Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Assets Screen Space Displacement Mapping (No Tesselation) - Progress

Discussion in 'Works In Progress' started by winning11123, Jan 12, 2019.

  1. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @Ascensi, Great minds think alike, I was pondering this last week myself)))). The final mesh is present in world space with Unity's DrawProcedural, so I think it could be possible if procedural meshes are included in what I assume is a batch process to contribute to the scene. I think I would have to cull the extrusions (as like stencil shadow mesh projection in a way) but would be cool if could work.Thanks for the recommendation))...green is my favorite color so nVidia here i am lol)))), I think taking this technique to a lower level with the minds they have there could be really interesting.
     
    Ascensi likes this.
  2. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    567
    That's very hopeful to hear! Also very important - multi display/player support.. would having two different camera views simultaneously currently work? I realize you don't have support for VR yet but maybe that's part of writing support for additional cameras? I have a holographic display I'd like to run at the same time which might be very tricky.. currently it has one camera but oddly captures 45 different angles and sends it to the display so I'd be very interested to know if this will work for it.

    Lastly I installed it into a project set to Vulkan, would you have to add support for Vulkan in your compute shader? currently I get the error:
    Shader requires a compute buffer to be bound but none provided, skipping draw.
    Attempting to draw with missing bindings. I do realize that when selecting a shader you do have it listed under DirectX11

    Update: I tried the demo with the holographic display. At first all the floating spheres show as black and can't tell if they are tessellated but when I used CTAA the scene was lit better and it definitely made the scene easier to look at.. edges were sharp etc. Thought it might help give you some clues what to tweek. In this video example first I used CTAA for anti-aliasing and it added sharpness and better lighting the next video is with it off.
     
    Last edited: Feb 2, 2019
    winning11123 likes this.
  3. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @Ascensi, thanks for bringing up any issues you might have or features you might need so I can improve if possible as this is very helpful to me. Also very cool display)) I saw a youtube video on this and thought was really cool! You could try but as the screen mesh is pushed into the world from its cameras position and orientation, viewing from the sides may not be ideal as you would most likley see either extrusion or the cuttoff angle(no faces), in VR/AR this is difference because you only have two vantage points and one screen worth of pixels.

    At the moment a single screen worth of meshes is I think all my gtx970 could cope with and leave room for around 2 million more triangles for low poly meshes. With VR it should be ok because it is still just one screen worth of a mesh split into two. I still have to work more on this and will take up that challenge after the terrain and megatexture support is in. Also with VR I have to see how best to integrate with single pass if possible and multi-pass - it may be one or the other, I hoping for single pass.

    Although not intended for multi camera setup right now I just did a test (fps about 160 in editor - look solid in build 1920x1080), if wanting to experiment you could duplicate the SSDM Camera and make sure Camera depth is less than Main Camera (Depth -3 ) add another layer called SSDM2 and then set the meshes to that layer you want to show in that camera. change the script attached to the main camera to this....
    Code (CSharp):
    1. public class Main_Camera_SSDM_Draw : MonoBehaviour
    2. {
    3.     //******************************************************
    4.     //classes
    5.     public SSDM_Camera _SSDM;
    6.     public SSDM_Camera _SSDM_2;
    7.     //******************************************************
    8.     //declarations
    9.     //******************************************************
    10.     //START
    11.     //******************************************************
    12.     void Start ()
    13.     {
    14.         //--------------------------------------------------
    15.         //--------------------------------------------------
    16.     }
    17.     //******************************************************
    18.     //ON POST RENDER
    19.     //******************************************************
    20.     void OnPostRender()
    21.     {
    22.         //--------------------------------------------------
    23.         _SSDM._iOnRenderObject();
    24.         _SSDM_2._iOnRenderObject();
    25.         //--------------------------------------------------
    26.     }
    27. }
    and attached the duplicated SSDM Camera.

    however with that being said...the mesh is draw prom the perspective of the camera that renders it. and both would be in the same main camera as draw from each camera so you would either see extrusion or no back faces if camera are not at same position and orientation as it's main camera counterpart.

    I will have to have a look if anything special is needed for Vulkan. I did see an Unity Issue Tracker error report for compute shader to vulkan error so there may be a few that have not been fully compatible. However I will see if there is anything I can do, it may be simple thing. Also try 2018.3 if not updated yet, as I had to use that to get Sparse textures to work.

    I noticed that this darkness is I believe caused by difference in Linear of Gamma color scheme, switching between these should solve the darkness, however I am uncertain exactly why. When using AA, post process is best to use and hardware AA generates random speckle artifacts around the edges for some reason. I will look into this further, thanks for the video!

    I will keep this all in mind check it off the list as I progress when I can look into deeper, thanks again really helpful to see more potential usage cases! But right now for most standard uses it is a good solid base for the technique, but I will try and cover all bases as I can.
     
    Last edited: Feb 3, 2019
    Ascensi likes this.
  4. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    567
    @winning11123

    Thanks! I was using linear differed and switched to forward but forgot about switching Gamma also as I normally don't use it. About the Holographic display like your asset it only two cameras one disabled. I think overall it's best to wait until you have sorted out SPR/ VR then try to trouble shoot the display. I think like your asset with one cam set to -1 and the other set to -2 and two FOV cam settings I think the shader it uses takes all the angles between and creates the multi angled view - just a guess. Vulkan support would be amazing.. I'm running VR and the Holoplay device and need to dedicate a video card to each and need as much speed as possible (multi GPU & multi core cpu & gpu support)

    I'm glad you're able to test multi cam, I really appreciate it! I will probably try experimenting with two displays for now.
    Also you might want to add a Dynamic mesh disabling & or scene unloading with Occlusion Culling script but keep collisions active so the GPU has less objects to look for that way you can either handle more geometry within your camera view and more GPU power or have less geometry and even more power etc. Maybe you've already tried this.
     
    winning11123 likes this.
  5. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @Ascensi, no problem, it is all interesting to me. Yes, I think I will stick to my current work flow for now, with working on the terrain and mega textures as I believe that will be most useful to start with. After that I will tackle these extensions. The main thing is to keep all as easy to use for all and myself in moving forward with an aim of no work for non coders. As more interest grows it will become easier to expand the project I think. There are many things to experiment with for sure, and when I get further along with a full amazing demo to really show this off, I think it will reveal most helpful things to add in moving forward, especially with helpful feedback like you are providing.
     
  6. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    Hi everyone,

    Just letting you know version 1.0.0.5 is now available. I will upload a video tomorrow with overview and usage of new feature.

    In this release Sparse Texture (Mega Texture) Support has been added. It is very easy to use, so when you see video you will be able to get straight into use. It is really cool addition. 3 Sparse Textures are created (color,normal,PBR) and this gives you either the following (12x4096(6 mip levels), 48x2048(5 mip levels), 192x1024(4 mip levels), 768x512(3 mip levels), 3072x256 (2 mip levels)).

    Next Update will be that of a Mask and mesh painting with the mega textures and another shader for this purpose. The mask will give you access to all textures available on the mega texture and will control Texture Tile, Tilling and Displacement settings.

    I will leave the sale on for another week, so if interested in where this is going good time to get it!
     
    Ascensi and mfleurent like this.
  7. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    567
    @winning11123 with your new system will you be able to store painted data in its own splat file? One of the main reasons why I was hoping for Megasplat integration is that I have a massive project setup with Voxeland but Voxeland the way it's currently set up doesn't allow wetness or puddle/steams to be painted.. every time Voxeland gets refreshed it only keeps texture data/position but no flow maps. Procedural it would be good to have rules for specific textures to only show at a specific mesh Normal angle for overhangs but also the ability to paint maybe as a different layer. Lastly Voxeland has Megasplat support but not SSDM. I'm sure many Megasplat customers would love a boost to their frame rate :D but adding support for it automatically gets it working with Voxeland via Megasplat integration.

    About testing with Raytracing, there is a free version of Octane render for Unity on the asset store if you'd like to try it some time.

    Thanks for the latest update! looks good.
     
    winning11123 likes this.
  8. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @Ascensi, yes, the next step be painting the mesh with the mega texture as the color pallet. It will have a four channel mask to control which tile on the sparse texture is used, how many times it is tiled, and 2 displacement params. This means you can have paint a mesh with literally every tile on the mega texture no matter the count. and make your own brushes of course. The mask is saved and used with a new shader that uses that megatexture.

    I will take note about feature to allow for runtime changes of this mask (great idea!), but initially with it's first release it will be something done in editor to paint the mask runtime for things like terrain and structures where haveing access to many tiled textures would be a benefit.

    Currently any integration with other plugins would have to be done by authors. It is much simpler for them to add support than for me, maybe if more interest happens or they can see it's potential expanded integration could happen, but right now with the resources I have, I just have to make my own system, which gives more freedom for me anyway.

    This is cool, I have a raytracer I wrote in Unity running in the compute shader, but I will have a look when I can change gears at that version of Octane, thanks for the recommendation! my current one is good but needs more features as is rather simple.

    Thanks! I am still holding off on showing the RD-Textures because I think I will only have one chance to blow anyone away with this, so I want to make it look amazing like Christoph's scenes).
     
    Ascensi likes this.
  9. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    567
    Just checking in for an update on VR SRP and a preview with Christoph's textures.
    Any new developments?

    I didn't understand the Mega texture video at first but now I understand. I hope you can make a batch converter that will create all the texture tiles under the 4k, 2k, 1k folder etc. You would state the metal channel & normal map channel and the user should be able to add their own prefix like _metal, _NM or _metal_ _nm_ and your converter just assigns them. I have many texture libraries I'd like to convert and they would take days manually.

    I have some photo real models that I'd like to put on the asset store and make recommendations to use your asset for performance. Ideally these models would be intended for VR so I'm hoping you've found a solution for SRP and seeing angles.

    Because displacement is often used for more realistic graphics -AAA games, I'd definitely like to see ray tracing work since many of the engines are now trying to use realtime ray tracing as the preferred realistic lighting & rendering engine.
     
    Last edited: May 6, 2019
    winning11123 likes this.
  10. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @Ascensi, Sorry for late reply, been busy with the real world :p. Currently I have just build a terrain system based on these excellent tutorials -
    . And in the next couple of days will be merging it with SSDM and will be added as a package to product. so can be added if needed. After that will be the water plane ripples and displacement. Then another version of the terrain where it will have full access to all slots on the mega texture rather than in the current implementation, which will only have as many mega texture tiles as height slots used in terrain. So a demo with this showing off Christoph's legendary RD-Textures on a terrain environment will be this week too)).

    As for VR that will be after the above is completed. I would appreciate if you would like to test the VR when time comes before release because I only have DK2, so thanks in advance if possible).

    Actually that is a great idea for a batch converter, and actually probably a must have as the situation you describe, so will add that to the list too. Yes it was not easy to convey the mega texture details in the video, but I tried to just run through as simply as I could. Figuring out how to use them myself felt like some kind of voodoo but I finally understood)).

    As to raytracing, It should be possible but is going to take some time. There are some things that need to be considered as really it is like one giant surface mesh pushed from the screen into the 3d world, so for example ray-traced reflections for objects reflecting objects infront of them would be black, as the back faces would not exist and I think shadows would have issues too. not to say there are not ways it could be done. but needs a bit more deep thought. I would love realistic lighting myself, actually I have been chasing this for long time as I think there is many new atmospheres that could be created with it.

    anyway that is where i am with this. so there should be an update and demo sometime in the next few days).
     
    Ascensi likes this.
  11. Ascensi

    Ascensi

    Joined:
    Sep 7, 2013
    Posts:
    567
    No problem to test with VR using my Vives. Looking forward to the demo!
     
    winning11123 likes this.
  12. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Nice tech.
    I have following error. Do you have an idea to run it with Unity default or should i try to change AutoLight.cginc.

    Unity 2019.1.2f1
    SSDM_Basic.scene
    in
    \Unity\SSDM\SSDM\ScreenSpaceDisplacementMapping


    Error.JPG

    Code (CSharp):
    1. Shader error in 'DX11/UBER_SSDM': unable to unroll loop, loop does not appear to terminate in a timely manner (30 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number at /Unity2019_1_2f1/Editor/Data/CGIncludes/AutoLight.cginc(247) (on d3d11)
    2.  
    3. Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SCREEN LIGHTPROBE_SH
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    5.  
    I really interrested in the water demo of your project.
    Keep on computeshadering.
     
    winning11123 likes this.
  13. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @4sascha Thanks! looking into it now...
     
  14. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @4sascha,

    I just created a new project in 2019.1.2f1
    added layer called SSDM
    assets->Import Packacge->custom package (select ScreenSpaceDisplacementMapping.unitypackage)
    select basic scene and all is good

    I think the problem is first release of SSDM I also included the project built with an older version of Unity and those shaders did not include the [unroll()) semantic in parts of the shaders. So I believe if you import the SSDM as the included unity package all should be good. I will remove version 1 a later date, as all is included in 1.0.0.51 .unitypackage.

    thanks if you can confirm, but all looks good here. Thanks for bringing to my attention!

    Best Wishes and don't hesitate to ask if need more assistance.

    Edit: Unity 2019 may not update the script SSDM_Camera.cs (line 243) automatically, so change
    from Graphics.DrawProcedural(MeshTopology.Triangles, MaxBufferSize);
    to Graphics.DrawProceduralNow(MeshTopology.Triangles, MaxBufferSize);
    if Unity does not do this. Will be taken care of in next release.

    Edit: hopefully only be another week or two on the water (mainly due to time), just getting the infinite procedural terrain finalized, glad you are looking forward to it, thanks))
     
    Last edited: May 15, 2019
  15. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    2019-05-15 16_21_18_error.jpg
    i followed your post

    new Unity Project 2019.1.2f1
    created Layer SSDM
    import Package
    \SSDM_1_0_0_51\Package\ScreenSpaceDisplacementMapping.unitypackage

    line 243 is updatet to
    SSDM_Camera.cs
    Graphics.DrawProceduralNow(MeshTopology.Triangles, MaxBufferSize);

    results in same Shader Error

    Shader error in 'DX11/UBER_SSDM': unable to unroll loop, loop does not appear to terminate in a timely manner (30 iterations) or unrolled loop is too large, use the [unroll(n)] attribute to force an exact higher number at /Unity2019_1_2f1/Editor/Data/CGIncludes/AutoLight.cginc(247) (on d3d11)

    Compiling Fragment program with UNITY_PASS_FORWARDBASE DIRECTIONAL SHADOWS_SCREEN LIGHTPROBE_SH
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
     
    winning11123 likes this.
  16. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @4sascha, hmm well this is troublesome because the error does not appear on my system.

    -what happens when you double click on the error in the console. does it take you to the error location in code? ( I looked at the line in AutoLight but seems ok)
    - does this happen with the other SSDM_Basic_Sparse_Texture scene?
    - possible to press play at all or error prevents play?

    could you try change in the file ../Assets/SSDM/Renderer/Shaders/UBER_SSDM.shader (in my visual studio 2017 line 366)

    change

    [unroll]
    for (int j = 0;j < PL_ActiveLightCount;j++)
    {

    to

    [unroll(4)]
    for (int j = 0;j < PL_ActiveLightCount;j++)
    {

    then save and let Unity compile scripts.

    - On your system being a shader error and complaining about at unroll loop. I have a gtx 970 what video card do you have? maybe driver need update, I would assume card has shader model 5 support so probably not the issue. But strange that I do not receive this error.

    - I am using unity HUB and opening project with same version you use (but all is ok on my system). Is it possible for to open the project in an older version of Unity and see if same error happens.

    That is somethings to help me narrow it down a little, I will check back tomorrow and see if any of that helped or not, or if anything new comes to mind. seems very strange to me as it does not occur on my system, but we keep trying to find it as would be good to understand why this is happening on your system. talk soon.
     
    Last edited: May 15, 2019
  17. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    yes. Opens a wormhole to line 247 in SSDM_Camera.cs

    SSDM_Basic_Sparse_Texture has same error.
    It is possible to play the scene but there is no renderouput from camera.


    same error after changing line 366 to [unroll(4)]


    Error2.JPG



    I also tried same procedure in Unity 2018.3.12. Same error.
    I check another GPU tomorrow. I use an GTX 1080.
     

    Attached Files:

    Last edited: May 15, 2019
    winning11123 likes this.
  18. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @4sascha, hmm this i really cannot explain. does the demo works for you though?

    if you like i can refund your money, i think either something wrong with Unity Install (as one of the first 2018 versions of unity would erase compute shaders when upgraded projects to it, possible an issue there somewhere) or graphics driver error but a 1080 should have no problem.

    so just let me know if you want a refund, i just have no idea when, even error goes no where and i cannot replicate from a clean install. Thanks for brining to my attention but just not much i can do at this stage.
     
  19. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Think i must say sorry.
    I recreate project at home in Unity 2019.1.2f1 and there is only one error.
    No refund. I like this method and played with it 10 years ago. Happy that you brought it to Unity.
    There is lots of potential for a lot of strange use cases.

    Assets\SSDM\Renderer\Scripts\SSDM_Camera.cs(243,13): error CS0619: 'Graphics.DrawProcedural(MeshTopology, int, int)' is obsolete: 'Method DrawProcedural has been deprecated. Use Graphics.DrawProceduralNow instead. (UnityUpgradable) -> DrawProceduralNow(*)'

    so i replaced
    line 243
    in
    SSDM_Camera.cs

    Graphics.DrawProcedural(MeshTopology.Triangles, MaxBufferSize);
    with
    Graphics.DrawProceduralNow(MeshTopology.Triangles, MaxBufferSize);

    Everything is working now.

    At work we are behind an proxy and firewall so that newest Unity HUB is not working for now.
    No PackageManager and AssetStore.
    That seems to have an influence on recompiling API´s and makes difference in project generation or something like that.
     
    winning11123 likes this.
  20. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    @4sascha, that is great new that you got it working! That was my first instinct, so glad that it was just setup error, not obvious to either of us)), but had me worried because did not solve.

    Oh this is cool, actually I found a few videos on YouTube about the technique from about 10 years ago, any would be yours? After I build this I did a search and found I was not inventor, but cool to have same idea as others and done in a new way)) so thanks for the support!
     
  21. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    You might want turn volume down a little)) but just a video on the progress of the procedural terrain working with sparse textures and SSDM. Demo and package update should be up on Monday all goes as planned. Thanks again for those who have supported and last week at 75% off sale, so after that will be a 50% off sale until water is added and some additional terrain features. Have a great weekend!

     
    Flurgle likes this.
  22. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    Another video update. Lots of improvements for version 2 but still very simple to use. Actual release of package update and new Demo should only be a few more days. Thanks for patience and support!
     
  23. Flurgle

    Flurgle

    Joined:
    May 16, 2016
    Posts:
    356
    Looks awesome. Would be interesting too see that with Jason Booth's Stochastic height sampling
     
    winning11123 likes this.
  24. winning11123

    winning11123

    Joined:
    Apr 29, 2014
    Posts:
    55
    Thanks! Yes, that looks like really cool technique for removing tiling in a texture. will have to read more about it, but for now I'll just have to add more content)). great find thanks for mentioning!
     
    Flurgle likes this.