Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Bert0

    Bert0

    Joined:
    Dec 17, 2012
    Posts:
    1
    Hello,

    First of all thank you for this great tool, especially for people who come from UDK on building materials.
    Now I'm trying to do some tests with the material on this picture:
    http://imgur.com/ReU4mCK
    What I want to do is move the central area of ​​the ball where i put the emissive, getting slowly turn and I´ll try to use the Rotator. In UDK have the possibility to put parameters on the axis, x or y, but in shader forge i don´t know how to do that. If anyone can help me a little I'd appreciate it,
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The rotator is used specifically for rotating UV coordinates, which you can do in this case too. But it really depends on what you mean by rotate.
    I think you want to use the panner in this case, and it will pan around the center (depending on how you've UV-mapped it)

    Edit: Actually, none of them will work in this case, because of how your texture looks. You'll need a mask + a panning texture masked by it.
     
    Last edited: Apr 16, 2014
  3. Deleted User

    Deleted User

    Guest

    The 4 textures are blended and masked by a splat map texture. I would like to use triplanar blending to prevent the textures from stretching on steep mesh. I've looked at the Triplanar Mapping article on the SF wiki, but I'm wondering if there's a more optimal way to do triplanar blending for so many textures rather than making 3 Texture2D nodes for each of the 4 textures and then mapping each of those to the world axis projections.
     
  4. King Phoenix W.

    King Phoenix W.

    Joined:
    Feb 4, 2014
    Posts:
    6
    Hi, is it possible to create this shader with Shader Forge? Cheers

     
  5. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,151
    ...What does it do?
     
  6. King Phoenix W.

    King Phoenix W.

    Joined:
    Feb 4, 2014
    Posts:
    6
    Reflecting Light with a Normal Map on a Plane/Sprite to create the illusion, that the Sprite has a Shadow/Light Side.
     
  7. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
  8. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The two materials you are lerping between has to have matching property names and types - usually you'll want to do it using the same shader on both materials.
     
  9. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Also, two new nodes coming in Beta 0.33 :)
    (Note that they aren't static / multi-compile switches, they are still properties. Static switches may come later!)

     
  10. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    not sure if i have understand because i use 2 same shader only texture change at this time but switches look interesing
     
  11. anadin

    anadin

    Joined:
    Oct 28, 2005
    Posts:
    98
    Very cool Ace, very cool :) I've been using IF's for this
     
  12. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    lol.. took me 20 minutes to find this (ugh, the search in post threads here is terrible)... wish you had tool tips for them :)
     
  13. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    does anyone know what the options are for related to the CubeMap? (e.g: Positve Z, Negative Z, Positive X, Negative X....)

    I've tried changing them and comparing diffs in the shader code, and not really seeing anything at all...
     
  14. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's only for the node previews, so it has nothing to do with the actual shader :)
     
  15. Deleted User

    Deleted User

    Guest

  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Sure! There's no sphere mask node in SF at the moment, but this should work the same way:



    It might be a bit unstable on some platforms. It works here in OpenGL, but I'm not sure about other platforms. It relies on division by zero to have a predictable result, which may break things, so be sure to try it before you release it ;)
     
  17. Deleted User

    Deleted User

    Guest

    Ah, very cool! Thanks for showing how to do it. :)
     
  18. reptilebeats

    reptilebeats

    Joined:
    Apr 28, 2012
    Posts:
    272
    $000097.png

    hi can someone let me know what these mean
     
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Scroll up 6 posts :)
     
  20. reptilebeats

    reptilebeats

    Joined:
    Apr 28, 2012
    Posts:
    272
    ha funny, these forums tend to get so full i tend not to read through them much. wish i did lol.
     
  21. Milric

    Milric

    Joined:
    Jan 14, 2014
    Posts:
    1
    Is there a working sample SF shader with lightmap support? I have tried to create several using the Texture 2D Node for the lightmap texture directed to the Emission input. In turn, the UV input on the Texture 2D node is receiving input from a UV Coordinates node with a UV setting of UV 1. The scene looks fine using a Unity built in Diffuse shader. But with my very simple shader, it looks quite wrong and a number of ways. The object is extremely bright and the UV mapping seems off.

    Obviously, I am doing something wrong. I was hoping to find a sample showing how to do it properly.
     
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Lightmaps are silly, because you have to follow a ton of ridiculous naming conventions to get things right.

    First off - Check Lightmap support in the lighting settings of your shader.

    - Name your diffuse texture "MainTex"
    - Name your normal map texture "BumpMap" (If applicable)
    - Multiply your diffuse texture by a Color node named "Color"

    If you want to support emission maps etc, there are even more things you need to match, even where the shader path is. I think it would have to be under Emissive / or something.

    This should get you started!
     
  23. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    I wish Unity would soften up those hardcoded naming conventions required for their type of Beast lightmapping integration. Beast should try to evaluate the shader as much as possible by emulating what a GPU is doing. Of course there are some kind of limits and restrictions that would make it necessary to drop some of the stuff we see in shaders on a regular basis (like multi pass shading, view dependent shading, screen space shading...) ... but there really shouldn't be silly requirements like a MainTex to read the albedo from. What's with multi-texture blending via vertex colors? Gone.
    The lightmapping system should become more generic and flexible.
     
  24. Homer-Johnston

    Homer-Johnston

    Joined:
    Nov 26, 2012
    Posts:
    46
    If it's not much effort, when using the Double Sided culling option it would be nice to have an option whether or not to automatically reverse the backface normals. Great tool!

    (This line is added automatically when Double Sided is set - would love if this was optional)
    float nSign = sign( dot( viewDirection, i.normalDir ) ); // Reverse normal if this is a backface
     
  25. SeveredScion

    SeveredScion

    Joined:
    Oct 16, 2012
    Posts:
    45
    tswalk,
    I don't have ShaderForge (yet), but if I understand your question, you're just asking the function of positive and negative x, y, and z in regards to a cubemap. A cubemap is essentially a fake 3D environment to be used as a reflection on objects that are reflective. The fake 3D environment is a cube made up of six maps that each represent one side of the cube. The orientation for the faces in Unity is:
    -x left face of the cube
    +x right face
    +y top
    -y bottom
    +z front (facing the camera/viewer)
    -z back (facing away from the camera/viewer)

    There are different techniques and software for creating a cubemap. Read the CubeMap page on the Polycount wiki thoroughly for a great explanation. They explain it better than I do :) Also check all the links and software at the bottom of the page
    http://wiki.polycount.com/CubeMap

    I hope this helps. If I misunderstood what you were asking, then please accept my preemptive apology :p
     
    Last edited: Apr 22, 2014
  26. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    First of all: Shader Forge is amazing. :)
    Second: I'm having some issues with vector properties. I want to colourize and oversaturate some penumbras using a vector3. It works perfectly fine, but as soon I replace the vector3 with a vector4 property (so I can modify the color at runtime), everything's going to extreme white. Could it be that somehow internally the vector4 gets converted to a color4 or something and it can't handle the values > 1.0f?

    http://notenoughsleep.eu/files/oversaturated penumbras wrong.png
     

    Attached Files:

    Last edited: Apr 22, 2014
  27. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I would guess the material you have in your scene, simply doesn't have the values set yet.
     
  28. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    Unfortunately, the values in the material are set. Maybe this is part of a bigger problem, the lighting seems to flicker from time to time and shadows behave quite strangely. Thanks anyway for the help!
     
  29. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Are you plugging lighting nodes where they shouldn't be?
    Try setting your shader to a single light instead of multiple ones, and see if the flicker goes away
     
  30. copenhagenjazz

    copenhagenjazz

    Joined:
    Oct 2, 2005
    Posts:
    45
    Hi

    Has there been any fixes to the problems regarding Unitys camera AO and shaders using alpha clip? It seems like this has been bugged before; http://shaderforge.userecho.com/topic/387915-alpha-clip-problem-in-beta-022/

    The builtin alpha cutoff shaders works fine with the AO so there has to be some way of making Shader Forge shaders compatible too.

    Switching to Ambient Obscurance is not an option for me :)

    Thanks in advance
     
  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not yet, it's a very messy issue.

    Essentially, the problem is that Unity renders depth for post effects by replacing all shaders in the scene, with one that writes depth.

    SF will try to find a suitable alpha clipping replacement shader, but in many custom clipping methods, it just can't. So it's replaced by another alpha clip shader, that doesn't match the shader you made in SF, and thus, the depth information sent to the post effect, doesn't match the shader that you see.

    It's the same issue for any shader that alters the geometry, which includes alpha clipping, vertex offsetting and displacement.

    There are ways of solving this, but it's not straightforward. I asked Aras about this, because I had no idea what was causing it myself at first, here's his guide on how to temporarily fix it:

     
  32. copenhagenjazz

    copenhagenjazz

    Joined:
    Oct 2, 2005
    Posts:
    45
    Ok thanks for the reply. I guess its just another one of those "funky" unity solutions :p

    For now I will then stick to the standard Unity cutout shaders as I am not comfortable with messing around shader code.

    Thanks again
     
  33. Bluntie

    Bluntie

    Joined:
    Jun 11, 2013
    Posts:
    10
    Hey guys and newbie alert! I'm experimenting with triplanar shading (different textures, depending on the angle of the polys), but I need some help.

    As you can see in the preview, the triplanar-ness of it is actually working - there's snow on the top and bottom of it, and grass on the sides. The transition between the snow and grass is too wide and smooth though - I would like to basically "sharpen" the mask, so the transition could be tighter, perhaps even use an actual masking-texture for it.

    However, I am completely stumped as to how I could do it, despite faffing about for what feels like hours trying to fix it. Anyone have any snazzy insights I am missing? Comments on the rest of the shader are welcome as well, I welcome any and all optimizations.

    $vp6wRKF.jpg
     
  34. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi Joachim,

    I have a little problem with a toon shader im working: Im multiplying a Fresnel node with the Light Color node, but it gets only the light color information from the directional light. Im doing something worng? If i turn off the Directional light, the rim light disapears.
     
  35. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I presume you're plugging it into emission - emission is only done once, and it reads the first directional light.
    If you want to have it read all light sources, you'll have to do custom lighting, and plug in in there instead.
     
  36. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    ohhh, that was the solution!! i dont know why i didnt tried it already xDD

    Thanks, im still a noob with shaders, but this is the result thanks to SF!!!! ( im working on a better ramp texture for now ):
    $ToonShading1 2014-04-22 20-26-57-15.jpg
     
  37. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Asked this a little bit ago but did not notice a response. Very busy thread.

    I am finishing up a leaf shader and it looks great. I want to have a slider that lowers the strength of the shadows on the leaves. Like tree creator leaves. I used ambient lighting but the leaves look lit up at night. I tried different ways that "work" but also strengthen the diffuse of the non-shadowed leaves. Just want to lower the shadow strength. Thanks
     
  38. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    That looks pretty nifty. I like those strokes :)
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The shadows from other objects, that is cast onto the leaves, or the geometrical shadowing, where it goes darker when it's facing away from lightsources?
    If it's the latter, you can use light wrapping and transmission to control it.
     
  40. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    The first. Shadows from all the objects.
     
  41. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Quick question while I remember. Is there a way to have IBL with the cubemap for all the materials editable through a script. Like with Lux there is a script in the hierarchy that you input the cubemap. So all the materials that have the shader use the cubemap in that script. Just so you do not have to put the cubemap in each material. Sorry for my confusing:confused: questions. Thanks
     
  42. bcoyle

    bcoyle

    Joined:
    May 22, 2013
    Posts:
    57
    +1, I'm also curious about how to best utilize cubemaps

    Also wanted to share my first shader that hasn't crashed on me yet - a basic material with controls for reflection, fresnel, normals
    $SF_basic_material_002.jpg
     
  43. anadin

    anadin

    Joined:
    Oct 28, 2005
    Posts:
    98
    I wanted to do this too but I can't see a way to do it for Cubemaps. For other textures and some parameters you can make them global (right click the node) so the way to do a Texture2D is have a Texture Asset (Make it Global) and plug it into the Tex slot of the Texture2D node.

    New in Shader Forge Beta 0.26:
    • You can now use global variables!
    - Currently supported types: Value, Vector4, Color and Texture
    - Right click on a property and select "Make global"
    - Global variables can only be set from code. For example: Shader.SetGlobalFloat("_MyGlobalValue", 5.0f)
    - Currently, there's no way of making the nodes display their current global value


    Ace?
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    See my tutorial on height lerping: http://acegikmo.com/shaderforge/wiki/index.php?title=Advanced_Texture_Splatting

    That is the usual technique for getting decent results between several real-world materials, as well as giving you a contrast settings to play with.
     
  45. Deleted User

    Deleted User

    Guest

    Any ideas as to why this directional light is showing through my custom terrain mesh when at sharp angles? The problem seems to be related to specularity, but I don't really know what the issue is...

    https://i.imgur.com/edLMHnv.png
     
    Last edited by a moderator: Apr 23, 2014
  46. Bluntie

    Bluntie

    Joined:
    Jun 11, 2013
    Posts:
    10
  47. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's because I'm working on other things, primarily.
    The reason there's no way of doing it for cubemaps is because I have no Cubemap Asset node. So I would need to first make the Cubemap node accept a cubemap asset, then add a cubemap asset data type, then add a cubemap asset node, and then make it so you can turn it global.

    Are you using custom lighting or one of the built-in ones?
     
  48. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Thank you movra! Here is another screenshot with a more toony model ( again, not modeled by me):
    $ToonShading1 2014-04-23 11-32-55-77.jpg

    Shader Forge is amazing for people like me! I dont know why unity dont have a node shader editor by defult.

    P.D: Im having some problems with Shader Forge window. There will be some fix so that the Shader Forge window does not close every time you open unity?
     
    Gekigengar likes this.
  49. Deleted User

    Deleted User

    Guest

    I'm using the built in Blinn-Phong lighting. Do I need to use a custom light?
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I see, then the weird lighting issue is my fault. I'll look into it for 0.33 :)