Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Released] SSF Particle2Fluid Shader Util

Discussion in 'Assets and Asset Store' started by dongfangliu, Feb 24, 2020.

  1. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Yes, this plugin currently does not support VR but you can try to make it suitable for VR.
    This is the problem of two eyes using different camera settings.

    TO MAKE THINGS CORRECT, you have to modify the plugin to render with 2 cameras since currently the workflow is done only for one camera.

    Theoretically, the work can be done as follows:

    1. Render additional textures ( as you can see in the inspector panel) with the right eye camera matrix
    2. Additional shading with right eye matrix
     
  2. Zxander

    Zxander

    Joined:
    Aug 12, 2013
    Posts:
    4
    Hello, I am trying to open this project in HDRP (not URP). I've run across some errors in the console, specifically "The call is ambiguous between the following methods or properties: 'Material.SetBuffer(string, ComputeBuffer)' and 'Material.SetBuffer(string, GraphicsBuffer)'. I spoke with the developer and he recommended using "SetBuffer("xxx",(ComputeBuffer)null);" instead. I replaced each instance in SSF_TextureGenerator.cs and this cleared the errors from the console.

    Next, I noticed that the shaders are Standard (lots of Pink) so anything generic was swapped over to an HDRP version. FluidSurface is amplify standard legacy shader so I converted it to a HDRPLit shader.

    This led to an error in the shader in 'FluidSurface': undeclared identifier 'UNITY_MATRIX_T_MV' at line 650 (on d3d11). Lines 650,1277,1826,2322,2831, and 3360.

    Debugging this I noticed that the Local Vertex Normal was causing the error. I changed TransformDirection to ObjectToWorld. This cleared that shader error but I still have errors for "Trying to add _GrabTexture (type 3 count 1)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr, Boolean&)".

    I'm now at the step with the grab pass issues but I cant figure out how to fix this issue on HDRP.

    I read on the forum (Mar 25, 2020) that "But if you could execute all those OnRenderObject functions of this plugin in each frame such as RenderPipeline.BeginFrameRendering ,then it should also work."

    Could you explain this a bit better. I feel like I might be close to a solution for HDRP but I lack the engineering knowledge to complete this task.

    thanks,

    -zander
     

    Attached Files:

  3. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Is it necessary to convert all shaders into HDRP? Im not sure, some people may have experience on this. Currently im very busy to have time to deeply check HDRP problem.

    You can see many OnRenderObject Functions in the plugin scripts, and you should try to execute them under the BeginFrameRendering stage of your renderpipeline. Because the OnRenderObject functions try to generate textures for shader on each frame
     
  4. Zxander

    Zxander

    Joined:
    Aug 12, 2013
    Posts:
    4
    OK, I will try and see what I can do. I am not an engineer but will poke around. If I have success I will let the forum know.
     
  5. Zxander

    Zxander

    Joined:
    Aug 12, 2013
    Posts:
    4
    Update on this... I got rid of the console errors by replacing
    OnRenderObject() with OnBeginFrameRendering

    For example
    void OnBeginFrameRendering(ScriptableRenderContext context, Camera[] cameras)
    {
    if (particleSource != null)
    {
    particleSource.updateParticleBuffer();
    setupBuffers();
    setParams();
    check_debugVisualize();
    drawColorTexture();
    drawDepthTexture();
    drawThicknessTexture();
    smoothDepthTexture();
    drawNoiseTexture();
    drawNormalViewDirTexture();
    }
    }

    Even though there's no errors anymore, the camera (and scene) do not display correctly. I'm getting results in scene view but it doesn't look right yet. This is closer. Maybe I shouldn't have replaced all of these with SetBuffer("xxx", (ComputeBuffer)null);?


    void releaseBuffers()
    {
    material_depthColorThickness.SetBuffer("xxx", (ComputeBuffer)null);
    material_depthColorThickness.SetBuffer("xxx", (ComputeBuffer)null);
    material_noise.SetBuffer("xxx", (ComputeBuffer)null);
    material_noise.SetBuffer("xxx", (ComputeBuffer)null);
    }

    Btw, I now that its not your job as a developer to ensure that your products work on all SRPs. I'm just trying to see what I can do. The good news is that this is much closer and is now doing something in HDRP.
     

    Attached Files:

  6. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    You can try to assign textures to the texture generator and upload the images snapshot of the texture.

    Currently,from your result, i think it may due to the render surface shader problem
     
  7. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    or the pipeline frame updating order issue, im not sure...
    and you should use a higher division mesh, do you know what i mean, if the mesh to represent the fluid surface is very low resolution, it will have some sigular triangle visual apperance
     
  8. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Hi, please just cast the buffer to ComputeBuffer, like
    (ComputeBuffer)null

    Code (CSharp):
    1. void releaseBuffers()
    2. {
    3. material_depthColorThickness.SetBuffer("xxx", (ComputeBuffer)null);
    4. material_depthColorThickness.SetBuffer("xxx", (ComputeBuffer)null);
    5. material_noise.SetBuffer("xxx", (ComputeBuffer)null);
    6. material_noise.SetBuffer("xxx", (ComputeBuffer)null);
    7. }
     
  9. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Hello all, I am releasing a new version! Though it only tested on windows cause I only have a windows laptop.

    What changes:
    0. Ensure support of Builtin Pipeline of Unity 2019 LTS and 2020
    1. Add support for URP (Unity 2020.2.6f1c1) and guidance to HDRP(Unity 2020.2.6f1c1).
    2. fix those previous errors in this thread

    You can have a taste and just get the new version.

    Best wishes.

    I will be busy in the following year and the next update is not on the plan.

    If anybody succeeds to make it work under URP and HDRP, please do not hesitate to share your successful experience in this thread.
     
  10. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Hello, please check the new version, which might help.
     
  11. dongfangliu

    dongfangliu

    Joined:
    Mar 6, 2017
    Posts:
    41
    Anybody interesting in make cartoon fluid rendering, may easily get those effect just through shadergraph editing.
    The reference link from zhihu is here:https://zhuanlan.zhihu.com/p/165653176.
    All properties mentioned have been prepared in this asset.
     
  12. Lsy1112

    Lsy1112

    Joined:
    May 17, 2021
    Posts:
    1
    Hello, could you please tell me why this plug-incan only display in certain angles? As soon as I rotate or zoom in to a certain point, the fluid disappears
     
    ml785 likes this.
  13. alexisdavidson

    alexisdavidson

    Joined:
    Apr 28, 2015
    Posts:
    29