refactor: reduce repeated UV transformations for mainTex in URP#717
refactor: reduce repeated UV transformations for mainTex in URP#717
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors shader code by introducing a reusable UV variable and removing obsolete code comments. The changes improve code maintainability by eliminating repeated UV transformations and cleaning up deprecated assignments.
Changes:
- Introduced
mainTexUVvariable to cache UV transformations instead of recalculating them multiple times - Removed obsolete version comments and deprecated
_Color = _BaseColorassignment - Applied consistent UV variable usage across texture sampling operations
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| UniversalToonBodyShadingGradeMap.hlsl | Added mainTexUV variable and replaced inline UV transformations with the cached variable; removed deprecated color assignment |
| UniversalToonBodyDoubleShadeWithFeather.hlsl | Added mainTexUV variable and replaced inline UV transformations; removed deprecated color assignment and version comments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),firstShadeTex, _Use_1stAs2nd); | ||
| const float4 mainTex = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, mainTexUV); | ||
| const float4 firstShadeTex = lerp(SAMPLE_TEXTURE2D(_1st_ShadeMap, sampler_MainTex, mainTexUV),mainTex, _Use_BaseAs1st); | ||
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, mainTexUV),firstShadeTex, _Use_1stAs2nd); |
There was a problem hiding this comment.
Missing space after comma in function calls. Add a space after the comma following 'mainTexUV' to maintain consistent code formatting with other function calls in the file.
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, mainTexUV),firstShadeTex, _Use_1stAs2nd); | |
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, mainTexUV), firstShadeTex, _Use_1stAs2nd); |
| 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 float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex)),firstShadeTex, _Use_1stAs2nd); | ||
| const float4 secondShadeTex = lerp(SAMPLE_TEXTURE2D(_2nd_ShadeMap, sampler_MainTex, mainTexUV),firstShadeTex, _Use_1stAs2nd); |
There was a problem hiding this comment.
Missing space after comma in function calls. Add a space after the comma following 'mainTexUV' to maintain consistent code formatting with other function calls in the file.
No description provided.