-
Notifications
You must be signed in to change notification settings - Fork 855
[URP] Lit Shader Detail Fixes #5432
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
ad11245
bdec597
95c3983
989685f
ff2cb4c
e969dfe
5b796c9
41d3c06
c962cd8
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 |
---|---|---|
|
@@ -373,6 +373,7 @@ public static void UpdateStandardMaterialKeywords(Material material) | |
CoreUtils.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap")); | ||
CoreUtils.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_MetallicGlossMap")); | ||
UpdateSurfaceTypeAndBlendMode(material); | ||
UpdateDetailScaleOffset(material); | ||
BaseShaderGUI.SetupMaterialBlendMode(material); | ||
} | ||
|
||
|
@@ -391,9 +392,24 @@ public static void UpdateStandardSpecularMaterialKeywords(Material material) | |
CoreUtils.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_SpecGlossMap")); | ||
CoreUtils.SetKeyword(material, "_SPECULAR_SETUP", true); | ||
UpdateSurfaceTypeAndBlendMode(material); | ||
UpdateDetailScaleOffset(material); | ||
BaseShaderGUI.SetupMaterialBlendMode(material); | ||
} | ||
|
||
static void UpdateDetailScaleOffset(Material material) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. minor: it would be good to explain the upgrade behavior in comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added more info |
||
{ | ||
// In URP details tile/offset is multipied with base tile/offset, where in builtin is not | ||
// Basically we setup new tile/offset values that in shader they would result in same values as in builtin | ||
// This archieved with inverted calculation where scale=detailScale/baseScale and tile=detailOffset-baseOffset*scale | ||
var baseScale = material.GetTextureScale("_BaseMap"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this specific to our shaders? _BaseMap is attributed as [MainTexture] for us and default is of course _MainTexture. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is specific from builtin->urp shader where tile/offset needs to be recalculated to retain same visual |
||
var baseOffset = material.GetTextureOffset("_BaseMap"); | ||
var detailScale = material.GetTextureScale("_DetailAlbedoMap"); | ||
var detailOffset = material.GetTextureOffset("_DetailAlbedoMap"); | ||
var scale = new Vector2(baseScale.x == 0 ? 0 : detailScale.x / baseScale.x, baseScale.y == 0 ? 0 : detailScale.y / baseScale.y); | ||
material.SetTextureScale("_DetailAlbedoMap", scale); | ||
material.SetTextureOffset("_DetailAlbedoMap", new Vector2((detailOffset.x - baseOffset.x * scale.x), (detailOffset.y - baseOffset.y * scale.y))); | ||
} | ||
|
||
// Converts from legacy RenderingMode to new SurfaceType and BlendMode | ||
static void UpdateSurfaceTypeAndBlendMode(Material material) | ||
{ | ||
|
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.
I wonder if this is clear enough for our users. I think this might be confusing for some users, perhaps expand it a bit.
I think a good error message (is hard :) ) gives you the error and context (runtime parameters) and then points/guides you towards a likely fix.
Can we give the current format of the texture in the message? so that you know what the format is when it's wrong and what it should be.
These were just my thoughts on this. No specific implementation requirements.
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.
This is infobox, so usually we do not go so deep in details for the sake of UX. I kinda copied this from normal texture info box. Do you have particular suggestion into what it should change for better readability?
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.
I also think some users will struggle with connecting linear space to the sRGB tick box. Maybe "This texture is marked as sRGB (Gamma space)"?
I think its ok to be a bit more clear since the "fix now" button is not available.