Search Unity

  1. Unity 2020 LTS & Unity 2021.1 have been released.
    Dismiss Notice

Procedural Stochastic Texturing prototype

Discussion in 'Graphics Experimental Previews' started by thomasdeliot, Feb 12, 2019.

  1. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    5.8.0+ got Custom Function Nodes
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    This is the little type your HLSL into the box thing? That's not going to cut it..
     
  3. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    You can include whole shader file and call individual function from it.
     
  4. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    Yes, but I rewrite the function based on settings, much like I do in MegaSplat and MicroSplat; not something you can easily do in this new node. In this particular case I can just include all combinatorics of the function, but that obviously greatly limits my possibilities. As an example, MicroSplat has the equivalent of around 350 shader_features, which just isn’t possible with Unity’s system. Being able to custom generate code at editor time is very powerful.
     
  5. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    397
    They removed the old system for custom nodes, but added a new system for custom nodes. you need SRP 5.8+ for the new system.
     
  6. sybere

    sybere

    Joined:
    Mar 26, 2015
    Posts:
    181
    Any way to change pre generated texture in runtime?

    Sample:
    Just albedo change:
    MaterialGameObject.GetComponent<Renderer>().material.SetTexture("_MainTex", WinterGrass);

    MaterialGameObject.GetComponent<Renderer>().material.SetTexture("What is the correct keyword?", WinterGrass_T);

    so what is the correct keyword?
     
  7. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    Stochastic Height Sampling for the Unity Shader Graph is now live in the asset store. (Note that this is not the same as the Unity technique, but rather uses a different blend operator so it doesn't require texture conversion, lookup tables, etc- and personally I find the quality to be superior as the height blend operator tends to wash out the source textures a lot less).
     
    Last edited: Mar 27, 2019
    transat, hopeful and ceebeee like this.
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    Is there any ETA for this?
     
  9. Kombiice

    Kombiice

    Joined:
    Jan 20, 2015
    Posts:
    64
    Hey!

    Are there any news?
     
  10. thomasdeliot

    thomasdeliot

    Unity Technologies

    Joined:
    Feb 12, 2019
    Posts:
    14
    Yes, the process is a bit long, but still working on a release within ShaderGraph ! Will update here once it happens.
     
  11. Kombiice

    Kombiice

    Joined:
    Jan 20, 2015
    Posts:
    64
    Thanks for the answer, that's really exciting! I almost lost hope and thought there might have been problems / the project might have been abandoned ;)!
     
  12. SERVGS

    SERVGS

    Joined:
    Jun 16, 2017
    Posts:
    3
    Hi all!
    Actually everyone could implement this in Shadergraph with CustomFunction node.
    Thanks for good references provided by Thomas Deliot in original shader code in first post (and method explanations in pdf of course).
    It works with Unity 2019.1/HDRP5.13/ShaderGraph5.13 for me. I have some problems with DXT scalers (not working/using RGB-half for now and it has color space inaccuracy as could be seen) and have to manually tape of Color space origins which I'm taken from Pre-compute shader in other standard project.
    Anyway, if Thomas will share with us with original ShaderGraph implementation it would be really excellent!

    Thanks!
     

    Attached Files:

  13. thomasdeliot

    thomasdeliot

    Unity Technologies

    Joined:
    Feb 12, 2019
    Posts:
    14
    Glad to know the code references are useful enough, thanks for sharing your implementation!

    In the meantime I'm releasing the ShaderGraph implementation as a prototype here as well. This isn't ideal since it requires a custom ShaderGraph package and a few setup steps for Unity to see it. It requires Unity 2019.2+ and a project using LWRP or HDRP 6.7.1 precisely. I've detailed setup instructions on the github readme, if something isn't clear report back to me here and I'll help/edit it.

    I initially thought I could just upload the few code files required and instruct users to add them into their ShaderGraph package, but Unity's package manager doesn't allow that, so this is the only solution for now. I can't backport it to previous ShaderGraph versions as it requires a serialization bugfix from 6.7.1, though I will be able to update it for future versions. Hoping to get this integrated into the official ShaderGraph package soon.

    Otherwise, this is a much more useful release than the previous Standard shader variant, as it makes the technique compatible with the new render pipelines and easily usable in custom shaders. We're very interested in seeing how Unity users can benefit from this technique so don't hesitate to provide feedback and show your results here!

    GitHub link:
    https://github.com/UnityLabs/procedural-stochastic-texturing

     
    Reanimate_L and rz_0lento like this.
  14. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
  15. thomasdeliot

    thomasdeliot

    Unity Technologies

    Joined:
    Feb 12, 2019
    Posts:
    14
    Ah indeed, I had messed up the commit. Thanks, fixed it
     
  16. SERVGS

    SERVGS

    Joined:
    Jun 16, 2017
    Posts:
    3
    Great work!
    I'm in to test it)
    Tasty, especially with Unity's TextureArray functionality and dirt/rust mask (AO/Curvature+noise) for big variance for grunge materials with respect to performance low drop-down.

    As I understand it right, that when ~2019.3 is come out this is feature we could have as standard option of Shadergraph package?
    Do you know this article - https://aleksk01010101.wordpress.com ? Very interesting. Currently don't know how to implement cause it still unthreaded and poor info for me unfortunately.
     

    Attached Files:

    Last edited: May 29, 2019
  17. SERVGS

    SERVGS

    Joined:
    Jun 16, 2017
    Posts:
    3
    IMHO:Well, this is great with triplanar (especially non-classic, 3 textures 3axis - see attach) materials. Nonetheless, I don't fill that it's really nice idea with creating Procedure Texture 2D (PT2D), cause it drawing your own way for developing. I mean, you can't do anything with PT2D in shadergragraph, like you can do with simple texture right now (and further). I'm realized that this is temporary, but simplistically I'm not sure that it is rational design. If any misunderstandings I'm free to discuss it in private.
     

    Attached Files:

  18. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,566
    Any plans to make this work with Triplanar projection out of the box or will we need to roll our own?

    Also, am I right in thinking you have to hard wire the input texture into each shader graph, there's no way at the moment to pass it as a parameter to the resulting material?
     
  19. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,458
    @thomasdeliot what happened with the shadergraph integration, is it still happening?
     
  20. Umaru_J

    Umaru_J

    Joined:
    Dec 29, 2015
    Posts:
    1
    I tried to make a build in Unity 2019.1.12 and its say it needs to compile up to 37 million shader variants on the Standard Stochastic shader. It has been building for about fours days now, and it's only progress of the 8 million shader variant. Based on this pace it will take about 17 days to complete.
     
    Cascho01 and ceebeee like this.
  21. KBanakakis

    KBanakakis

    Joined:
    Sep 14, 2018
    Posts:
    1
    @thomasdeliot This is an excellent shader but are there any plans on updating for URP? Or any plans to make it compatible with 2019.3 soon?
     
  22. cadpeople

    cadpeople

    Joined:
    Nov 6, 2014
    Posts:
    21
    Bump, what happend to this amazing project?
     
  23. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,219
    cadpeople likes this.
  24. UBayir

    UBayir

    Joined:
    Feb 4, 2015
    Posts:
    3
    As far as I understand it only works with LWRP 6.7.1
    I couldn't manage it to work with the URP or later versions of LWRP
    If you don't have LWRP 6.7.1 already installed Unity does not allow you to install that specific version from the package manager, even on Unity 2019.2 the earliest version you can install for LWRP is 6.9.0 and this doesn't work with that version.
    So far the whole thing does not work right now
    How can we make it work pls?
     
    sas67uss likes this.
  25. sas67uss

    sas67uss

    Joined:
    Feb 8, 2020
    Posts:
    56
    Exactly :(:confused:
    when i import this project there are 12 errors like this " does not contain a definition for 'TimeParameters' " or "does not contain a definition for 'concretePrecision' "

    Library\PackageCache\com.unity.render-pipelines.lightweight@6.9.2\Editor\ShaderGraph\LightWeightSpriteUnlitSubShader.cs(179,97): error CS0117: 'ShaderGeneratorNames' does not contain a definition for 'TimeParameters'

    Library\PackageCache\com.unity.render-pipelines.lightweight@6.9.2\Editor\ShaderGraph\LightWeightSpriteUnlitSubShader.cs(264,102): error CS1061: 'GraphData' does not contain a definition for 'concretePrecision' and no accessible extension method 'concretePrecision' accepting a first argument of type 'GraphData' could be found (are you missing a using directive or an assembly reference?)
     
  26. Imperatoss

    Imperatoss

    Joined:
    Mar 24, 2018
    Posts:
    45
    I would also like a compatible version with HDRP 7.3.1
     
  27. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    I've ported this to 6.9.1, 7.4.1, 8.1.0 and bleeding edge 10.x here:
    https://github.com/0lento/Graphics/tree/stochastic-texturing-6.9.1
    https://github.com/0lento/Graphics/tree/stochastic-texturing-7.4.1
    https://github.com/0lento/Graphics/tree/stochastic-texturing-8.1.0
    https://github.com/0lento/Graphics/tree/stochastic-texturing-10.x (based on hdrp/staging, requires 2020.2.0a17+)

    Do note that you need to use Git LFS to clone the graphics repo properly. After that you only need the ShaderGraph package from these branches, for rest you can just use the regular package manager packages.

    Worth noting that I haven't changed the original workflow at all - which I think could have a lot of improvements. For example you still need a custom asset for each texture and this custom asset isn't supported as SG's input property type, which practically makes it impossible to make reusable shaders with this approach. What I have provided here is simply a port of the original design and made it work on newer SRPs.
     
    Last edited: Jul 9, 2020
    gigazelle, cxode, TieSKey and 2 others like this.
  28. Cerealex

    Cerealex

    Joined:
    Jun 29, 2020
    Posts:
    6
    Hi! Is there any way to make this work on 2019.3 and HDRP 7.3.1?

    Thanks!
     
  29. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    Can't you use 7.4.1 version I linked in a post above? It should be all around better version than 7.3.1.

    That being said, if you really need to have it on 7.3.1 and you know how to use git, just checkout 7.3.1 branch from Graphics repo and cherry-pick my 2 commits from the 7.4.1 branch linked above and it should work.
     
  30. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    608
    Anybody know if Unity is still working on this, or it has been abandoned?
    Is there any alternative to this plugin?
     
  31. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    If you need stochastic texturing specifically, @jbooth sells ASE node that does this: https://assetstore.unity.com/packag...ampling-node-for-amplify-shader-editor-143715 + microsplat addon that does this as well: https://assetstore.unity.com/packages/tools/terrain/microsplat-texture-clusters-104223

    As for breaking texture tiling, there are countless techniques available which you could implement yourself using SG even. Stochastic texturing does seem to have quite superior results in comparison to most of these techniques. But what works the best does depend on your materials ultimately.
     
  32. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    608
    Could you link to some examples please (with tutorials if possible)
    Been googling this for a week, without success....
     
  33. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
  34. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    Hey @thomasdeliot , do you have a status update on stochastic texturing? Is it still planned to come to mainline shader graph at some point? Has it been abandoned?
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    This is one of the reasons I don't like the original approach and prefer my variation on it, which uses a height blend operator of either height data or luminosity data, instead of a histogram preserving one. This gets rid of the need for any texture modifications, LUTs, or preprocessing, and just works with your existing texturing data, makes it texture compression agnostic, and IMO looks better for organic surfaces as well.
     
    cxode likes this.
  36. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    @jbooth I really love your stochastic texturing in Microsplat, it looks amazing and is stunningly easy to set up. However I'd like to use it on non-terrain objects as well. Would you consider making a Shader Graph node for it? I know you've got an ASE node, but my whole project uses Shader Graph and I'm not keen to buy and install ASE just for this one feature. Idk how difficult it is to port ASE to shader graph.
     
    gigazelle likes this.
  37. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    I did, but then Unity made the API private and broke everyone's nodes. For a while I was hacking the assemblies to keep my stuff working, but it wasn't worth the effort when Unity is being down right adversarial about letting people extend their tools, so now I only support ASE.

    ASE is much better though, so you won't regret switching.
     
    hippocoder, hopeful and cxode like this.
  38. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    Well, I took the HLSL from Microsplat and stuck it in a shader graph node lol






    As someone who knows very little about shaders I'm proud of myself for getting this to work :D

    I would very much like to share this, but obviously I can't as the code was written by Mr Booth and is restricted by the asset store license. @jbooth would you be willing to work out something that would allow distribution of the shader graph node? I don't care about personally making money from it or anything, so if you want to just sell it on the asset store I'll send you the files. Or maybe you could include it with the MicroSplat clusters asset.

    Edit: although ideally I'd like to just put it up on github for free. I expect you aren't on board with that, but if you are then let me know!

    Edit 2: If you do want to discuss this please email hijimmyitsmejasonfromtheunityforums@jimmycushnie.com
     
    Last edited: Dec 7, 2020
    ftejada likes this.
  39. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    This would be an incomplete solution, as you need to apply the same texture choices across multiple texture samplings- ie: normals, diffuse, etc. Otherwise they won't line up correctly between the different PBR inputs. My nodes provided an set of outputs for this so they could be chained together. Additionally my node allowed you to choose which channel contained the height map data, or use the luminosity as the height map. This could all be re-built in the shader graph like you've done now, but since your not able to write real nodes anymore, you can't expose options that affect the code-gen, and thus this, done properly, balloons out into 21 different nodes for all the combinations of options. As such, I chose not to go that route.

    Well the thing about selling anything on the asset store is that if the thing you sell generates lots of support requests, it quickly becomes not worth doing. That's why I removed my version in the first place- because after Unity closed the API, every Unity version the API would get changed with no docs or notice, and very quickly the time it took to figure out those changes and update things would eclipse the income the node would generate. So yeah, I'm not particularly keen on supporting Unity's shader graph here, the team chose to lock asset developers out of their solution after many of us already shipped products for it, and that doesn't really build a lot of good will.
     
    ftejada, hopeful and cxode like this.
  40. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    Fair enough. Thank you for the detailed response.

    Could you elaborate on this? What's wrong with doing the following?



    Personally I don't care much about this feature, I can only ever see myself using the alpha channel for heightmaps. I'm happy to live without it.

    Also just for the record I agree that Unity has been very sucky about this, and I hope they drastically change their attitudes/practices
     
  41. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    Ok so when I actually put that shader on an object it looked all F***ed up. I did some research and I think the reason for the F***iness is that the PBR master node normal input expects a value in tangent space, but normal textures are typically encoded in object space.

    I made a second stochastic sampling node that's essentially identical but it calls the
    UnpackNormal
    shader macro and it all seems to work properly now.

     
  42. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    The blending of the normal maps will be based on the alpha channel of the normal map, not the height map encoded into the alpha map of the diffuse map, so essentially they won't match.
     
  43. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    Can't I just encode the height map into both the normal and diffuse map? Or is that what you meant by "apply the same texture choices"?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,768
    I mean you could, but that will reduce the quality of your normal map, and you'll be computing the most expensive part of the technique multiple times instead of once.
     
    cxode likes this.
  45. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    200
    That makes sense.

    Thank you for taking the time to help me learn about these things. I really appreciate it!
     
  46. Davilarek

    Davilarek

    Joined:
    Nov 16, 2019
    Posts:
    5
    hey, can you please tell me how to install it? I really want this Procedural Stochastic Texture plugin. I have unity 2019.4.15f1 and LWRP
     
  47. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,998
    First you have to clone that git repo with some git tool that supports Git LFS, then either copy the shader graph package of the directory with the clone into your projects Packages folder or add file/folder reference to it via PM / by editing the manifest directly. Just using the full folder copy is easier so I mentioned it first.

    You also need matching SRP package installed on your project, in this case URP 7.4.1 as I never updated this for 7.5.1 (it's a simple to merge my changes to any 7.x version if you know how to use git though).
     
  48. stuksgens

    stuksgens

    Joined:
    Feb 21, 2017
    Posts:
    130
    This is one of the nodes that has a lot of potential, I don't believe that unity abandoned the project.

    I really wanted to have it native to the shader graph:(
     
    newguy123 and Cascho01 like this.
  49. Ruchir

    Ruchir

    Joined:
    May 26, 2015
    Posts:
    330
    Just wanted to ask, why is this not included in the shader graph?
     
  50. stuksgens

    stuksgens

    Joined:
    Feb 21, 2017
    Posts:
    130
unityunity