Skip to content

Conversation

anisunity
Copy link
Contributor

@anisunity anisunity commented Oct 21, 2021

https://jira.unity3d.com/browse/HDRP-110

This PR implements an initial version of the Water System for HDRP. It still be significantly improved before
The design and scope document can be found here:
https://confluence.unity3d.com/display/HDRP/HDRP+Water+System

image
image

This system allows for the users to add ocean, rivers and pools to their scenes.

Testing status
Check the feedback document here: https://shorturl.at/efluM

@github-actions
Copy link

github-actions bot commented Oct 21, 2021

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.
Link to Yamato: https://unity-ci.cds.internal.unity3d.com/project/902/
Search for your PR branch using the search bar at the top, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

HDRP
/jobDefinition/.yamato%2Fall-hdrp.yml%23PR_HDRP_trunk
With changes to HDRP packages, you should also run
/jobDefinition/.yamato%2Fall-lightmapping.yml%23PR_Lightmapping_trunk

SRP Core
You could run ABV on your branch before merging your PR, but it will start A LOT of jobs. Please be responsible about it and run it only when you feel the PR is ready:
/jobDefinition/.yamato%252F_abv.yml%2523all_project_ci_trunk
Be aware that any modifications to the Core package impacts everyone in the Graphics repo so please discuss the PR with your lead.

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure we don't have all those function already available somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok currently it was in cloud :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i moved it from cloud specific to a more generic file

Copy link
Contributor

Choose a reason for hiding this comment

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

So those function should be moved into the file name: com.unity.render-pipelines.high-definition\Runtime\Lighting\SphericalHarmonics.cs . There is other function for SH there.

@remi-chapelain remi-chapelain requested a review from a team October 25, 2021 11:53
@anisunity anisunity force-pushed the HDRP/water-system branch 3 times, most recently from 63d4717 to a7c43ac Compare November 10, 2021 09:21
@anisunity anisunity changed the title [WIP] Implementing a water system for HDRP Implementing a water system for HDRP Nov 22, 2021
@anisunity anisunity marked this pull request as ready for review November 23, 2021 09:15
@anisunity anisunity requested a review from a team as a code owner November 23, 2021 09:15
Copy link
Contributor

@remi-chapelain remi-chapelain left a comment

Choose a reason for hiding this comment

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

PR is in good shape for merging a v1 ✔️

We're still missing a few things to be able to consider it really finished like:

  • Documentation (will come later since it will evolve with the UX pass coming)
  • Metal support (has been disabled for now, but will make a fogbugz as soon as this is merged and hopefully will be fixed asap)

You can find more info in the confluence test document here.
As for the feedback document, most of the issues have been fixed and less serious issues/concerns will be fixed in the upcoming weeks.

@anisunity
Copy link
Contributor Author

Also this needs screenshot updates on the other platforms, but I am going to wait for the branching to do it. @sebastienlagarde

@anisunity
Copy link
Contributor Author

Fixed some issue with the normal management that improves significantly the rendering at high wind speeds

$VertexDescription.Position: input.positionOS = vertexDescription.Position;
$VertexDescription.Normal: input.normalOS = vertexDescription.Normal;
$VertexDescription.Tangent: input.tangentOS.xyz = vertexDescription.Tangent;
$VertexDescription.uv0: input.uv0 = vertexDescription.uv0;
Copy link
Contributor

Choose a reason for hiding this comment

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

note for me

@@ -0,0 +1,70 @@
VertexDescriptionInputs AttributesMeshToVertexDescriptionInputs(AttributesMesh input)
Copy link
Contributor

Choose a reason for hiding this comment

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

note for me


// This intends to simulate indirect specular "multi bounce"
float3 attenuation = 1.0f;
if (R.y < 0.0)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a comment that it assume Y is up? and assume water is flat

// Update the water surfaces
var commandBuffer = CommandBufferPool.Get("");
UpdateWaterSurfaces(commandBuffer);
renderContext.ExecuteCommandBuffer(commandBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

Pure sanity check, @JulienIgnace-Unity any thought about calling update of water surface with command buffer like this?

// Water textures
[Reload("Runtime/RenderPipelineResources/Texture/Water/FoamSurface.png")]
public Texture2D foamSurface;
[Reload("Runtime/RenderPipelineResources/Texture/Water/FoamNormals.tga")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reasons this isn't a png here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do later

numBands = nbBands;

// Allocate the buffers
phillipsSpectrumBuffer = RTHandles.Alloc(simulationResolution, simulationResolution, numBands, dimension: TextureDimension.Tex2DArray, colorFormat: GraphicsFormat.R16G16_SFloat, enableRandomWrite: true, wrapMode: TextureWrapMode.Repeat);
Copy link
Contributor

Choose a reason for hiding this comment

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

sanity check, is this always allocated even if water is disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only allocated if the system is on


using (var builder = renderGraph.AddRenderPass<WaterRenderingData>("Render Water Surfaces", out var passData, ProfilingSampler.Get(HDProfileId.WaterSurfaceRendering)))
{
builder.EnableAsyncCompute(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

? is it for future testing?

UNITY_TRANSFER_INSTANCE_ID(input, output);

// Apply the mesh modifications that come from the shader graph
float3 positionOS;
Copy link
Contributor

Choose a reason for hiding this comment

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

note for me

Copy link
Contributor

Choose a reason for hiding this comment

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

Note for self: evaluate the need of duplicated the shaderpasswaterforward.hlsl instead of reusing regular file

GetSurfaceAndBuiltinData(input, V, posInput, surfaceData, builtinData);

// Light layers need to be set manually here as there is no mesh renderer
builtinData.renderingLayers = DEFAULT_LIGHT_LAYERS;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah good point, light layers will need to works with water, so we will need to add them on the water volume control or the equivalent mesh

@anisunity
Copy link
Contributor Author

Launching the tests, yay!

@anisunity
Copy link
Contributor Author

Did the fixed asked by @sebastienlagarde, rebased master and relaunching the tests

@anisunity
Copy link
Contributor Author

relaunched tests

@anisunity
Copy link
Contributor Author

Fixed memory leak and relaunching tests


// Make sure to release the resources if they have been created (before HDRP destroys them)
if (simulation != null && simulation.AllocatedTextures())
simulation.ReleaseSmmulationResources();

Choose a reason for hiding this comment

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

I think this is a typo, it should be ReleaseSimulationResources

Note: Sorry if I shouldn't comment on the PR, I saw the comment you left a while back about this but I still thought I should point this out. Have a great day.

Copy link
Contributor Author

@anisunity anisunity Nov 30, 2021

Choose a reason for hiding this comment

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

image

@anisunity anisunity removed the request for review from a team November 30, 2021 11:46
{
// Update the water surfaces
var commandBuffer = CommandBufferPool.Get("");
UpdateWaterSurfaces(commandBuffer);
Copy link
Contributor

Choose a reason for hiding this comment

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

note for me. Maybe run async in the future

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants