Skip to content

Commit a4431a2

Browse files
svc-reach-platform-supportEvergreen
authored andcommitted
[Port] [6000.3] Fix additional lights in Forward rendering
1 parent 9145509 commit a4431a2

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsBasic.shadersubgraph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@
849849
"m_FunctionName": "AddAdditionalLightsBasic",
850850
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
851851
"m_FunctionSourceUsePragmas": true,
852-
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
852+
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
853853
}
854854

855855
{

Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsColorize.shadersubgraph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@
12691269
"m_FunctionName": "AddAdditionalLightsColorize",
12701270
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
12711271
"m_FunctionSourceUsePragmas": true,
1272-
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
1272+
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
12731273
}
12741274

12751275
{

Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@
11401140
"m_FunctionName": "AddAdditionalLightsHalfLambert",
11411141
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
11421142
"m_FunctionSourceUsePragmas": true,
1143-
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = dot(WorldNormal, light.direction);\n float halfLambert = NdotL * 0.5 + 0.5;\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * halfLambert;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
1143+
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = dot(WorldNormal, light.direction);\r\n float halfLambert = NdotL * 0.5 + 0.5;\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * halfLambert;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
11441144
}
11451145

11461146
{

Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsSimple.shadersubgraph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@
11521152
"m_FunctionName": "AddAdditionalLightsSimple",
11531153
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
11541154
"m_FunctionSourceUsePragmas": true,
1155-
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
1155+
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
11561156
}
11571157

11581158
{

Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsURP.shadersubgraph

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@
11481148
"m_FunctionName": "AddAdditionalLights",
11491149
"m_FunctionSource": "3beadf505dbc54f4cae878435013d751",
11501150
"m_FunctionSourceUsePragmas": true,
1151-
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n half Roughness = pow(1 - Smoothness, 2);\r\n half Roughness2 = Roughness * Roughness;\r\n\thalf Roughness2Minus1 = Roughness2 - 1;\r\n\thalf normalizationTerm = (Roughness * half(4.0) + half(2.0));\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Convert the pixel light index to the light data index\r\n\t\t#if !USE_CLUSTER_LIGHT_LOOP\r\n\t\t\tlightIndex = GetPerObjectLightIndex(lightIndex);\r\n\t\t#endif\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = NdotL * atten;\r\n //DirectBRDFSpecular\r\n\r\n float3 lightDirectionWSFloat3 = float3(light.direction);\r\n float3 halfDir = SafeNormalize(lightDirectionWSFloat3 + float3(WorldView));\r\n float NoH = saturate(dot(float3(WorldNormal), halfDir));\r\n half LoH = half(saturate(dot(lightDirectionWSFloat3, halfDir)));\r\n float d = NoH * NoH * Roughness2Minus1 + 1.00001f;\r\n half LoH2 = LoH * LoH;\r\n half spec = Roughness2 / ((d * d) * max(0.1h, LoH2) * normalizationTerm);\r\n #if REAL_IS_HALF\r\n spec = spec - HALF_MIN;\r\n spec = clamp(spec, 0.0, 1000.0);\r\n #endif\t\t\r\n float3 thisSpecular = spec * Reflectance * NdotL * atten;\r\n\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
1151+
"m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n half Roughness = pow(1 - Smoothness, 2);\r\n half Roughness2 = Roughness * Roughness;\r\n\thalf Roughness2Minus1 = Roughness2 - 1;\r\n\thalf normalizationTerm = (Roughness * half(4.0) + half(2.0));\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = NdotL * atten;\r\n //DirectBRDFSpecular\r\n\r\n float3 lightDirectionWSFloat3 = float3(light.direction);\r\n float3 halfDir = SafeNormalize(lightDirectionWSFloat3 + float3(WorldView));\r\n float NoH = saturate(dot(float3(WorldNormal), halfDir));\r\n half LoH = half(saturate(dot(lightDirectionWSFloat3, halfDir)));\r\n float d = NoH * NoH * Roughness2Minus1 + 1.00001f;\r\n half LoH2 = LoH * LoH;\r\n half spec = Roughness2 / ((d * d) * max(0.1h, LoH2) * normalizationTerm);\r\n #if REAL_IS_HALF\r\n spec = spec - HALF_MIN;\r\n spec = clamp(spec, 0.0, 1000.0);\r\n #endif\t\t\r\n float3 thisSpecular = spec * Reflectance * NdotL * atten;\r\n\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif"
11521152
}
11531153

11541154
{

0 commit comments

Comments
 (0)