Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit a466b1e

Browse files
committed
bugfix to support the shader for webgl
1 parent 8fde061 commit a466b1e

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Runtime/Shader/Tiles3D.shader

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,38 +95,48 @@
9595
Name "ShadowCaster"
9696
Tags { "LightMode" = "ShadowCaster" }
9797

98+
Cull Back
99+
ZWrite On
100+
ZTest LEqual
101+
98102
HLSLPROGRAM
99103
#pragma vertex vert
100104
#pragma fragment frag
101-
102105
#pragma multi_compile_instancing
103106

104107
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
105-
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShadowCasterPass.hlsl"
106108

107109
struct Attributes
108110
{
109111
float4 vertex : POSITION;
110112
float3 normal : NORMAL;
113+
UNITY_VERTEX_INPUT_INSTANCE_ID
111114
};
112115

113116
struct Varyings
114117
{
115118
float4 positionCS : SV_POSITION;
119+
UNITY_VERTEX_OUTPUT_STEREO
116120
};
117121

118122
Varyings vert(Attributes input)
119123
{
120124
Varyings output;
121-
float3 positionWS = TransformObjectToWorld(input.vertex.xyz);
122-
float3 normalWS = TransformObjectToWorldNormal(input.normal);
123-
output.positionCS = GetShadowCasterPositionCS(input.vertex, normalWS);
125+
UNITY_SETUP_INSTANCE_ID(input);
126+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
127+
128+
float3 worldPos = TransformObjectToWorld(input.vertex.xyz);
129+
float3 worldNormal = TransformObjectToWorldNormal(input.normal);
130+
131+
worldPos += worldNormal * 0.001; //prevent zfighting spots
132+
133+
output.positionCS = TransformWorldToHClip(worldPos);
124134
return output;
125135
}
126136

127137
float4 frag(Varyings input) : SV_Target
128138
{
129-
return 0;
139+
return 0.0;
130140
}
131141
ENDHLSL
132142
}

0 commit comments

Comments
 (0)