-
Notifications
You must be signed in to change notification settings - Fork 206
opt: reduce duplicate albedo calculations in URP #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c3cc695
aa50968
35247a7
c734573
7ffb2d7
39925b4
1b6998d
176dcda
0a02803
af1213e
d2ede60
0c8a7c0
c6a0908
24d310d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,16 +144,18 @@ void frag(VertexOutput i, out float4 finalRGBA : SV_Target0 | |
| float3 halfDirection = normalize(viewDirection + lightDirection); | ||
|
|
||
| #ifdef _IS_PASS_FWDBASE | ||
| float3 Set_LightColor = lightColor.rgb; | ||
| float3 Set_BaseColor = lerp((_BaseColor.rgb * mainTex.rgb), | ||
| ((_BaseColor.rgb * mainTex.rgb) * Set_LightColor), _Is_LightColor_Base); | ||
| //v.2.0.5 | ||
| const float3 baseAlbedo = _BaseColor.rgb * mainTex.rgb; | ||
| const float4 firstShadeTex = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex, mainTexUV),mainTex, _Use_BaseAs1st); | ||
| float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * firstShadeTex.rgb),((_1st_ShadeColor.rgb * firstShadeTex.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| const float3 firstShadeAlbedo = _1st_ShadeColor.rgb * firstShadeTex.rgb; | ||
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, mainTexUV),firstShadeTex, _Use_1stAs2nd); | ||
| float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * secondShadeTex.rgb),((_2nd_ShadeColor.rgb * secondShadeTex.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| const float3 secondShadeAlbedo = _2nd_ShadeColor.rgb * secondShadeTex.rgb; | ||
|
Comment on lines
+147
to
+151
|
||
|
|
||
| //v.2.0.5 | ||
| float3 Set_LightColor = lightColor.rgb; | ||
| float3 Set_BaseColor = lerp((baseAlbedo),(baseAlbedo * Set_LightColor), _Is_LightColor_Base); | ||
| float3 Set_1st_ShadeColor = lerp(firstShadeAlbedo,(firstShadeAlbedo * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| float3 Set_2nd_ShadeColor = lerp(secondShadeAlbedo,(secondShadeAlbedo * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| float _HalfLambert_var = 0.5 * dot(lerp(i.normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; | ||
|
|
||
|
|
||
| //v.2.0.6 | ||
| //Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold. | ||
|
|
@@ -358,11 +360,10 @@ void frag(VertexOutput i, out float4 finalRGBA : SV_Target0 | |
| //v.2.0.5: Filtering the high intensity zone of PointLights | ||
| float3 Set_LightColor = lightColor; | ||
| // | ||
| float3 Set_BaseColor = lerp((_BaseColor.rgb * mainTex.rgb * _LightIntensity), | ||
| ((_BaseColor.rgb * mainTex.rgb) * Set_LightColor), _Is_LightColor_Base); | ||
| float3 Set_BaseColor = lerp((baseAlbedo * _LightIntensity),(baseAlbedo * Set_LightColor), _Is_LightColor_Base); | ||
| //v.2.0.5 | ||
| float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * firstShadeTex.rgb * _LightIntensity),((_1st_ShadeColor.rgb * firstShadeTex.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * secondShadeTex.rgb * _LightIntensity),((_2nd_ShadeColor.rgb * secondShadeTex.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| float3 Set_1st_ShadeColor = lerp((firstShadeAlbedo * _LightIntensity),(firstShadeAlbedo * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| float3 Set_2nd_ShadeColor = lerp((secondShadeAlbedo * _LightIntensity),(secondShadeAlbedo * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| float _HalfLambert_var = 0.5 * dot(lerp(i.normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; | ||
|
|
||
| //v.2.0.5: | ||
|
|
@@ -451,11 +452,10 @@ void frag(VertexOutput i, out float4 finalRGBA : SV_Target0 | |
| //v.2.0.5: Filtering the high intensity zone of PointLights | ||
| float3 Set_LightColor = lightColor; | ||
| // | ||
| float3 Set_BaseColor = lerp((_BaseColor.rgb * mainTex.rgb * _LightIntensity), | ||
| ((_BaseColor.rgb * mainTex.rgb) * Set_LightColor), _Is_LightColor_Base); | ||
| float3 Set_BaseColor = lerp((baseAlbedo * _LightIntensity),(baseAlbedo * Set_LightColor), _Is_LightColor_Base); | ||
| //v.2.0.5 | ||
| float3 Set_1st_ShadeColor = lerp((_1st_ShadeColor.rgb * firstShadeTex.rgb * _LightIntensity),((_1st_ShadeColor.rgb * firstShadeTex.rgb) * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| float3 Set_2nd_ShadeColor = lerp((_2nd_ShadeColor.rgb * secondShadeTex.rgb * _LightIntensity),((_2nd_ShadeColor.rgb * secondShadeTex.rgb) * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| float3 Set_1st_ShadeColor = lerp((firstShadeAlbedo * _LightIntensity),(firstShadeAlbedo * Set_LightColor), _Is_LightColor_1st_Shade); | ||
| float3 Set_2nd_ShadeColor = lerp((secondShadeAlbedo * _LightIntensity),(secondShadeAlbedo * Set_LightColor), _Is_LightColor_2nd_Shade); | ||
| float _HalfLambert_var = 0.5 * dot(lerp(i.normalDir, normalDirection, _Is_NormalMapToBase), lightDirection) + 0.5; | ||
|
|
||
| //v.2.0.5: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace should be removed from the end of this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback