Skip to content

Commit 27fbed5

Browse files
committed
[Fix] fix bugs and grammers
1 parent b1eedfb commit 27fbed5

10 files changed

Lines changed: 20 additions & 13 deletions

Assets/Shaders/Chapter6/Chapter6-BlinnPhong.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// Transform the vertex from object space to projection space
3636
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
3737

38-
// Transform the normal fram object space to world space
38+
// Transform the normal from object space to world space
3939
o.worldNormal = mul(v.normal, (float3x3)_World2Object);
4040

4141
// Transform the vertex from object spacet to world space

Assets/Shaders/Chapter6/Chapter6-DiffusePixelLevel.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Transform the vertex from object space to projection space
3131
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
3232

33-
// Transform the normal fram object space to world space
33+
// Transform the normal from object space to world space
3434
o.worldNormal = mul(v.normal, (float3x3)_World2Object);
3535

3636
return o;

Assets/Shaders/Chapter6/Chapter6-DiffuseVertexLevel.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// Get ambient term
3434
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
3535

36-
// Transform the normal fram object space to world space
36+
// Transform the normal from object space to world space
3737
fixed3 worldNormal = normalize(mul(v.normal, (float3x3)_World2Object));
3838
// Get the light direction in world space
3939
fixed3 worldLight = normalize(_WorldSpaceLightPos0.xyz);

Assets/Shaders/Chapter6/Chapter6-HalfLambert.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// Transform the vertex from object space to projection space
3131
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
3232

33-
// Transform the normal fram object space to world space
33+
// Transform the normal from object space to world space
3434
o.worldNormal = mul(v.normal, (float3x3)_World2Object);
3535

3636
return o;

Assets/Shaders/Chapter6/Chapter6-SpecularPixelLevel.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// Transform the vertex from object space to projection space
3636
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
3737

38-
// Transform the normal fram object space to world space
38+
// Transform the normal from object space to world space
3939
o.worldNormal = mul(v.normal, (float3x3)_World2Object);
4040
// Transform the vertex from object spacet to world space
4141
o.worldPos = mul(_Object2World, v.vertex).xyz;

Assets/Shaders/Chapter6/Chapter6-SpecularVertexLevel.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Get ambient term
3838
fixed3 ambient = UNITY_LIGHTMODEL_AMBIENT.xyz;
3939

40-
// Transform the normal fram object space to world space
40+
// Transform the normal from object space to world space
4141
fixed3 worldNormal = normalize(mul(v.normal, (float3x3)_World2Object));
4242
// Get the light direction in world space
4343
fixed3 worldLightDir = normalize(_WorldSpaceLightPos0.xyz);

Assets/Shaders/Chapter9/Chapter9-AlphaBlendWithShadow.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
5454

55-
// Pass shadow coordinates to pixel shade
55+
// Pass shadow coordinates to pixel shader
5656
TRANSFER_SHADOW(o);
5757

5858
return o;

Assets/Shaders/Chapter9/Chapter9-AlphaTestWithShadow.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
5353

54-
// Pass shadow coordinates to pixel shade
54+
// Pass shadow coordinates to pixel shader
5555
TRANSFER_SHADOW(o);
5656

5757
return o;

Assets/Shaders/Chapter9/Chapter9-AttenuationAndShadowUseBuildInFunctions.shader

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
o.worldPos = mul(_Object2World, v.vertex).xyz;
4949

50-
// Pass shadow coordinates to pixel shade
50+
// Pass shadow coordinates to pixel shader
5151
TRANSFER_SHADOW(o);
5252

5353
return o;
@@ -117,7 +117,7 @@
117117

118118
o.worldPos = mul(_Object2World, v.vertex).xyz;
119119

120-
// Pass shadow coordinates to pixel shade
120+
// Pass shadow coordinates to pixel shader
121121
TRANSFER_SHADOW(o);
122122

123123
return o;

Assets/Shaders/Chapter9/Chapter9-ForwardRendering.shader

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,17 @@
127127
#ifdef USING_DIRECTIONAL_LIGHT
128128
fixed atten = 1.0;
129129
#else
130-
float3 lightCoord = mul(_LightMatrix0, float4(i.worldPos, 1)).xyz;
131-
fixed atten = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL;
130+
#if defined (POINT)
131+
float3 lightCoord = mul(_LightMatrix0, float4(i.worldPos, 1)).xyz;
132+
fixed atten = tex2D(_LightTexture0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL;
133+
#elif defined (SPOT)
134+
float4 lightCoord = mul(_LightMatrix0, float4(i.worldPos, 1));
135+
fixed atten = (lightCoord.z > 0) * tex2D(_LightTexture0, lightCoord.xy / lightCoord.w + 0.5).w * tex2D(_LightTextureB0, dot(lightCoord, lightCoord).rr).UNITY_ATTEN_CHANNEL;
136+
#else
137+
fixed atten = 1.0;
138+
#endif
132139
#endif
133-
140+
134141
return fixed4((diffuse + specular) * atten, 1.0);
135142
}
136143

0 commit comments

Comments
 (0)