Skip to content
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

Refactor VFX / SG Integration (use any target) #3467

Merged
merged 208 commits into from Apr 28, 2021

Conversation

johnpars
Copy link
Contributor

@johnpars johnpars commented Feb 11, 2021

Purpose of this PR

Allow users to target VFX Graph with HDRP Master Node/Stack in ShaderGraph. Specifically it unlocks the following to users:

  • Support any HDRP material type (StackLit, Hair, etc.) for any VFX Output Context.
  • Support Vertex Stack in VFX (Replacing this PR).
  • Improve VFX Output Context UI by re-using Material UI blocks for surface option configuration.
Bubbles.mp4

The refactor is done with the following technical goals in mind:

  1. Consolidate the various VFX .template files into a single template, reducing code duplication and making VFX more easily maintainable if there are changes to HDRP shading architecture.
  2. Phase out the need for HDRP's specific VFX Context implementations (i.e. the "Output Particle Lit Mesh" etc.). Output contexts themselves should only describe the primitive/task type and not also suggest the material type- this is the responsibility of the shader graph.
  3. Use Shader Graph as the VFX shader generator and share as much information as possible with the render pipeline's (sub)target. This lets VFX automatically scale with HDRP whenever a new sub-target/material type is introduced. (Prior to this PR, the Visual Effect target would have to manually re-implement the work for each material type- and so far only supported lit/unlit).
  4. Serialize the generated VFX material within the VFX asset. Prior to this PR the material was generated on the fly and all of the render state was statically known at compile time. The problem with this is VFX must re-implement all of the render state configuration itself. By serializing the material we can easily re-use the HDRP material inspector UI blocks which are largely responsible for configuring render state and surface options.
  5. Keep the original VFX Shader Graph Integration. For now, this PR simply offers a new generation path, with plans for a future PR to support URP as well (for 21.2).

Usage

  1. Ensure Improved ShaderGraph Generation is enabled in the Visual Effects Preferences panel. It should be enabled by default.

image

  1. Select the new Support VFX Graph toggle in within the HDRP Target Graph Inspector and save the asset.

image

  1. In VFX Graph, assign the VFX compatible shader graph into the Shader Graph field. Note that exposed fragment and vertex properties in the Shader Graph will be exposed in the Graph View and configurable per-particle (this is exactly how the current SG support works).

image

  1. Configure the effect's render state & surface properties in the output context's inspector. Note that we now serialize materials within the VFX asset, and can re-use the material inspector generated by the shader graph. This allows us to holistically configure render state in HDRP between VFX and normal material renderers, and convey that information to the user in a familiar way.

image


Testing

From a user point of view, this PR introduces a slight adjustment in workflow.
From a quality/testing point of view this PR introduces various things that will require validation in various systems (HDRP, SG, VFX).

  • Manually verified that all HDRP sub targets compile for all VFX output types (mesh),
  • Manually verified motion vectors for all output types.
  • Manually verified support for vertex stack (and motion vectors for vertex stack + VFX animation at the same time).
  • Manually verified render state configuration via the new Context UI's material inspector.
  • Manually verified multiple output contexts in the same system.
  • Manually verified the new workflow of toggling VFX support in graph, and linking to it from VFX.
  • Manually verified support for the original Visual Target / integration.
  • Made a standalone build
  • Test Document
  • Yamato
  • Added new test 34_ShaderGraphGeneration to VFX_HDRP. @VladNeykov plans to add more robust testing in the FTP.

Comments to reviewers

Copy link
Contributor

@VladNeykov VladNeykov left a comment

Choose a reason for hiding this comment

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

Everything green on the test doc, thanks for the many iterations and your hard work on this @johnpars !

Copy link
Contributor

@PaulDemeulenaere PaulDemeulenaere left a comment

Choose a reason for hiding this comment

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

The head still have an unexpected "#pragma enable_d3d11_debug_symbols"
No real impact on execution beside build size.

@johnpars johnpars marked this pull request as ready for review April 27, 2021 03:32
@johnpars johnpars requested a review from a team as a code owner April 27, 2021 03:32
Copy link
Contributor

@PaulDemeulenaere PaulDemeulenaere left a comment

Choose a reason for hiding this comment

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

I double check the discussion and everything has been resolve.
LGTM, we have to be sure that Nightly_VFX_HDRP is 🟢 but also HDRP, we got this failure on last run with OSX :

[06:26:38.461 Information] [260/262] TestFinish
	name: UnityEngine.TestTools.Graphics.Tests.ImageAssertTests.PerPixel_BadB_Throws
	result: PASSED
	duration: 0.010073 seconds
[06:26:45.241 Information] LogEntry
	severity: Warning
	message: 61 TextureIDs were not freed
	stacktrace: 
	line: 1734
	file: ./Runtime/GfxDevice/GfxDevice.cpp

However, I don't think it's related to your change...
Great job @johnpars ! This refactor will unleash a lot of technical constraint we had with VisualEffectGraph integration.
FYI, I started to port your approach to URP (see this branch) but it's still in progress. I will come back to you once I have something working in both pipeline.

@sebastienlagarde
Copy link
Collaborator

Re-launched nightly with custom revision that should be green: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/HDRP%252Fsg-vfx-integration-improved/.yamato%252Fall-hdrp.yml%2523Nightly_HDRP_CUSTOM-REVISION/6546711/job/pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
10 participants