Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Procedural Stochastic Texturing prototype

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

  1. MasterPiece66

    MasterPiece66

    Joined:
    Mar 29, 2018
    Posts:
    3
    This work in the HDRP terrain ?
     
  2. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    can anyone please update this to the newest, (2020.3.20f1)? Cannot find another free way to do this.
     
    newguy123 likes this.
  3. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    MagiJedi, dannyr83, twobob and 2 others like this.
  4. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    I'm a bit clueless with this kind of thing @rz_0lento please could you give me a step by step on how to use this. I read the instructions from the github link in that article, but they're speaking complete gibberish to me.....

    I have an existing HDRP/Lit shader with textures in for albedo, normal map, height. What do I do with these get the stochastic from the link working and assigned into my HDRP/Lit shader?

    I can load a custom package from a single git line in paqckage manager. But this here is complete gobbledygoo to me: (not to mention what I do with it when it is installed)
    upload_2021-10-16_13-34-31.png

    I only have these options:
    upload_2021-10-16_13-55-35.png
     
    Last edited: Oct 16, 2021
    dannyr83 likes this.
  5. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Last edited: Oct 18, 2021
    twobob likes this.
  6. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
  7. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    This might be asking too much, but could you provide some instruction with using openUPM and adding this? All good if you can't. I will just spend another week fumbling through what should be a simple thing... Cheers.
     
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
  9. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    alright, thanks heaps mate. Ill work it out and let you know if it worked.
     
  10. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
  11. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    I also tried that:
    upload_2021-10-20_15-13-15.png

    But then I get this:
    upload_2021-10-20_15-13-31.png
     
  12. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    Ah apologies guys, I forgot a comma (,) after the dependancy.....

    upload_2021-10-20_15-20-14.png
     
  13. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    I really wish somebody can just make a Youtube vid of this. I'm reading the instructions, but its like reading gobbledygook!

    This doesnt mean anything to me:
    upload_2021-10-20_15-34-38.png

    This is so annoyingly frustrating!
     
  14. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    You need to have commandline git installed for the package manager's git support to work.
    As for instructions, they are step by step... I don't know what more one could expect :)
     
    twobob likes this.
  15. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    I got as far as that (done all steps in red). Stuck from blue onwards:
    upload_2021-10-20_15-54-8.png

    now connect the asset node. What Asset are they talking about???
    upload_2021-10-20_15-54-43.png

    ...and then next "connect uv as usual". There's a USUAL??? I've never doen this so please be more specific in the instructions and assume some of us has not used Unity for 50 years.
     
  16. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    In a way its good I got stuck as I just noticed that:
    upload_2021-10-20_16-5-22.png

    Seems then I'm stuck with the crappy "simple" version.

    More the reason Unity should get on with it and implement proper solutions natively in Shader Graph
     
  17. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278
    Ah I give up!
    If it's not one thing, then its a"bloody"nother!

    upload_2021-10-20_16-15-37.png
     
    dannyr83 likes this.
  18. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    One of the things about using that editor is the lack of tangible error handling. Personally, this was one of my fave texture things ever.
     
  19. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    I am having the exact same problem...sigh...
     
  20. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    Thanks for all your help man, but it doesn't work. shader error undeclared identifier same as new guy above. any ideas how to fix?
     
    newguy123 likes this.
  21. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    It's probably some SG change on recent Unity version, haven't tried it myself there.
     
  22. dannyr83

    dannyr83

    Joined:
    Jul 14, 2021
    Posts:
    10
    @newguy123 I am jumping ship to Unreal they don't have this problem(and many others), had enough of all the technical problems, and obsolete tutorials.. Just want to make a game...
     
    Last edited: Oct 23, 2021
  23. supaworst

    supaworst

    Joined:
    Mar 26, 2012
    Posts:
    45
    @rz_0lento Hi! First of all thanks to have updated and supported this amazing (dead) project.

    I'm trying the package i've pulled from your git with unity 2021.2/URP and, at the beginning, it seemed to work fine despite of some shader errors in the console. I don't know why but, after reeboting unity, the shader broke totally adding the classic pink error color on my meshes.

    Do you have any clue about that? Do you have any plans to update it to 2021.2?

    Thanks in advance for your reply and best regards!
     
  24. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Unity guys, why did you let this thing die?
     
    twobob and newguy123 like this.
  25. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,443
    You could always use Microsplat Texture Clusters. It works on all pipelines. A 1-click solution and I'm quite happy with it. Been creating a new scene this weekend. Here's with only 1 terrain texture.

    Stochastic Texture Clusters Off:

    Stochastic_Texture_Clusters_Off.jpg

    Stochastic Texture Clusters On:

    Stochastic_Texture_Clusters_On.jpg
     
    Last edited: Mar 8, 2022
  26. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    269
    Off-topic, but that's a very beautiful scene. Is that a publicly available water asset?
     
  27. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,443
    Crest Ocean HDRP. Also available for URP and free for Built-In.
     
    cxode likes this.
  28. twobob

    twobob

    Joined:
    Jun 28, 2014
    Posts:
    2,058
    As I understand it the argument would be twofold. Performance and the new pipelines.

    I used this to death. I feel the same but it is what it is.
     
  29. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,278

    What if I dont have actual terrain, but my terrain is a large mesh? (or even small mesh). Is that still a 1-click solution @Rowlan ?
     
    kspeeder likes this.
  30. Junior_Djjr

    Junior_Djjr

    Joined:
    Nov 3, 2017
    Posts:
    11
    Omg, it pains me to see so many people having trouble getting this to work.

    I implemented this into my games, so you can get it here:

    Unity Procedural Stochastic Texturing Node for Shader Graph

    Unity Procedural Stochastic Texture Terrain Shader

    It's the simple version, without the color correction, because the full one is very difficult to implement, and I saw above that there is a problem with the "Linear" color space. The simple version is also more performant.

    I implemented this also in GTA San Andreas, many people with weak PC ran it and no one complained about performance issues, it really is a great solution for texture tiling.

    btw, I'm not a shader guy, so don't ask me to do crazy things on top of it.
     
    Babajan, PolyCrusher, vlery and 4 others like this.
  31. mikelortega

    mikelortega

    Joined:
    Feb 5, 2014
    Posts:
    47
    Thank you @Junior_Djjr. Could you please show a Shader Graph capture using your Custom Function? I'd like to know how to configure Inputs and Outputs, cause I cannot make it work in Unity 2022.1.4f1. Thanks!
     
    FernandoMK likes this.
  32. MichaelEGA

    MichaelEGA

    Joined:
    Oct 11, 2019
    Posts:
    43
    I know this is a bit old, but it comes up in the google search for stochastic texturing and I thought people might appreciate an answer to the above question.

    I got @Junior_Djjr stochastic node working in Unity 2022.2.1f1 by doing the following.

    1. Open up the hlsl file "StochasticNode.hlsl" in visual studio (or whatever you use for editing scripts)
    2. Edit the line that says:

    void Stochastic_float(TEXTURE2D_PARAM(tex, samplerTex), float4 UV, out float3 Out)

    and change it to this:

    void Stochastic_float(UnityTexture2D tex, UnitySamplerState samplerTex, float4 UV, out float3 Out)

    save and close.

    (Don't ask me why these values have to change... I just followed the hint in this thread).

    3. Open up shader graph, make a custom node, add the "StochasticNode.hlsl" to the Source input
    4. Set up the inputs as follows

    Precision Inherit (If you're using the node in a subshader this should be 'Single' not 'Inherit)
    Preview Inherit

    Inputs
    tex Texture2D
    samplerTex SampleState
    UV Vector4

    Outputs
    Out Vector3

    Type
    File
    Name Stochastic
    Source StochasticNode​

    The node should be functional and not show an error..

    I implemented this here.

     
    Last edited: Jan 31, 2023
  33. stigmamax

    stigmamax

    Joined:
    Jun 30, 2014
    Posts:
    322
    Comment utiliser StandardStochastic sur Unity LWRP ?
     
  34. jjejj87

    jjejj87

    Joined:
    Feb 2, 2013
    Posts:
    1,117
    Can't this be added to the Shader Graph as an official node? I mean, it seems very useful so far. And it works.
     
    newguy123 likes this.
  35. MichaelEGA

    MichaelEGA

    Joined:
    Oct 11, 2019
    Posts:
    43
    La solution ci-dessus est pour URP (LWRP). Essayez la dernière version. :)
     
  36. ValsodarX

    ValsodarX

    Joined:
    Dec 14, 2020
    Posts:
    2

    Hi, I'm completely new to the shader graph, I did everything you mentioned here. The errors are gone however the node just outputs a solid color (I connected a texture). That's probably though because I don't know how to implement it. I would use your terrain shader however I'm working with spherical planets so that's not an option.

    Can you please go more into detail with shader graph implementation and how to connect everything so it gets the desired output?
     
  37. MichaelEGA

    MichaelEGA

    Joined:
    Oct 11, 2019
    Posts:
    43
    Not sure. What you said should work. Are you inputting UVs or not. If not you can try to input the world position or similar.

    Also, something like this may be what you're looking for: https://forum.unity.com/threads/simple-stochastic-planet-shader-free-on-github.1413297/ It's a planet shader I made that uses the stochastic shader.
     
    Last edited: Sep 1, 2023
  38. ValsodarX

    ValsodarX

    Joined:
    Dec 14, 2020
    Posts:
    2
    I've seen your planet shader and while it's great, I'm currently trying to texture the planet upclose, so the ground looks interesting when you land. Anyways, I've got the stochastic shader to work, I just deleted it and did everything again, so I must have made a mistake the first time. Interestingly, when I disconnect the UVs I get the same dubious result from before so that must have been the issue, as you said. Thank you so much anyway!
     
    MichaelEGA likes this.
  39. Spikebor

    Spikebor

    Joined:
    May 30, 2019
    Posts:
    288
    please add this back to Shader Graph for newer version.
     
    newguy123, Thygrrr and Ruchir like this.