Skip to content

refactor: reduce repeated UV transformations for mainTex in URP#717

Merged
sindharta merged 3 commits intomasterfrom
refactor-urp
Jan 21, 2026
Merged

refactor: reduce repeated UV transformations for mainTex in URP#717
sindharta merged 3 commits intomasterfrom
refactor-urp

Conversation

@sindharta
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mainTexUV variable to cache UV transformations instead of recalculating them multiple times
  • Removed obsolete version comments and deprecated _Color = _BaseColor assignment
  • 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);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines +151 to +153
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);
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@sindharta sindharta changed the title Refactor urp refactor: reduce repeated UV transformations Jan 21, 2026
@sindharta sindharta changed the title refactor: reduce repeated UV transformations refactor: reduce repeated UV transformations for mainTex in URP Jan 21, 2026
@sindharta sindharta merged commit a5b5ba9 into master Jan 21, 2026
24 checks passed
@sindharta sindharta deleted the refactor-urp branch January 21, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants