Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Sure. Set Blend mode to Off and disable auto-sort, configure it the same way as Opaque shaders, and it should work :)
     
  2. bcoyle

    bcoyle

    Joined:
    May 22, 2013
    Posts:
    57
    That's what I was thinking! But you're not allowed to turn the blend mode off when there's something plugged into the alpha slot :confused:
     
  3. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not even when unchecking auto-sort?
     
  4. bcoyle

    bcoyle

    Joined:
    May 22, 2013
    Posts:
    57
    It doesn't look like it, all signs point to not being able to set the Blend Mode to Off unless I remove the connection to the Alpha slot. Another dilemma that I have is that currently only Deferred Pre-Pass shaders work with CandelaSSR, but that shader method in SF disables the Alpha. I don't need the transparency, just access to adjusting that alpha number to control the screen space effect.. Would Shader Forge ever accommodate for this?
     
  5. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It should, and it's definitely possible. Right now I'm in the middle of restructuring a lot of the code, so it may take a while
     
  6. bcoyle

    bcoyle

    Joined:
    May 22, 2013
    Posts:
    57
    Well I'm in no rush, I just hope SF and Candela can play nicely together one day. Keep up the good work!
     
  7. Project-Mysh

    Project-Mysh

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

    Im the psvita debugger ( remember me? xD) like the UV problem with the variable name , finally i found another problem like that, this time with vertex colors. I had to change it to "Color" ( I was using the vertex colors as a diffuse texture ) but the name "Color" can be in conflict with other variables (maybe). Is very easy to fix, but I prefer to ask you if this is the correct way to do it.
     
  8. Jebus

    Jebus

    Joined:
    Sep 17, 2011
    Posts:
    18
    Sorry could you go into a little more detail about masking the normal vector? If there's a graph on the wiki that does something similar I'd be happy to work it out from that.

    This seems like the closest thing I can find

    Bleh, i've rebuilt the shader linked to above, and then tried to morph it into what I need, but that hasn't really worked :(
     
    Last edited: May 20, 2014
  9. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
  10. Tiny-Man

    Tiny-Man

    Joined:
    Mar 22, 2014
    Posts:
    482
    Hey, i'm going to make an ocean shader for a project.
    So I'm pretty confident on how to implement it.
    Although how would I do the vertex displacement? I.e get the wave effect sorta randomized? I was thinking of using a heightmap to determine the beginning vertex position of the ocean mesh and then run a simple sin(x) to increment the wave up and down from there.
    Thanks ;)
     
  11. roach_779

    roach_779

    Joined:
    Aug 2, 2012
    Posts:
    37
    Hi,

    I like to create a vertex color shader with detail map. What nodes should I be looking at? I don't need spec or bump, but I will need to color channel and I also need to do a diffuse version (diffuse shader with detail map).

    I just want to confirm, shaders I create in shader forge can run on machines without shader forge...correct?

    Thanks
     
  12. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    There's a Vertex Color node inside the geometry tab section.
    And you can use a Texture2D node from the properties tab section.
    As it highly depends on how you want to apply the detail map to your mesh it is up to you to use the correct uv space. When using the Texture2D node without any modification it uses uv0 (texcoord0) as far as I know.
    But you could easily use the secondary uv set or calculate your uvs inside the shader.
    Lastly you can simply multiply the detail map with the vertex colors. Or you could try one of the many blend modes that come with the Blend node.

    Correct.
     
  13. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Here is a fragment of a shader here, to use the uv2 coordinates to make individual polygons in a mesh billboard. Think a mesh with many grass polygons, that billboards for you.

    Code (csharp):
    1. v2f vert (appdata v)
    2. {
    3.     v2f o;
    4.     //vertical billboarding
    5.     float3 eyeVector = ObjSpaceViewDir( v.vertex );  
    6.     float3 upVector = float3(0,1,0);
    7.     float3 sideVector = normalize(cross(eyeVector,upVector));
    8.     float3 finalposition = v.vertex;
    9.     finalposition += (v.texcoord1.x) * sideVector;
    10.  
    11.     finalposition += (v.texcoord1.y) * upVector;

    Here is how I tried to implement it in shaderforge:

    $temp1.jpg

    When I attach it to the vertex offset, I get the pink ball and errors like this:
    Program 'vert', unable to find compatible overloaded function "cross(error, float3)". My thought on that is, am I using ViewDir correctly?
     
  14. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    I'm still fairly new to shader coding, so I'm not quite sure if this is doable:
    Let's assume I've got a icosahedron (or something similar) and I want a shader which controls the color of the faces though a custom vector input, not by normals/tangents - so that let's say a specific face lights up with a certain color when an object is in front of it (and all others faces do not). Would this even be possible with a shader or do I have to make a model specially for this task?
    (I'm assuming this could also be similar to the new faceted faces style where I simple have to split every face so that the normals aren't interpolated, but I'm uncertain.)
    Thanks in advance. :)
     
  15. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Seems fine - are you using Beta 0.34?
    (This wouldn't work in any version prior to it)
     
  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    If you want that amount of control, you're most likely better off controlling individual faces from code rather than shaders, and send the color information into either the vertex colors of the face you want to modify the color of, or tweak material properties.
     
  17. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508

    Yes, in a new project. And I don't know if it matters, but this is just within shaderforge. I haven't actually used it on a mesh yet.
     
  18. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    Hi there!

    Is there a way to make shadows go "full black" with shaderforge? I am looking for a visual style in which the shadows are fully black (ie. the shadows must not light up due to lights in the scene).

    Cheers and thanks for your awesome product!
     
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Sort of, yeah. Disable ambient lighting in the scene and make a custom lighting NdotL term followed by a ceiling function
     
  20. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    126
    Hi Joachim

    Could you tell me when you will be introducing support for Amplify Textures?
    http://amplify.pt/unity/amplify-texture/

    Shader Forge is a wonderful tool and I using it quite a lot but in combination with the unlimited textures which AT offer nothing short of a revolution in terms of new possibilities.
     
  21. neroziros

    neroziros

    Joined:
    Aug 25, 2012
    Posts:
    129
    Thanks! but is there a way to make it work with multiple lights? In my scene there is one shadow casting directional light and several spotlight and omni lights. While the ceiling method works with one light, once there is more than one the shadow is light up
     
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    There's no specific timeframe for it, but it would be nice to have at some point!

    In short - no.
    Forward rendering is done in multiple render passes, one per light source, which means each pass can't access data from the previous or following passes.
     
  23. aegget_

    aegget_

    Joined:
    Oct 30, 2012
    Posts:
    33
    Hi. I was just wondering, is there a way to limit the triplanar blend to not have the texture show up underneath the mesh?
    I have a dust texture on the green channel blend input and the other diffuse on red and blue but the dust shows up on top and underneath.
    http://acegikmo.com/shaderforge/wiki/index.php?title=File:Triplanar_mapping.png

    I used another method before with Normal Dir -> Comp Mask G -> Clamp 0-1 -> Round -> Lerp T. That worked better but left me with an hard edge instead. Do you know any good method for fixing this? Thanks!
     
  24. FreakForFreedom

    FreakForFreedom

    Joined:
    Jan 22, 2013
    Posts:
    156
    Thanks a lot for the infos! :)
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The layering depends on the order of the inputs, when you set it to layered rather than summed. Try switching them around
     
  26. Waffleslug

    Waffleslug

    Joined:
    Jan 3, 2013
    Posts:
    12
    I recently purchased Shader Forge and I am loving it so far. What I originally needed was a detail map shader but I was unsure if any of the offerings on the asset store would offer me enough control so I decided to go with Shader Forge. After a few days of playing around I came up with this and it's almost making me feel like a professional shader author: $8N2geud.png

    I have some thoughts and questions.

    Is there a way to disconnect a node line other than link up a new node in it's place and then delete the node? Ideally I would like to be able to click + drag on the node input and while still holding the mouse button press delete.

    A "Save As" or save incremental backup button in the shader editor would be nice.

    Would it be possible to get some sort of ColorBuilder node that has 4 inputs for R,G,B,A? I know that I can use the Append operation to build a color out of the individual channels but that would require 4 nodes which can be a bit of screen estate when the shaders start getting complicated. I can also add a code node to do it but this seems like a fairly standard and useful function that others might want built in.

    Do you have any plans for Unity5? The video from http://blogs.unity3d.com/2014/05/19/teleporter-demo/ makes it sound like they are moving towards Deferred Rendering as the default option. Do you have any plans to integrate with the deferred rendering pipeline or will shader forge remain a forward renderer shader?

    I played around briefly with the DX11 Tessellation/Displacement nodes - it took me a while to find your earlier posts/screenshots about how to hook those nodes up. It would be nice if that information was more easily available. Perhaps I'll add that to the wiki when I get a chance.

    I was interested in experimenting with Phong Tessellation mentioned at the bottom of this article here: http://docs.unity3d.com/Documentation/Components/SL-SurfaceShaderTessellation.html Is there a good way to do this entirely from within Shader Forge or will I need to manually edit the shader files? I'll admit I am not entirely sure what feeds into the DX11 Displacement node, can I cram vertex shader code node into that? Can I enable #Pragmas from within it? If I have to edit the shader code manually to add those features will I still be able to edit the shader with Shader Forge's editor afterwards?
     
  27. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Glad you like it!

    There are three ways:
    Alt+RMB click on a connector to disconnect it
    Alt+RMB drag to draw a connection cut line
    Backspace or delete while hovering a connector with the cursor

    It would be a nice feature, I just haven't taken the time to implement it, because other things have priority at the moment. One issue is that I can't use the built-in shader dialogue, since it should ask what you want to rename the shader path to.

    https://shaderforge.userecho.com/topic/376215-multi-input-append-node/

    Since Beta 0.33, Shader Forge has supported deferred pre-pass rendering. But yes, the plan is to make SF be able to create shaders for the upcoming deferred rendering pipeline in Unity 5 as well

    It would be great if you could add it to the Wiki :)

    At the moment you need to edit shaders manually to do phong tessellation, which will make you unable to keep editing it with SF without overwriting the changes you entered into the shader. This is something I've planned to implement natively though, so you don't have to do it manually
     
  28. aegget_

    aegget_

    Joined:
    Oct 30, 2012
    Posts:
    33
    Unfortunately that didnt work either, guess I have to rethink and see if I can find another way of solving it. Thanks away
     
  29. SGFX

    SGFX

    Joined:
    Mar 25, 2014
    Posts:
    24
    Hey Ace

    Do you have an idea what needs to be done to make candela SSR work ?
    I really dont get it to work and I have no real idea what to do

    here is what they write in their PDF

    https://hostr.co/file/0xUPdUYBp4Gl/ssr.PNG

    Do you understand that by chance ?
     
  30. bcoyle

    bcoyle

    Joined:
    May 22, 2013
    Posts:
    57
    http://forum.unity3d.com/threads/20...Unity/page22?p=1629934&viewfull=1#post1629934

    at the moment you have to edit the shader outside SF to get shaders to work correctly with Candela - hopefully in the future both of these assets will work out methods to be more compatible
     
  31. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Wow - we now have switches and toggles, absolutely fantastic!

    Am I right, that the shader will run faster when the switch uses a branch that needs less GPU/CPU-Power?

    How can we access the switch/toogle by code?
     
    Last edited: May 26, 2014
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    They don't save computation power; they are still actively evaluated properties, not static branches.

    Code (csharp):
    1. material.SetFloat("_MyToggle", 1.0);
     
  33. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Ok, but deactivating a whole branch will result in a faster rendering shader or not?:

    Look at the first node, setting it to "ON" will use one texture at all, so it will render faster - right?

    $Switch.png
     
    Last edited: May 26, 2014
  34. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Deactivating, as in, disconnecting something entirely in Shader Forge? Then yes.
     
  35. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Not in the case you've posted here. Both options are evaluated with the switch node; not one or the other; it's just syntax sugar, essentially.

    If you want only one side to be evaluated, you'll have to wait for a node which does #ifdef for you.
     
  36. jjunkers87

    jjunkers87

    Joined:
    Jan 24, 2014
    Posts:
    1
    Hey all, first off Shader Forge has blown my mind each time I play around with it so definite thumbs up to the author. But I ran into quite a serious problem today. I haven't changed anything and this problem has come up. I can see the shader in the preview but not in the scene? Has anyone ever experienced this problem before? I removed all assets in my scene, turned on and off lighting, changed type of lighting and still nothing. I am REALLY hoping to by pass this problem quickly, thanks a lot everyone.

    http://postimg.org/image/hxtgib499/
     

    Attached Files:

  37. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I would guess you're using deferred lighting in your project/camera, but making a shader that's only supported in forward rendering
     
  38. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Hey Acegikmo,
    Opening a compiled shader is broken with Unity 4.5, it looks like they changed the function signature.
     
  39. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    This should now be fixed for the upcoming 0.35 :)
     
  40. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Is there an estimated release date for this? I'm working on a Space Cowboy Game Jam entry and the deadline is a week and a half from now.
     
  41. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    0.35 will take a long time. You'll be better of having two Unity installs, one for checking compiled shaders, and one for the project itself, in that case
     
  42. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    I'll probably do that, yeah. It's just a bit of a mess since my HDD is getting mighty cramped these days.
     
  43. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    I'm not sure of this, but since installing Unity 4.5 I can't see properties of any shaders/materials which are not done with shader forge. In fact, if I add the custom editor block to any existing shaders then those properties will start drawing, which makes me suspicious that SF is causing this. I might have to uninstall it from the project tonight to verify this..
     
  44. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Nope, full rebuild of the library fixed it - I think adding the SF editor fixing it was just a fluke..
     
  45. gonzorob

    gonzorob

    Joined:
    Dec 1, 2011
    Posts:
    96
    Hi

    I'm trying to get a nice ping-pong effect (so a float goes from 0 1 then 1 to 0) using noise and time. Currently, it reaches 1 then snaps back down to 0. I'm going to use this to move verts around nicely.

    Any suggestions would be very helpful! In c# I'd do this with a modulo operator - can these be used in shaders?

    Many thanks
     
  46. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    You probably just want a triangle wave then. It's actually very simple thing to implement.

     
  47. Nieves

    Nieves

    Joined:
    Jul 20, 2013
    Posts:
    1
    I have a small question, Is Shader Forge a physic based shading editor?

    Thank you for your time.
     
  48. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    You can choose the lighting type of your shaders. PBS is one of them. It is a wonderful thing.:D
     
  49. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The Wiki should help you out in this matter :)

    http://acegikmo.com/shaderforge/wiki/index.php?title=Waveforms
     
  50. gonzorob

    gonzorob

    Joined:
    Dec 1, 2011
    Posts:
    96