Search Unity

Shader Forge - A visual, node-based shader editor

Discussion in 'Assets and Asset Store' started by Acegikmo, Jan 11, 2014.

  1. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Hi Acegikmo !
    I know you have tons of work, but I would really appreciate if you could have a look with my problem concerning double sided transparent shader :)
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Which one?
     
  3. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    This one :)

     
  4. piacentini

    piacentini

    Joined:
    May 27, 2014
    Posts:
    28
    New to ShaderForge, got it today, and currently running through the tutorials. I am trying to port/improve a shader that is misbehaving. It was previously created in Strumpy, for the abandoned PlanetTerrain asset.
    It basically let's you specify 4 textures, and decides which one is displayed based on the height of the mesh (it is a terrain-type mesh). I was thinking about making it able to work on custom/modeled meshes as well, taking a distance from a center/reference point. So suppose you have a planet-like model: if the distance between the vertex data and the origin (0,0,0) is smaller than 6, use texture 1 (bottom of ocean). If it is between 6 and 6.5, use texture2, and so on. Later I can expand it to optionally blend between textures as well.
    I have a version hand-coded using shader language, modified from this post. But I would like to recreate it in ShaderForge, to learn the tool and also expand it a little bit (and to be easily shareable).
    Being new to the tool, do you have any pointers/examples I can use to start building something like this? Maybe a simple example that switches textures based on mesh height or something like that? Thanks in advance.
     
  5. WHKS

    WHKS

    Joined:
    Dec 13, 2011
    Posts:
    61
    why cant i download 1.12 i keep telling it to update an all i get is 1.06
     
  6. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    I have this particle sorting issue as you can see in the picture I attached :

    the trail fx (green) is a mesh particle with a shader I created in Shaderforge. the blend mode on the shader is Addtive. But when another particle intersects with the trail fx, the overlapped area is not transparent as I expected. particle_sort_fighting.jpg shader.jpg
     
  7. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You need to run Unity 5 to download the latest version. 1.06 was the last Unity 4 version :)

    Not sure if we're looking at the same thing - but that's simply how additive blending works. The pixel colors are limited to the 0 to 1 range (Unless you're using HDR+tonemapping), which means if you have a white color, (1,1,1), and add a cyan color (1,1,1) + (0,1,1) = (1,2,2), but this is then clamped, making it (1,1,1) again.
     
  8. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    I interpreted it as that the dark areas should let the lighter particles through, there should be no black around the cyan.
     
  9. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    the trail mesh cut the burst fx in half and half. they are both addive blend mode. what I wanted is the bust fx in front of the trail fx (on the top)
     
  10. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Oh, that's because you're writing to the Z-buffer, for some reason. Check auto-sort at the bottom of both shaders :)

    Additive is exactly what it says, it's just RGB addition :)

    It's order-independent, which is to say:
    1+2 gives the same result as 2+1
     
  11. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    I set the Sort fudge value of the burst fx to -1000, but the two are still not sorted right.
     
  12. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    yes. I did checked writing to the Z-buffer.
     
  13. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    sure. I will give it a try. thanks!
     
  14. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Which is the problem. Uncheck Z-buffer write. Check auto-sort
     
    shaoyongzhang likes this.
  15. Kajfa

    Kajfa

    Joined:
    May 14, 2014
    Posts:
    3
    Hi

    I'm trying to create a shader using shader forge to mimic the standard shader in unity 5. But I have a problem with the alpha aspect of it.

    In the standard shader you can set the "rendering mode" of an object to be "fade" or "transparent". If it's set to fade I get the same result as my shader forge shader. But I need it to be set to transparent to keep it reflectivity.

    What do I need to do in shader forge for an transparent object to retain it's reflectivity?

    upload_2015-3-31_11-21-40.png
     
  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    This is something I'll look into in the future. If you're using non-PBR, you can multiply the specular value by 1/alpha, but I don't think this trick will work in PBR, and it also doesn't work when doing 100% transparent materials
     
    Zeblote likes this.
  17. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Acegikmo, is there any chance you could implement the option to disable shadows from blocking transmission? Especially since self-shadows block it from the light they should be transmitting light in the first place. I can get the raw attenuation by code but I have to rewrite it every time I chance the shader on Shaderforge.
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Could you show me an example of what you mean?
     
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I think this was caused by the fact that your shader is still being lit, and sometimes the face-side check fails, thinking it's actually facing the other way, giving you shadow on one side, and light on the other.

    However, this can be solved if you also connect color to transmission, which will actually cause another bug, which is now fixed for the coming 1.13 version :)
     
  20. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I can't seem to be able to replicate this. I'm getting consistent results
     
  21. shaoyongzhang

    shaoyongzhang

    Joined:
    Mar 31, 2015
    Posts:
    13
    it works! Thank you so much Acegikmo.
     
    Acegikmo likes this.
  22. FPires

    FPires

    Joined:
    Jan 5, 2012
    Posts:
    151
    Sure. This is the shader I'm working on. The left image has shadows off, while the right image has shadows on, for the Point light emitter at the hand.

    transmission.jpg
     
    shaoyongzhang and Acegikmo like this.
  23. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    I will record a short video tomorrow and show you the steps I take and the results I get and perhaps someone can see if I made a mistake or something. :)
     
  24. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Just sent this to someone who needed assistance in making a dissolve shader, so, if you need it, here's a very basic example :)

     
    FreakForFreedom likes this.
  25. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    As I get more comfortable at using Shader Forge I am planning to put together a sort of collection of videos on how to make shaders, their uses, examples and the shader image layouts for people to use. Is there anywhere that currently exists where there are lots of user created shaders using Shader Forge? Like a repository? xD
     
  26. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Last edited: Apr 1, 2015
  27. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Hey @Acegikmo, this might be crazy but… how about saving the shader/graph in the graph image (using steganography)?
     
  28. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Could work! Although it would be killed by compression, which is rather risky, plus the format would be binary more or less, which SF currently doesn't have
     
  29. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    So it turns out that because my objects had receive shadows on I had those weird results. Is there any way of having the same results as your tutorial video but with shadow receive on?

    Uploading a video with me showing the issue I am having. :)

     
    Last edited: Apr 1, 2015
  30. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Thanks for the video!

    So the behaviour you get is actually expected. You mentioned by the end of the video that you wanted a gradient based on the direction of the light - you need more than just atten*color in that case :) You need the NdotL term as well.
    Try using normal lighting, and plug a value of 1 into light wrapping, and a value of 0.5 or so into transmission.
     
  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge 1.13 is now out!
    • You can now switch transparency mode between Fade and Reflective. Reflective keeps reflections intact, even when fully transparent
    • Added premultiplied alpha blending to the blend mode presets
    • The blend mode preset will now show the name of your blend mode, in case you manually set Src and Dst to one of the presets
    • Fixed a bug where global texture nodes reverted to regular properties on load
    • Fixed a bug where shaders sometimes didn't compile when using diffuse and transmission
    • Fixed a bug where shaders sometimes didn't compile when switching to deferred after using Opacity in forward

    Fadereflective.jpg
     
  32. Yamo

    Yamo

    Joined:
    Nov 18, 2012
    Posts:
    18
    Is there a simple way to generate a random number? Looking to get a random int between two values.
     
  33. Deleted User

    Deleted User

    Guest

    At the moment the only way is via scripting, with Random.Range(Min, Max) attached to material.SetInt/SetFloat istruction
     
  34. Yamo

    Yamo

    Joined:
    Nov 18, 2012
    Posts:
    18
    Ah, thanks :D
     
  35. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    True, but I meant just for the original PNG file. Like ln your wiki, you can always click through to the original graph file from the preview jpeg. I thought of it because of this (old) post: http://www.gamasutra.com/blogs/Russ...raphy_for_sharing_playergenerated_content.php

    Anyway, just a fun idea.
     
  36. Deleted User

    Deleted User

    Guest

    @Acegikmo

    Great update, everything working fine...but i have found a little problem on normal during load compiling (luckily)

    P.S = Sorry for repost...

     
  37. rattlesnake

    rattlesnake

    Joined:
    Jul 18, 2013
    Posts:
    138
    Thank you very much !
    It's working correctly with the 1.13 version :)
     
    Acegikmo likes this.
  38. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    Really appreciate this! You are soo good with your asset users / fans / customers / friends / peoples / hello! :D
     
    Acegikmo likes this.
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Glad things work out :D
     
  40. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
    Last edited: Apr 3, 2015
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The image doesn't seem to work in the post, but I see it in this quote, for some reason.

    Anyhow, you should look into refraction and having a texture to define where and how to refract. There are multiple steps involved in this
     
  42. ryan chen

    ryan chen

    Joined:
    Jan 21, 2015
    Posts:
    7
    thank you
    the image here:http://huaban.com/pins/352686942/
     
  43. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Hi, I've come to ask for some help from the Shader Wizards here. I'd like to make something similar or just the same as this soap bubble that you can see in the video below (is 1:30 if it doesn´t play at that time):



    It's from the game The Book of Unwritten Tales 2, hopefully there are some developers here.

    Thanks.
     
  44. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Enable PBR, plug in 0 into alpha, 0 into metalness, and 0 into diffuse, enable reflection probes, and set the transparency mode to reflective, and make sure your seen has reflection probes
     
    Ga2Z likes this.
  45. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    It was a while ago, but did anyone find a solution to @HenriqueGomez question about foam on contact with colliders? I would love to have a water shader with this to use on edges, rocks and the character when they enter the water.
     
  46. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Thanks @Acegikmo I suppose I could multiply or do some operations on the reflection to make it look like oily foam, fresnel it and apply some UV rotation or so. But which node allows me to get the reflection probes information?

    Check the page 65 for @DeadNinja ocean shader: http://forum.unity3d.com/threads/shader-forge-a-visual-node-based-shader-editor.222049/page-65

    Oh, and it is made with a concept named Depth Biased Alpha (you can look at an UDK material) it has some workarounds for Unity but I couldn't explain you appropriately.

     
    Last edited: Apr 4, 2015
  47. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    @Ga2Z There is no "Subsurface" lighting option, nor is there a "Depth Fade" node in Shader Forge, are you sure this method is upplicable to ShaderForge?
     
  48. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    What I did was, multiply the foam Texture2D with a inverted Depth Blend node.
    Just connect a texture and a depth blend node.
    Then, add a one minus node to the Depth Blend and multiply the texture by it.
     
    Ga2Z likes this.
  49. Ga2Z

    Ga2Z

    Joined:
    Feb 16, 2012
    Posts:
    68
    Yes, that's what I meant by a work around in Unity that I couldn't explain because I haven't done it but here @HenriqueGomez tell us his method. And about that, Henrique habla español? hahaha
     
  50. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,421
    This sounds like an interesting way to do this, I am still yet to create anything more advanced than a snowfall shader.
    Would someone be able to provide me with an example or screenshot of the node setup?