Skip to content

Fix Refraction #2220

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

Merged
merged 23 commits into from
Oct 20, 2020
Merged

Fix Refraction #2220

merged 23 commits into from
Oct 20, 2020

Conversation

alelievr
Copy link
Member

@alelievr alelievr commented Oct 14, 2020

Purpose of this PR

  • Expose the refraction mode to the material inspector from SG. Note that the refraction mode is only displayed in the material when it's enabled in the shader graph:
    image

  • Added a warning when using a blend mode different than Alpha and refraction is enabled:
    image

  • Updated documentation accordingly:
    image

  • Also fixed this issue:
    Issue: In the ShaderGraph settings, we can set the rendering pass value to pre-refraction with refraction enabled, which should not be possible.
    This PR fixes this issue and hides the pre-refraction option in the rendering pass field when refraction is enabled in the shader.

  • Note that this PR also include the code from Fix render queue migration to 10.x #2198 that was reverted from staging

Behavior changes in the refraction material UI: now the pre-refraction is always visible in the rendering pass field and a warning is displayed if refraction is enabled with pre-refraction rendering pass instead of the refraction block being hidden.

image


Testing status

Tested that pre-refraction is hidden when we enabled refraction in both the material and ShaderGraph.
Renderingpass

image

I also ran DXR + HDRP_Tests, all green

@alelievr alelievr self-assigned this Oct 14, 2020
@github-actions github-actions bot added the HDRP label Oct 14, 2020
@github-actions
Copy link

It appears that you made a non-draft PR!
Please convert your PR to draft (button on the right side of the page)
and cancel any jobs that started on Yamato.
See the PR template for more information.
Thank you!

# Conflicts:
#	com.unity.render-pipelines.high-definition/Editor/Material/Lit/ShaderGraph/HDLitSubTarget.Migration.cs
#	com.unity.render-pipelines.high-definition/Editor/Material/Unlit/ShaderGraph/HDUnlitSubTarget.Migration.cs
# Conflicts:
#	com.unity.render-pipelines.high-definition/CHANGELOG.md
Copy link
Contributor

@TomasKiniulis TomasKiniulis left a comment

Choose a reason for hiding this comment

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

Checking with Antoine, there's an issue with Blending Mode still getting displayed in material(and material being affected by it) when material is created with Refraction Model set None. After shadergraph Refraction Model is changed to anything from "none", materials should hide Blending Mode option, but that does not happen

@alelievr
Copy link
Member Author

Fixed blend mode issue
BlnendMode

@alelievr alelievr changed the title Fix pre-refraction option in shadergraph Fix Refraction Oct 15, 2020
Copy link
Contributor

@TomasKiniulis TomasKiniulis left a comment

Choose a reason for hiding this comment

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

Awesome! Not running into any issues anymore. Love it that there's a warning now in Shadergraph too, when blending mode is not alpha
image

Tested material creation before refraction is set and after refraction is set, changing refraction type ant reimporting the material keeps the changes unchanged

@sebastienlagarde sebastienlagarde changed the base branch from HDRP/staging to master October 16, 2020 15:44
@sebastienlagarde
Copy link
Contributor

PR retargeted to master

@@ -233,7 +233,8 @@ public static System.Collections.Generic.List<HDRenderQueue.RenderQueueType> Get
}
else
{
result.Add(HDRenderQueue.RenderQueueType.PreRefraction);
if (!hasRefraction)
Copy link
Contributor

Choose a reason for hiding this comment

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

thinking about that, what is happening if we are on prerefraction rendering pass and we select a refraction mode . In shader code it will work (refraction is just disabled), but in the UI. cc @TomasKiniulis

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it is the same problem than for blend mode, we will need to always display the value but have a warning to say that it is not working. Thought?

Copy link
Member Author

Choose a reason for hiding this comment

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

When I tested it was automatically setting the rendering pass to Default instead of Pre-Refraction

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the warning in both ShaderGraph UI and material inspector.

As a side effect, the refraction UI is now always visible even if we select pre-refraction rendering pass

image

@alelievr alelievr requested a review from JordanL8 October 20, 2020 14:22
@@ -69,6 +69,10 @@ To create a new Lit Material, navigate to your Project's Asset window, right-cli

Unity exposes this section if you select **Transparent** from the **Surface Type** drop-down. For information on the properties in this section, see the [Surface Type documentation](Surface-Type.md#TransparencyInputs).

:warning: When you enabled the **Refraction**, make sure to use the **Blend Mode** **Alpha**, otherwise the effect will not work as expected. A similar warning will be displayed in the material inspector if you enabled refraction with a **Blend Mode** different than **Alpha**.
Copy link
Contributor

@JordanL8 JordanL8 Oct 20, 2020

Choose a reason for hiding this comment

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

No emojis ❗ :rage1:

Be aware that when you enable Refraction, make sure to set Blend Mode to Alpha, otherwise the effect does not work as expected. If you enable Refraction and use a Blend Mode other than Alpha, a warning displays in the material Inspector.

Copy link
Member Author

Choose a reason for hiding this comment

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

No emojis ❗ :rage1:

noooo! (btw, do you know why? we have them in the inspector, why not in the doc?)

Copy link
Contributor

@JordanL8 JordanL8 left a comment

Choose a reason for hiding this comment

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

Rewrote a couple of bits

@alelievr alelievr requested a review from JordanL8 October 20, 2020 16:07
@sebastienlagarde sebastienlagarde merged commit a99c658 into master Oct 20, 2020
@sebastienlagarde sebastienlagarde deleted the HDRP/fix/pre-refraction-shadergraph branch October 20, 2020 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants