Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Runtime/Resources/CesiumForUnityStencilShadowVolume.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Shader "Custom/CesiumForUnityStencilShadowVolume"
{
Properties
{
_Color ("Color",Color) = (1,1,1,1)
}
SubShader
{
Tags { "RenderType"="Opaque" "RenderPipeline"="UniversalPipeline" }

//Using double-sided stencil, configured with 2 passes
Pass
{
Name "StencilDepthRenderState"
Tags{"LightMode" = "Step1"}
Cull Off
Stencil
{
Ref 0
//Comp always//equal

CompFront Always
FailFront Keep
ZFailFront DecrWrap
PassFront Keep

CompBack Always
FailBack Keep
ZFailBack IncrWrap
PassBack Keep
}
ZTest On
ZWrite Off
ColorMask 0
}
Pass
{
Name "StencilColorRenderState"
Tags{"LightMode" = "Step2"}
Cull Off
Stencil
{
Ref 0

CompFront NotEqual
FailFront Zero
ZFailFront Zero
PassFront Zero

CompBack NotEqual
FailBack Zero
ZFailBack Zero
PassBack Zero
}
ZTest Off
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha

HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
# include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

//Using To UnityProperty
half4 _Color;

float4 vert(float4 positionOS:POSITION): SV_POSITION
{
//ObjectSpace To ClipSpace
float4 OUT;
OUT = TransformObjectToHClip(positionOS.xyz);
return OUT;
}
half4 frag(): SV_Target
{
//Set to Color
//half4 color = half4(0,1,0,1);
half4 color = _Color;
return color;
}
ENDHLSL
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Runtime/Resources/CesiumForUnityStencilShadowVolume_Mat.mat
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: CesiumForUnityStencilShadowVolume_Mat
m_Shader: {fileID: 4800000, guid: b89edf0f547ce004ca69ca33d00656bd, type: 3}
m_Parent: {fileID: 0}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs: []
m_Ints: []
m_Floats: []
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
m_BuildTextureStacks: []

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.