Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
    @DMeville Thats alright. no idea how to do the gif thing you did in your submission ha ha. otherwise i would put one up.
     
  2. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
  3. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
  4. sysper

    sysper

    Joined:
    Oct 11, 2014
    Posts:
    33
    Thank your for your reply!

    I did that you teach. But not works. I am a beginner and I know it is a really basic shader. :-(
    But I am not sure that Shader Forge has Sprite Shaders capability.

    How to create a Sprites-Default shader in Unity Built-in shaders with Shader Forge?
    Is there a compatible shader I can use for this, with can be modified with Shader Forge?

    I am making 2D game and I would like to modify some of shaders of the sprites.

    Thanks again,
     
  5. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Is there any way I can tell the shader to lerp between different textures depending on the light angle ? The light direction node gives me different colors regarding which angle the light is coming from, but I have no idea how to use it for lerping.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161
    Something like this?

     
  7. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161
    I just found what might be a pretty big bug in the last two versions of SF. Whenever I try and replace a new shader with an SF shader, this happens:





    I can't do anything to close SF and the only way I can get it to behave normally is if I load up an SF created shader or restart Unity.
     
  8. DMeville

    DMeville

    Joined:
    May 5, 2013
    Posts:
    418
    @Murgilod: this was happening to me too. :(
     
  9. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Nope. It should work more like radiosity normal maps. Depending on where the light hits it should show the normal color regarding to the light angle.

     
  10. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161
    Oh, jeez, yeah, I'm trying to do something similar and I've really no idea.
     
  11. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Deluxemap, that's a nice name, haha.
    In any case, just sample the texture, use the remap node to remap from the 0 1 range to -1 1 range, then normalize and use that as your light vector in the usual setups (Blinn-Phong or whatever)
     
    Cactus_on_Fire and Murgilod like this.
  12. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I'm kinda lost in the setup of the shader. Can you bang up a quick shader to show what the nodes should look like ?

     
  13. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    This is now fixed in 1.03
     
  14. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Basically - do this: http://acegikmo.com/shaderforge/wiki/index.php?title=Custom_Lighting

    But use a texture node, with your light direction map and the remap node, as a light direction, rather than the light dir vector. Mind that you need to use lightPos.w to make sure it only does it in the first pass, and not the rest
     
  15. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Can't get it to work :V



    Also I should point out that it should work with point lights as well.
     
  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    That's because you're doing something wrong
     
  17. Deleted User

    Deleted User

    Guest

    Any chance of see SubSurfaceScattering in near future?
     
  18. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    In near future? No.
    In the future? Yeah, maybe

    The thing is, SSS is something you can make yourself right now.
    SF isn't a pack of shaders, it's a shader editor, after all. Though it does have transmission and light wrapping, which is intended for SSS approximation. But if you want to make a proper SSS, you'll have to do that with custom lighting
     
    Deleted User likes this.
  19. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Well, here is the shader. I'm trying to get the most basic point light direction normals without attenuation and ambient light and all that.

     
  20. Deleted User

    Deleted User

    Guest

    Ah...so it's already possible to make this? Good, usually it's a problem when a node is missing, but if in this case this problem does not occur...then it's much better.
     
    Last edited by a moderator: Dec 28, 2014
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    LightColor is the real-time light color. If you want to use baked light, don't use the real-time color, use the baked color!

    Also, the light direction map you posted, is in world space, so you need to use the correct mesh as well, not just any mesh.

    Do the baked part first, and the real-time part second. The real-time part should be exactly like in the tutorial/wiki, with the one exception that it all should be multiplied by lightPos.w to remove it from the first pass.
     
  22. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Ohh, I get the confusion. The radiosity normal was just an example to show how the light bends the normals to get those colors. It's not supposed to operate on any radiosity lightmaps or any lightmaps at all, it should show you the realtime light direction normals on the mesh surface.
    Otherwise, I know how to do this if it was meant to use lightmaps.

    Now this is possible with directional lights, but pointlights give me a pitch black result every time.
     
    Last edited: Dec 28, 2014
  23. Eideren

    Eideren

    Joined:
    Aug 20, 2013
    Posts:
    309
    @sysper Could you tell us what exactly doesn't work ? What i gave you should work even if the texture is marked has a sprite, i tried that right now and i can't see any problems with it.
     
  24. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    When you need to regulary throw out internal builds you better stick with a beta that works for you at the moment. However I update to B18 right now and hope that it doesn't break things.
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Are you using a pirated copy?
    You're talking about specific versions - nobody would "update" to a build that is 20 versions behind.
     
  26. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Pirated copy? Hell no! We just developed a lot of stuff on our side and had some problems in the past since we updated from the first public beta on and usually left only those aside marked as minimal tested. However since U5 is still in beta problems can occur and when you have a partner company depending on your builds it is sometimes better to stick with an older version. So I was just asking. Some asset store stuff for example worked fine with older betas but failed with newer ones. That was the only reason why I was asking.

    EDIT: Maybe you got me wrong. I was not asking about which SF version I should use. I was asking about the Unity Beta. Because SF worked fine for me but after updating to version 1.02 some things gone wrong. Sorry for not clarifying things properly.
     
  27. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Ah, alright, that makes sense :)
    Latest version of both Unity and SF should always work best (some features aren't even available in Unity 4.x)

    If you run into any bugs, make sure you let me know!
     
  28. toxtronyx

    toxtronyx

    Joined:
    Aug 21, 2014
    Posts:
    114
    Stupid me ;-)
    I used the time to update to B18 and give it a shot later today. I'll let you know if something hits the fan.
     
  29. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It was a long time since I posted .gifs. I think it's time again!

     
    Deleted User and IFL like this.
  30. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Awesome. :)

    Edit: And gifs rock.
     
  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Alpha clip with dithered transparency is coming in 1.03 as well!
    Be sure to view this in full size, since dithering is a per-pixel effect :)

     
  32. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
    Awsome. If I may make a small request. which is to label which nodes require pro version to work in the built version.
    Ex: "Depth Blend (Pro)"

    Edit: and to include Sutract/divide along with the other multi input nodes.
     
    Last edited: Dec 28, 2014
  33. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161
    I think the problem there ends up being the somewhat tricky problem of the order of operations. Allow me to give an example:

    5 * 9 * 2 = 90
    5 * (9 * 2) = 90

    So all seems right there, BUT:

    5 / 9 / 2 = 0.27777777777
    5 / (9 / 2) = 1.11111111111

    5 - 9 - 2 = -6
    5 - (9 - 2) = -2

    Unless specifically documented, subtraction/division could very much result in some really difficult to track down bugs.
     
  34. Deleted User

    Deleted User

    Guest

    Can you fix also vertex and fragment counter in 1.03?
     
  35. Mynglam_13

    Mynglam_13

    Joined:
    Apr 11, 2014
    Posts:
    4
    Thank you for a wonderful plugin, for a long time use.
    Recently decided to bake lightmaps, but ran into a problem
    All warnings in console decided, lightmap support marked, but alpha clip ignored.
    Standart cutout shader work fine, but I need vertex offset and double sided polygons.
     
  36. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161


    Shader error in 'Shader Forge/Ocean': declaration of "node_9961" conflicts with previous declaration at (68) declaration of "node_9961" conflicts with previous declaration at (68) at line 71

    ...Not sure what's going on here. If I disconnect it from either diffuse or emission or use another texture asset node, it works fine. Otherwise, pink ball of death.

    edit: it seems it happens whenever I have a texture asset and a texture 2D going into emission?
     
    Last edited: Dec 28, 2014
  37. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Music to my ears
     
    Last edited: Dec 29, 2014
    Acegikmo likes this.
  38. DaDarkDragon

    DaDarkDragon

    Joined:
    Jun 6, 2013
    Posts:
    115
    @Murgilod i think your texture 2ds are the same node name internally. if you go to settings and show them you can change them manually.
     
  39. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
  40. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,161
    Tried that. Even on a fresh shader where I plug them in individually I have the same issue.
     
  41. IFL

    IFL

    Joined:
    Apr 13, 2013
    Posts:
    408
    I get this problem with duplication of Texture2Ds... If that's what you're running in to, replace one of them with a fresh Texture2D node (not a duplicated one) and it'll fix it.
     
  42. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You sure? I have a repro case, where this was the solution :)
     
  43. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Getting the vertex animation to work is a big issue with a long chain of issues attached to it, unfortunately.

    However, the transparency thing is quite easy.

    Add Transparent/ to your shader path, and make sure your transparency is based on the _MainTex texture.
    I should add a warning for this.

    Edit: There's now a warning for this. Coming in 1.03 :)

    For example, note the shader path name and the name of the texture node:

    upload_2014-12-29_8-20-38.png
     
    Last edited: Dec 29, 2014
    TFGCo4 likes this.
  44. Deleted User

    Deleted User

    Guest

    I get "undeclared identifier" error with these three nodes connected like in this screen...it's a bug?

    P.S = Same error occur with Vertex Offset.

     
    Last edited by a moderator: Dec 29, 2014
  45. sysper

    sysper

    Joined:
    Oct 11, 2014
    Posts:
    33
    Thank you very much!

    I found that for Spine all shaders must have something that resolves with Material.mainTexture.
    For anyone using shader forge with spine, make sure you name the texture going to the Diffuse node as "MainTex".

    Thanks again. :)
     
  46. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    @Acegikmo I have this error popping up a lot in the console, so I'll post it here in case nobody reported it before:



    I also have a suggestion to offer regarding the ability to move a hierarchy of nodes. Currently you have to have to:

    1) Click on "Settings"
    2) Click on "Hierarchal Node" (which should be "Hierarchical Node" by the way :) )
    3) Move the nodes as a group
    4) Go back to Settings and click on "Hierarchal Node" again to disable the mode

    Which is a little impractical. Would it be possible to activate the hierarchical mode when you simply click and hold your mouse button (without moving) for about a second? That way you could very easily have access to both modes (single and multi-node move).

    So if you click and move a node it just moves that node, but if you click and hold the mouse button without moving for about a second then it goes to multi mode and moves the selected node as well as all its children.
     
    Deleted User likes this.
  47. Deleted User

    Deleted User

    Guest

    Uhm...i think it's the same bug that occurred to me...good...hope it will be fixed fast
     
    Last edited by a moderator: Dec 29, 2014
  48. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Oh I see. Mmh I also noticed that once this happens there's no way to open Shader Forge anymore; I mean the window opens but remains blank. And this new error message also appears:



    EDIT:
    That last error turns out to be a very big deal actually; even after closing and restarting Unity I can't launch Shader Forge anymore. There's no error showing up in the console but the SF window remains completely blank... :/
     
    Last edited: Dec 29, 2014
    Deleted User likes this.
  49. Mynglam_13

    Mynglam_13

    Joined:
    Apr 11, 2014
    Posts:
    4
    Thanks, now works as expected.
     
  50. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Alright, just talked to the developer and here's the way to fix the issue:

    1) Update to version 1.02 (the bug that causes the duplicate IDs is fixed)

    2) If your shader still refuses to open in SF, manually open its code and look for the duplicate ID (in the shader's header). In this example, the ID number of this Vector3 is not unique (it appears somewhere else in the header, for another node):

    SFN_Vector3,id:2691,x:32685,y:33204,varname:node_2691,prsc:2,v1:0,v2:0,v3:1;n:type:ShaderForge.

    Once you find the ID number, either:

    - Delete the line and any of the references to this ID in other nodes (found after the "|" sign). In this case you'll have to recreate the node (and its connections) in SF.

    Or (if you really know your graph):

    - Replace the duplicate ID by a new number and make sure to apply this ID number to any other node's connections referencing that node. That's more tricky to do, but that's what I did and it worked.
     
    Acegikmo and Deleted User like this.