crest icon indicating copy to clipboard operation
crest copied to clipboard

ICollProvider queries excluding DynWaves

Open emaber opened this issue 5 years ago • 3 comments

we are trying to use DynWaves as a cosmetic feature only, but we don't want the dynamic waves to impact my simulation which is based on Ocean queries using OceanRenderer.Instance.CollisionProvider.

Unfortunately there seems to be no way to exclude DynWaves from the query.

Things we already explored:

  • Settings Anim Waves -> Collision Source: The CPU option excludes too many Ocean features
  • Tinkering with the compute shaders and trying to subtract the DynWaves texture from the AnimWaves texture during sample doesn't seem to work. (But we have limited understanding of that part of how Crest works :()

Is this something that can be achieved already, or planned in any way, or what would be the best approach to look into this?

Thank you

emaber avatar Nov 26 '20 20:11 emaber

Hi there, yeah its an issue with our stuff.

The CPU option excludes too many Ocean features

Which features out of interest? The CPU should be a valid option, but is rarely used and probably way out of date

The trouble is that the dynamic waves are simulated at multiple resolutions/cascades, and these are copied into the displacement textures, and then a 'combine' pass integrates the data from all the cascades together. It's all mixed up together. See our siggraph talk from last year for more info about the combine pass.

I think an approach to this might be:

  1. Add a texture array for the combined dynamic waves to LodDataDynWaves. See CreateCombineBuffer() function and code around it.
  2. After dynamic wave simulation, run the combine pass, similar to the CombinePassCompute() function to combine all the dynamic wave cascades
  3. Remove the code in ShapeCombine.compute that copies in the dynamic waves
  4. Add code to Ocean.shader to sample the combined dynamic waves (this would need to be added as a new sampler)

This separates the dynamic waves from the displacement textures. They would be combined separately, and sampled from the ocean shader. This means that the dynamic wave data wont be in the displacement textures that the queries sample.

huwb avatar Nov 26 '20 21:11 huwb

The CPU option excludes too many Ocean features

Which features out of interest? The CPU should be a valid option, but is rarely used and probably way out of date

Multiple Gerstner Inputs and attenuation.

[...]

Lot of information that we need to work on before we can provide a proper feedback on the rest!

Our understanding was that the _LD_TexArray_AnimatedWaves contains both the AnimWaves and DynWaves, while _LD_TexArray_DynamicWaves contains only the DynWaves.

So we just tried to do the following in "QueryDisplacements.compute":

return (wt_0 * _LD_TexArray_AnimatedWaves.SampleLevel(LODData_linear_clamp_sampler, uv0, 0).xyz + wt_1 * _LD_TexArray_AnimatedWaves.SampleLevel(LODData_linear_clamp_sampler, uv1, 0).xyz) - (wt_0 * _LD_TexArray_DynamicWaves.SampleLevel(LODData_linear_clamp_sampler, uv0, 0).xyz + wt_1 * _LD_TexArray_DynamicWaves.SampleLevel(LODData_linear_clamp_sampler, uv1, 0).xyz);

But it does not seem to work.

Thanks a lot for the quick answer for now. I'll update here once we work more on your proposed approach.

emaber avatar Nov 26 '20 22:11 emaber

Two problems with naively subtrating dynamic waves from animated waves:

  • Animated waves have been combined - all the big wavelengths have been copied up the cascade chain. Dynamic waves have not, the wavelengths are separated out across the cascade chain. The two things are incompatible.
  • When dynamic waves are copied in to the animated waves, a horizontal displacement is generated to give them chop - see ShapeCombine.compute or my siggraph talk. So _LD_TexArray_DynamicWaves.x has the dynamic wave height, but when its copied in a full xyz is generated.
  • Btw related to the previous point - _LD_TexArray_DynamicWaves.xyz is erroneous. The x component is height, y component is vel.

But i thought of an alternative approach that may work and be better:

  1. Leave animated waves the way they are now
  2. Perform a combine pass on the dynamic waves as described in my last post, probably into a new texture array
  3. In the query shader, subtract the dynamic waves, kind of like what you have, but used the combined dynamic waves, and generate a displacement to get the xyz you need

This is probably better as it avoids messing with the animated waves (which are used for foam and stuff), and avoids messing with the ocean shader.

huwb avatar Nov 27 '20 05:11 huwb