wave-harmonic / crest

A class-leading water system implemented in Unity
MIT License
3.4k stars 475 forks source link

Activating flow in the material when oceanrenderer is running does only work in editor #1139

Closed klauskobald closed 8 months ago

klauskobald commented 8 months ago

Current Behavior

I am checking for flow elements in the scene and activate all flow components then with this Coroutine:

    IEnumerator _flowactive(bool b)
    {
        var mat = Instantiate(oceanRenderer.OceanMaterial);
        mat.SetFloat("_Flow", b ? 1 : 0);
        yield return new WaitForEndOfFrame();
        _setCrest("_createFlowSim", null, b);
        yield return new WaitForEndOfFrame();
        oceanRenderer.OceanMaterial = mat;
    }

I use coroutine because it does not work synchronous. This works in the editor but not in any player. The flow itself works, but the rendering does not show the flow.

So before digging deeper, the question is: how much overhead does flow create, when there is no flow splines. Then I would just leave it on, if it does not matter.

Expected Behavior

flow rendering

Steps To Reproduce

No response

Unity Version

2021.3.31

Crest Version

latest

Render Pipeline

Universal

Editor or Standalone

Standalone

Environment

Any player

Anything else?

No response

klauskobald commented 8 months ago

I was thinking about it: maybe the shader is not available in the player because stripped during compiling?

klauskobald commented 8 months ago

Yes - the shader seems to be missing then - so let's leave it like that.