-
Notifications
You must be signed in to change notification settings - Fork 855
[HDRP] Add documentation section about editing shader at runtime #5688
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
Conversation
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. HDRP Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
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.
Topic and the addition make perfect sense. Approving ✔👍
@@ -0,0 +1,11 @@ | |||
# Editing shader properties at runtime | |||
|
|||
For High Definition Render Pipeline (HDRP) non-Shader Graph shaders, such as the [Lit](Lit-Shader.md), [Unlit](Unlit-Shader.md) shaders, changing a property at runtime, in some cases, does not have any effect. This is because if the property is not enabled before runtime, the specific shader variant associated with this property is not included in the shader (and is also not included when bulding a player). To include the shader variant, the proper keywords need to be enabled on the material before editing. |
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.
There is various incorrect statement here. Probe exist also for shader graph.
Here is a proposal:
Each shader feature (Keyword) use in a shader (link to the doc) produce a different shader code to compile. Each of this shader code is call a shader variant. Unity try to reduce the number of shader variant to compile by only considering the sets of kewords use in a Material. Other shader variant don't exist. When building a Player, it is the union of the all shader variant based on keyword used that is compiled.
If you try to create a Material at runtime and change proerties which affect which keywords is enabled. In case this combination was not existing when building the player, this shader variant will not exist and the rendering will fail.
This can happen if you use for example the HDRP/Lit shader and try to setup a iridecence material but don't have any ididescence properties enabled in an already existing Material.
^ So this is not good but this is what I think we should express. We should be clear that 1) This is for Unity in general, not only HDRP. Builtin have same issue. And that this is also for shader graph if you add keyword in shader graph.
Then the goal is to explain that users must enable the right keyword at runtime and that this shader variant need to exist.
this statement can be share with URP documentation.
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.
Thanks, will update with a new proposal with this info !
Updated the text based on what has been discussed with @sebastienlagarde |
...nity.render-pipelines.high-definition/Documentation~/editing-shader-properties-at-runtime.md
Outdated
Show resolved
Hide resolved
This is large enough to need editorial review so I'm working on this in a google doc.. @remi-chapelain I'll invite you for a tech review when I've made changes :). |
update on this PR? |
@sebastienlagarde This doc has been absorbed into the shader docs. See the draft google doc for input from Kerry. Please close and do not merge this PR. |
Closing this PR because the information have been included in this more recent one. |
Purpose of this PR
Following this forum post, I propose adding this bit of information to the documentation.
Even though, the recommended route to take is to use the Lit master node in shader graph instead of using HDRP/Lit materials.
I still think users will try it (cf forum post) and thus makes sense to include it.
Comments to reviewers
Text is "draft", feel free to correct anything according to proper English grammar and documentation standards :)