Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Shader Forge - A visual, node-based shader editor

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

  1. Deleted User

    Deleted User

    Guest

    Again...thanks for help :D
     
  2. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Just made these spikey smokes that goes well with the sparks.

     
    Last edited: Jan 9, 2015
  3. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You probably need to connect specular too. PBL without specular doesn't make much sense. Also, remove ambient light, it's already part of the built-in lighting :)
     
  4. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Thanks for the tips. I am kinda close to having this working properly with spec/gloss PBR, but its not quite giving me the same results as the standard Unity 5 shader yet. I'll do some more testing and fiddling and will probably post screenshots and more info at some point this weekend.
     
    Cascho01 likes this.
  5. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Still don´t get it working :-(

    Great!
     
  6. Deleted User

    Deleted User

    Guest

    Great for realistic games, for curiosity, it's all based on textures or also particles?
     
  7. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Textures, shader and the mesh, but no particles.
     
    Deleted User likes this.
  8. Deleted User

    Deleted User

    Guest

    Maybe you can modify shader and add dissolve system for explosion after specific time.
     
  9. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Yeah, there's a slider for that as well :)
     
    Deleted User likes this.
  10. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    1.03 is now out!

    Shader Forge 1.03:
    • You can now enable transparency dithering when using alpha clip
    • The append node will now accept more than two inputs
    • You can now hold Ctrl (Cmd on OSX) to temporarily toggle hierarchical node movement
    • Added warning when using lightmapping without Transparent/ in the shader path when using alpha clip or alpha
    • Added warning when when conflicting variable names are present
    • Fixed a bug where the d3d9 render platform failed to compile when using Unity 5
    • Fixed a bug where Shader Forge crashed when replace-opening a shader
    • Fixed a bug where replace-opening a shader didn't properly highlight the main node inputs


     
    Gekigengar, IFL and Deleted User like this.
  11. Deleted User

    Deleted User

    Guest

    Finally...and about relief mapping? Any news?
     
  12. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    Well, I hope I'm helping... The cg code looks good. :( Have you used the LightColor node in a Custom Lighting setup successfully before? It's the summed light-colors of each fragment within range of each light without falloff or shading applied. So if you have two red lights and an object that is just barely inside each light's range, that object would be 2x red even though it's at the edge of each range. Does that help? Or does the following do what you're wanting?
    SF_H92_01.jpg
    On that note, playing around with your node graph on a normal (non-hairy) surface results exactly like I expect, whether either switch is bypassed or not. To verify that, I recreated the shader by hand, and the look was identical. I'm not sure where to go from here.
    I didn't test it in 4.6.1 - thought you were using 5b18. At any rate, it shouldn't be black. I've attached my shader to this post. I don't know if it's backwards compatible. Let me know if it works for you - the scene's lighting/skybox has to be setup properly so that could cause an issue.
    This is wonderful! I think it'd help hide the alpha sorting issue at the base if you light it like you have the tips lit. Still, it looks great.
     

    Attached Files:

  13. Deleted User

    Deleted User

    Guest

    Mhh...no, this is the first time that i use light color node with switch, and still don't know why switch doesn't isolate node how it should (maybe i wrong something?), however i have only one point light with same coordinte of object that have fur, and i have tested your graph, this is the result

     
  14. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Yeah thanks :) If only this alpha drawing order issue was solved.

    Here's a composition of all 3 elements. Sorry for the low quality gif

     
    shaoyongzhang and Acegikmo like this.
  15. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    @Acegikmo - Is there an issue with opening compiled shader source in v5b18?

    Okay. I finally reproduced it. Something weird is going on with the CG (lerp specifically?). I tried the usual lerp work-arounds, but it's just not working. Also, I can't seem to get into the compiled shader source to check what the issue might be.

    [EDIT::] Problem identified, and I feel stupid for not realizing it sooner. ForwardAdd passes add to the previous pass. With the switch, it's adding the base texture to the previous pass. That's the problem. You want the pass gone, but it's there because the switch says it has to be. It's only kind-of a Shader Forge issue. Work-around for now: replace the variable that represents the texture in the final LERP function in the forward-add pass with 0. Not an elegant fix, but it works.

    Wow. You accurately predicted what our heads would look like after seeing this.
     
    Last edited: Jan 9, 2015
    Deleted User likes this.
  16. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    That explosion is amazing, the results you can get out of shaderforge really are something
     
  17. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    @Cactus_on_Fire Did you try to write your geometry to the depth buffer ?
     
  18. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    Hi there.
    I've just started using SF, and it's really great!

    The issue I'm seeing is getting anything to work on mobile (I'm testing on Windows Phone). Yes, I know SF is more suited to high-quality shaders, not mobile, but I was under the impression that I would be able to get some simple stuff to work.

    In this example, all I've done is put a color node to diffuse. Experimental Force SM2 is enabled. However the object just appears black when running on an actual device.

    Have I done/missed something stupid?

    Thanks!
     

    Attached Files:

  19. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Heh, thanks xD

    Indeed. I can't imagine a SF'less Unity.

    I did. Drawing order still jumps when it intersects with other meshes, also makes the alpha issues more visible. I wish there was a way to manually define drawing orders within the meshes.
     
  20. Deleted User

    Deleted User

    Guest

    So it's a forward problem? Mhh...waiting response of @Acegikmo
     
  21. wangzy_88

    wangzy_88

    Joined:
    Sep 12, 2012
    Posts:
    14
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You need to enable "Direct3D 11 for windows RT" in the shader settings when making things for windows phone.

    Not sure what you want me to respond to. It's how forward rendering works. If you don't want multiple lights, configure the shader to only use a single light source,
     
  23. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hi,

    I have wierd code in my shader about screenpos while I not use it.

    Code (CSharp):
    1.             float BinaryDither3x3( float value, float2 sceneUVs ) {
    2.                 float3x3 mtx = float3x3(
    3.                     float3( 3,  7,  4 )/10.0,
    4.                     float3( 6,  1,  9 )/10.0,
    5.                     float3( 2,  8,  5 )/10.0
    6.                 );
    7.                 float2 px = floor(_ScreenParams.xy * sceneUVs);
    8.                 int xSmp = fmod(px.x,3);
    9.                 int ySmp = fmod(px.y,3);
    10.                 float3 xVec = 1-saturate(abs(float3(0,1,2) - xSmp));
    11.                 float3 yVec = 1-saturate(abs(float3(0,1,2) - ySmp));
    12.                 float3 pxMult = float3( dot(mtx[0],yVec), dot(mtx[1],yVec), dot(mtx[2],yVec) );
    13.                 return round(value + dot(pxMult, xVec));
    14.             }
    Code (CSharp):
    1.                 #if UNITY_UV_STARTS_AT_TOP
    2.                     float grabSign = -_ProjectionParams.x;
    3.                 #else
    4.                     float grabSign = _ProjectionParams.x;
    5.                 #endif
    6.                 i.screenPos = float4( i.screenPos.xy / i.screenPos.w, 0, 0 );
    7.                 i.screenPos.y *= _ProjectionParams.x;
    8.                 float2 sceneUVs = float2(1,grabSign)*i.screenPos.xy*0.5+0.5;
    For that shader :

    sf_test_1102015.png

    My mistake or a bug ?
     
  24. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    @Acegikmo

    From memory, I cannot create my own node ?
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    No, but you can make a code node. However, did you enable dithering?
    It added the dithering function, so you probably enabled it under the blending settings
     
  26. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369

    Nope p1.JPG
     
    DaDarkDragon likes this.
  27. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That's a bug then. I just found it :)
    This has now been fixed in 1.04!
    If you want to fix it until it's out, connect alpha clip, then turn off dithering, then disconnect alpha clip.
     
  28. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    ok thanks
     
  29. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    Forgot to mention, I do have that enabled, and it still doesn't work.
     
  30. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    Hum, I restate my question ^^ Can I copy and paste nodes from one shader to another ? And if not , why ? because there are no problem of dependence because it's just a nodes copy.

    Actually, I have 2 shaders with shaderforge and I want merge them together so my question.
     
  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That's weird :(
    What if you make it only support a single light source?
    You can. Simply use Ctrl+C and Ctrl+V :)
     
  32. RogueCode

    RogueCode

    Joined:
    Apr 3, 2013
    Posts:
    230
    I just tried switching to a WinRT/Windows Store (8.1) Phone app, and it seems to work! So, for the standard "Windows Phone" 8.0 platform doesn't work (for me at least) - which isn't an issue.

    I've now got a pretty complicated shader working perfectly! :D

    p.s. as a bit of feedback: The UI is generally REALLY well thought out, and besides reading up on the nodes, I didn't need to read any other documentation to successfully use it. Even pressing a letter to bring up the menu is easy to find by accident. The only thing that I had to look up was how to delete connections. To me it should just be a right click on the connection, I don't see why I need to press alt too.
     
    Last edited: Jan 10, 2015
  33. Sylmerria

    Sylmerria

    Joined:
    Jul 2, 2012
    Posts:
    369
    I'm idiot, I have not even tested :p That works ! Great !
     
  34. Deleted User

    Deleted User

    Guest

    Light color node can be isolated by switch node? Or this can bypass switch?
     
  35. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You should be able to use light color with the switch node, it's probably working just fine. Again, the way forward rendering works, is more likely your problem
     
  36. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    372
    Loving Shader Forge so far. However we've recently run into a small issue:

    We're writing a special shader that will take a texture that is an atlas of masks we will use to blend with. We will be setting some global properties at runtime and using those properties to rotate the masks to fit the needs in the game at that time.
    The problem we're having is trying to rotate the atlas of masks whilst keeping our position in the atlas.

    For example, say the shader is using the top left quarter of the atlas. If we rotate the UV in an attempt to rotate just that part of the atlas, we will end up using a mask in one of the other corners.

    This makes sense logically - We're rotating the entire UV matrix. How do we rotate in such a way that the UV offsets for the atlas are kept intact?
    The Rotator node in Shader Forge has a Pivot property, but we cannot yet work out how that functions.

    Can anyone help?
     
  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Give it a Vector2 as pivot, which is the center of the sprite in normalized coordinates, meaning:
    [0,0] = Bottom left of atlas
    [0.5,0.5] = Center of atlas
    [1,1] = Top right of atlas
     
  38. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    A little patch release is now live! I highly recommend getting it, the first bugfix is especially annoying

    Shader Forge 1.04:
    • Fixed a bug where the internal variable names didn't update when properties were copied with precision & variable name display turned off
    • Fixed a bug where the dithering code was included even though alpha clip wasn't connected
    • Fixed a bug where you got duplicate errors on properties with conflicting variable names
     
  39. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    372
    Thanks for the rapid response mate. However it doesn't appear to work:
    Shader with rotation of 0 set and the pivot point in the middle of the top left atlas tile:


    Rotation at 90 and the splatmap is not showing the correct rotation:


    Full splatmap texture:


    EDIT. I've noticed some odd behavior with the Rotator:
    If I apply a radian angle, UV and Pivot (Vec2) I'll get a rotated UV (Note that it doesn't appear to respect Pivot!).
    If I apply the above but also add a Value of 0 and attach it to Speed the rotation will not happen at all.
     
    Last edited: Jan 10, 2015
  40. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    372
    Hrm I've also noticed some odd behavior with the Rotator:

    If I apply a radian angle, UV and Pivot (Vec2) I'll get a rotated UV (Note that it doesn't appear to respect Pivot!).
    If I apply the above but also add a Value of 0 and attach it to Speed the rotation will not happen at all.
     
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's most likely an issue because you're also scaling. You need to do them all in the correct order. You might need to define a pivot manually in this case
     
  42. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    372
    If I do the rotation first, then I won't know which tile to display on the atlas unless I somehow transform the tile location based on the rotation (Not sure how to math that?).

    What do you mean by pivot manually? Aren't I doing that right now?
     
  43. karitoSAO

    karitoSAO

    Joined:
    Mar 22, 2013
    Posts:
    3
    Tengo 2 preguntas Primera Si usted puede controlar el tamaño del hueso Fresnel Que Tanto misma veta en Bordes Y la otra pregunta es ¿por qué el nodo chanel mezclado no es la esfera o la multiplicación es la referencia Imegen utilizar
    triplanar_color.png
     
  44. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Could you write in English instead?
     
  45. Deleted User

    Deleted User

    Guest

    I can connect node to switch but switch not isolate light color, that remain active, and I would like to avoid creating further shaders copy to make this system work, again, you're sure it's not a problem of SF?
     
    Last edited by a moderator: Jan 10, 2015
  46. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    It's not a problem of SF. This specific case could be added as a feature, but it'd be better for Ace to continue his work on a multi-pass solution because I think that would inherently include this issue in addition to hundreds of others. If you're really not wanting to make copies, you can manually add shader defines or multi compile statements. It could be very useful to access those inside of SF, but they're rare enough that it's not a big deal to add them after each compile. Just keep what you're wanting to change in a notepad window to make it a simple copy-paste operation...
     
    Deleted User likes this.
  47. Deleted User

    Deleted User

    Guest

    Good...so it's definitively not a bug (but a prerogative of shader pass), that was what I wanted to understand.

    However SF it's a great tool, and hope that will be more great with 2.0.
     
  48. RaginBear

    RaginBear

    Joined:
    Jan 10, 2015
    Posts:
    6
    hey guys i need help with shadows, for some reason shadows on the SF shader are different

    right native unity shader, the left SF
    I need to fix this, its serious issue for me.
     
  49. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    In Unity 4.x or 5.x?
     
  50. frontakk

    frontakk

    Joined:
    Jan 8, 2011
    Posts:
    292
    Hi. I bought this asset.
    It's very nice product!:)
    I think this asset similar to UnrealEngine material editor.
    Is there a node like UE's suvUV node?
    I'd like to animation using a sprite sheet.
     
    gurayg likes this.