Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. hobstob

    hobstob

    Joined:
    Dec 18, 2013
    Posts:
    20
    Hello trying to create a layered texture so I followed the configuration from the shader forge website and I get some errors. I need this to work desperately...
    $ShaderForgeShaderNetwork.PNG $ShaderForgeShaderError.PNG
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,242
    You have nodes using the same name, most likely. Rename your nodes to something more approproate
     
  3. hobstob

    hobstob

    Joined:
    Dec 18, 2013
    Posts:
    20
    Sorry the error images is not showing leme post it here

    $ShaderForgeShaderError.PNG
     
  4. hobstob

    hobstob

    Joined:
    Dec 18, 2013
    Posts:
    20
    That fixed it, thank you, Naming things goes along way.
     
  5. Project-Mysh

    Project-Mysh

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

    In terms of performance, what node will be better for use as diffuse color: vertexColors or low res 2D Texture?. Also if I need only 1 color or 2 colors, would be better vertexColors or 2 Color nodes with a Lerp node?
     
  6. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,242
    Vertex colors would be fastest in both cases
     
  7. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Thanks for your fast response ^^.
     
  8. topsekret

    topsekret

    Joined:
    Apr 18, 2013
    Posts:
    69
    My company recently purchased SF, and we are very pleased with it so far!

    Since we are focused on mobile, we use lightmaps and light probes for all of our lighting. As such, we have set the "Light mode" for our SF shaders to "Unlit/Custom". However, we haven't found a way to make any of the shaders work with lightmaps using SF nodes.

    I have looked at the code, and it seems like SF is doing 90% of the work to support light maps (it gave us a shader with "unity_Lightmap" and "unity_LightmapST" declared, it gave us UV coordinates, it transformed the UV coordinates in the vertex shader, and it read from the lightmap in the pixel shader). However, there doesn't seem to be a node that artists can use to actually do anything with the value read from the lightmap.

    As a programmer, I can go in and add the lines we need in the pixel shader right before the return:
    #ifndef LIGHTMAP_OFF
    finalColor *= DecodeLightmap(lmtex);
    #endif

    Unfortunately, if the artists need to change the shader, when they load it into SF, it stomps over the changes I made to support lightmaps. Ideally, there would be a node that lets you read from the lightmap, that way I wouldn't have to tweak the code each time an artist needs to make a change.

    Is there any way to do this in the current version of SF? If not, are there any plans to support a lightmap node in the future?

    Thanks!
     
  9. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,242
    There are no lightmap nor light probe nodes for custom lighting. Right now, it's only a feature for when using the other lighting modes.
    However, it is a planned feature, and should come in the next update. It will take a while though, I'm restructuring the entire shader compiler system in order to support all of this.
     
  10. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    979
    I'm still stumbling around SF. I would like to create a shader similar to this. Where a transparent object would be seen through other geometry and glow. Can someone point me to a node screenshot or tutorial? Thank you.
     

    Attached Files:

  11. aegget_

    aegget_

    Joined:
    Oct 30, 2012
    Posts:
    33
    Hi, I was just wondering if shader forge has something like UDKs object radius node. I looked through the node list and wiki but couldn't find any info on that. I also googled, trying to find the cg code for something like that but no luck there either. Does anyone know of a cg code tutorial or care to share a snippet that I can plug in to the code node? Would help a lot thanks!
     
  12. spyrka

    spyrka

    Joined:
    May 28, 2014
    Posts:
    1
    Hi everyone. I need your help :)

    I'm creating a shader for football jersey and I have a problem. As you see below, there are some clearances - that part of arm shouldn't be visible:

    $przeswit.JPG

    The model is imported from MakeHuman with 'Hide faces under clothes' option and it looks good with built-in shaders.

    Here is my shader:

    $shader.jpg

    As you see, the idea is to join two transparent textures and then add a number on the jersey. I'm a novice in this so I'll be grateful of any advice regarding that entire shader.

    I hope it is clear to you, my language skills aren't perfect :) Thanks for help in advance!
     
    Last edited: May 30, 2014
  13. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    So I've managed to make the start of a screen-based reflection shader using the Scene Color node, I've sort of managed to get the panning of the 'scene' texture so the reflection reacts to the direction of the camera and it would pass as acceptable in most of the use cases I have for it, but there is an issue where it doesn't work on any surface that's not facing upward. I'd like to be able to use this as a glass shader on buildings.

    I am aware of the limitations and the accompanying artifacts which I have plans on how to cover up, But I'd like to get the shader working in it's current state before i pretty it up

    I somehow need to translate UV's or something and ANY clues would be a really big help as I am pretty clueless from here on out and don't really know where to start.

     
  14. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,163
    It doesn't have one, but there's an entry on the feedback page you can upvote to give it some attention here: http://shaderforge.userecho.com/topic/424158-object-radius-node/
     
  15. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    repost because this was last post in last page so will probably get missed...

    So I've managed to make the start of a screen-based reflection shader using the Scene Color node, I've sort of managed to get the panning of the 'scene' texture so the reflection reacts to the direction of the camera and it would pass as acceptable in most of the use cases I have for it, but there is an issue where it doesn't work on any surface that's not facing upward. I'd like to be able to use this as a glass shader on buildings.

    I am aware of the limitations and the accompanying artifacts which I have plans on how to cover up, But I'd like to get the shader working in it's current state before i pretty it up

    I somehow need to translate UV's or something and ANY clues would be a really big help as I am pretty clueless from here on out and don't really know where to start.

     
  16. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,163
    Could you give a rough visual mockup of what you're trying to do? I remember working on something similar in UDK I might be able to translate over.
     
  17. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    Yes, I am using the screen image (Scene Color) to 'fake' a reflection, this means that I can use this shader on things such as glass, cars and other shiny objects to approximate reflections, it is better than just a cubemap but not as good as proper (camera) based real time reflections. The area that appears 'stretched' at the bottom of the image is a side effect/shortfall of the effect I am using and this will be covered later by either a cubemap of the sky, or for interior reflections the reflections would 'fade off' at that point. This effect will not be perfect but it could be a better implementation than I am currently doing.



    I have the effect somewhat working but it could be working better and the effect only currently works on flat surfaces facing directly upward, I need the reflections to 'face' the right way according to the surface normals
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,242
    This is usually achieved using multi-pass shaders, which SF doesn't support at the moment. You'll have to use custom built-shaders for that, or multiple Shader Forge shaders on the same mesh, where the glow is rendered on top.

    unity_Scale.w would contain your uniform object scale, if it works.
    Also:
    http://shaderforge.userecho.com/topic/424158-object-radius-node/


    Use Alpha Clip instead of Alpha, and make sure your shader blending is set to Off rather than Alpha Blended
     
  19. danieleve

    danieleve

    Joined:
    Sep 4, 2012
    Posts:
    9
    Hello all!!

    I have a problem with my shader in deferred lighting mode (a very simple shader with just some nodes for speculars and so on):

    When I check "Lightmap support" I get many errors from my nodes, and obviously the shader become totally pink.

    If I disable it all goes well, but I need Lightmaps...

    What can I do?

    Thank-you so much for your support!
     
  20. AndreasAustPMX

    AndreasAustPMX

    Joined:
    Mar 2, 2014
    Posts:
    8
    Hey guys,
    I would like to control a panner speed via vertex color, is that possible?

    something like this:

    $panner.JPG
     
  21. Project-Mysh

    Project-Mysh

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

    Why do you want to do per material SSR shader? In terms of performance its way better to do SSR as postprocess.
     
  22. anton1987ru

    anton1987ru

    Joined:
    Nov 16, 2012
    Posts:
    15
    $EbfiIkunB1c.jpg
    Chaoss , i modify your shader and finai result is this :grin:
     
  23. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Aha, and can you post how u did that so chaoss and the rest of the comunity can learn from your progress on SSR.
     
  24. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,242
    This is a silly bug in the latest version, this bug should go away in the next
     
  25. anadin

    anadin

    Joined:
    Oct 28, 2005
    Posts:
    97
    So, wouldn't mind some info if anyone can help

    This shader is bouncing around on the net in a few places and in a few Asset Store assets - its normally used for rocks and things..

    Code (csharp):
    1.    
    2. void surf (Input IN, inout SurfaceOutput o) {
    3.         float4 tex = tex2D(_MainTex, IN.uv_MainTex);
    4.         float4 tex2 = tex2D(_MainTex2, IN.uv_MainTex2);
    5.         float4 dest;
    6.         _Opacity*=tex.a;
    7.         dest.rgb = tex2.rgb<=0.5 ? 2*tex.rgb*tex2.rgb : 1-2*(1-tex.rgb)*(1-tex2.rgb);
    8.         dest.rgb = lerp(tex2.rgb, dest.rgb, _Opacity);
    9.         dest.rgb *= _Color.rgb;
    10.         o.Albedo = dest.rgb;
    11.         o.Alpha = tex2.a * _Color.a;
    12.  
    I am assuming the line that reads "dest.rgb = tex2.rgb<=0.5 ? 2*tex.rgb*tex2.rgb : 1-2*(1-tex.rgb)*(1-tex2.rgb);" is basically doing something like an IF statement. I had a read of a HLSL primer and it seems its a special way of doing it based on the threshold "<=0.5". Is this quicker than an IF? I dropped it into ShaderForge as a code node and it works fine but I would love to know exactly what it is doing and see if I could do it all in nodes.

    I was even playing around to see it matched one of the blend nodes but it doesn't seem to.
     
  26. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    8,583
    Wow :), that means it can do effects like those in Candela SSR ?
     
  27. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,388
    This is an if statement; the ternary operator is just a faster way to write it. IE:

    int val = 0;
    if (something == true)
    val = 1;
    else
    val = 2;

    can be expressed as:

    val = (something == true) ? 1 : 2;
     
  28. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    How did you do this, can you post the shader?
     
  29. Leanimal

    Leanimal

    Joined:
    Sep 1, 2013
    Posts:
    28
    Awesome, I'd love to see that shader too with the lions.
     
  30. anadin

    anadin

    Joined:
    Oct 28, 2005
    Posts:
    97
    Thanks jbooth for the confirmation, it was how I read it but its nice to know for sure before I start adding IF's to my shaders, I have a pathological fear of them - totally worried that an IF is not a good idea on a GPU :)
     
  31. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    There has to be a way to get my reflection shader working I have searched google, asked 2 seasoned programmers and Acegikmo but not even they know how to do it. I've now spent an entire 7 solid days on this and gotten nowhere
     
  32. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Hi, can i make something like sphere mask such as UDK node? Need some ideas.
     
  33. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    4,388

    You should generally avoid branches on the GPU. The behavior of a branch is highly variable depending on shader model, hardware, and use case, and some of those have absolutely horrible performance. You can often avoid branches by masking things with math rather than branching; and often that will look better because you can give it an area of interpolation. For instance, rather than writing something like:

    if (color > 0.5)
    result += color;

    you can do something like:

    result += color * pow(color, 10);

    which basically slams the value towards 0 or 1, with a small interpolation area between around the midpoint.

    If your going to branch in the pixel shader, you'll usually fall into one of several results:

    1. The compiler will compute both sides of the branch and choose one; so no work is saved by doing the branch.
    2. The hardware supports branch prediction (newer hardware), so if your branch tends to go entirely the same way for every pixel, it won't be that bad for performance. However, if it goes a different way for each pixel, it will hurt performance more.
    3. if your branch result has lots of dependent use, other operations may have to wait on the branch to be resolved.

    All that said, sometimes you just need to branch and it's worth the cost - as always, I wouldn't worry that much about a branch or two in a shader until you profile it and see that it's a problem. But it's nice to get in the habit of working without them when you can.
     
  34. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    Hi guys, How I can randomize a RGB color using Noise random?
     
    Last edited: Jun 3, 2014
  35. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Is there still a way to get this 20% off or is 80$ including 20% off?
     
  36. Jebus

    Jebus

    Joined:
    Sep 17, 2011
    Posts:
    18
    Regarding this post

    The original image had a second texture that was blended in using the objects highest point (no matter its rotation), and the transition from old to new was created by the influence of the normal map.

    It's probably clearer for me to ask advice by breaking it into it's 2 stages.

    1. Create a blend that started from the top and transitioned to the bottom of the object.
    2. Adjust the blend so instead of a harsh line transition, it was influenced by the normal map (which I think is what you were suggesting by masking out the G channel).

    I'll keep working on this myself, but if anyone has any ideas I'd love to hear them.
     
    Last edited: Jun 5, 2014
  37. ExperimentalGame

    ExperimentalGame

    Joined:
    Sep 18, 2013
    Posts:
    10
  38. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    155
    Is half-lambert lighting doable in deferred rendering? It was easy in forward rendering, but the "Light Wrapping" node is exclusive for it, unfortunately.
     
  39. Jebus

    Jebus

    Joined:
    Sep 17, 2011
    Posts:
    18
    Getting so close!

    In action it still looks as though it fades in rather than a building up effect that transitions from top to bottom (Like a build up of snow).
     

    Attached Files:

  40. adamz

    adamz

    Joined:
    Jul 18, 2007
    Posts:
    1,029
    Were you able to integrate Edge Length Tessellation yet?
     
  41. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Sorry to ask, but is anyone here the actual developer of this product? I am thinking of buying it but I want to know that I'll have support after the purchase :)
     
  42. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,163
    Acegikmo is the developer and he was seen here on the last page. It's a very well supported asset.
     
  43. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    155
    I concur what Murgilod said. The support (as well as the asset) is amazing!
     
  44. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Ok, fair enough. I am going to buy this today then. It looks amazing.

    Have any of you guys that have experience with it done any volumetric fog with it? Or is it not good for that?

    (Still gonna buy :D )
     
  45. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
  46. Waffleslug

    Waffleslug

    Joined:
    Jan 3, 2013
    Posts:
    12
    I have a few requests:

    Is it possible to add a Cubemap Asset like the Texture asset? The main thing that I want to be able to do is read from different mip levels of the same cubemap, Right now I have to include the same cubemap twice - I'm not sure if this is sending the same texture to the GPU twice or if it's smart enough to realize it's the same asset?

    This would also mean a Cubemap node for the code window to match the Tex node?

    Can we turn off all the lights in the preview window? This would be helpful when tuning image based lighting and emission maps.

    And finally would it be possible to edit the displayed names separate from the internal names? Some shaders/other assets expect certain names for the texture fields which might not exactly match what you actually use the texture for in your shader. So if I could name the texture _MainTex, but set the displayed name to Albedo + Gloss, that would solve that. It's not a huge deal though, since I can describe things in the shader with the comments.
     
  47. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    7,163
    I've got some more weirdness going on in 4.5 with Shader Forge. Nothing critical, now that I've got two installs, but some weird things going on.



    This pointless and arbitrary shader doesn't seem to be reporting any vertex/pixel/texture lookup data?



    Entering text in the lookup box causes weird text alignment issues. This does not occur anywhere else.

    OSX 10.9.2, Unity 4.5.0f6 Indie, Shader Forge 0.34.
     
  48. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    725
  49. nrlnd

    nrlnd

    Joined:
    Mar 13, 2012
    Posts:
    12
  50. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    597
    Not sure what you mean by this.
    Do you want to have remote access to someone else's SF plugin so that you could work collaboratively?
    Or do you want support for render textures that receive images via Syphon - which in turn would be used by a shader to map that image onto whatever 3d-object of your choice?

    Consider this:
    The first would probably require alot of rework just to add a feature that might lead to staggering sales - why bother buying SF when you can access it at a friend's Computer via remote?

    The latter doesn't make much sense to me. Syphon integration into your app would be up to you anyhow - in which case you can also deliver the render textures and set them in the material via scripting.

    Maybe you could elaborate somewhat more on your intention of using Syphon. What's it good for? What do want to do with it - your usecase?
     
unityunity