Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    @Acegikmo

    D = distance from a given point (or points) on the mesh
    A = amount (color value, from blue to cyan to green to yellow to orange to red)

    I would like to be able to control the color of the mesh based on the distance (D) from one side (or both) an amount (A). So the mesh may only go from blue to green over the entire surface. Or it may go from blue to red a short distance from the start point.

    Think soft select in Max when you are playing with the falloff and pinch values. Thank you.
     
  2. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can't really check distances along the surface of the geometry on a shader level, but I'm not sure thats what you're trying to do.
    "distance from a given point (or points) on the mesh" - Is it point or points? (It makes a lot of difference)

    What is the end-result you want to achieve? (This all sounds like something that shouldn't be handled on a shader level)
     
  3. AlteredPlanets

    AlteredPlanets

    Joined:
    Aug 12, 2013
    Posts:
    455
    @ Murgilod, WFTO_JWong, Acegikmo I was talking like a blood puddle, but creating animated properties is cool too, I guess I just wanted to know if I could use shader forge to create kind of effects. Nice effects by the way :)
     
  4. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Can you think of a way to achieve screen size dependant variable tesselation (i'd like to shoot for 1 pixel = no less than 1 triangle) or is that not possible (i know you can tesselate based on distance but i'm not sure if it's possible to figure out how many tris are in a given pixel in the tess stage)?

    If not is it possible to do distance based tess without custom code using just nodes?
     
  5. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I think the closest you get to that is to use distance based tessellation, which is possible yeah :)
    You can use the View Position, World Position and the Distance node to check the distance
     
  6. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Oh i hadn't noticed there was a distance node, that in itself answer my question quite a few other.

    Really amazed at the quality, no clue why the hell you call this a beta version :)
     
  7. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Are you doing something funky in the preview with the view? I just did a little test (inputing to diffuse instead of tess factor) and it works just fine if i apply the shader to a game object move in scene view (color changes while moving toward / away from object) but the object color doesn't change within the shader forge preview (if i zoom in/out in preview)
     
  8. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The zoom doesn't move the camera back and forth, it changes the FoV
     
  9. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I see, so sounds like it's all normal then :)
     
  10. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Tool looks amazing, been looking for a good replacement shader editor after shifting from UDK to Unity and this looks like it could be what i wanted. Is there any demo/trial version of this available right now? I will most likely end up buying this tool, but a demo would be nice.
     
  11. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Oh and while i can understand that behavior, i think it would be nice to add a warning on the view node about this (on a bad day, i could've spent a lot of time before trying it outside the preview :) )
     
  12. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,135
    I really hope Unity gets some expanded OpenGL support in the future. I'd love to use this stuff but I deploy to/from Macs :/
     
  13. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Feature request : i'm working on a large graph (as it's going i'm thinking it will be way above 100 nodes), any chance you could give us some form of "colored panels" like world machine does in which we can put "group" nodes by functional area and when moving a panel all nodes move along?

    I'm trying to keep my nodes grouped in areas but at 25 nodes it's already a mess and i'm barely starting my ubber offline shader
     
  14. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Is there a node that does the inverse of LERP?

    I have value A and B, lerp(A,B,0.5) = X
    Is there such a function such that func(A,B,X) = 0.5 ?

    For distance based tesselation i'm trying to do min distance max distance and i need to know where "distance" is % Wise between min max to know which % of tess (lerped between min max tess factor params) i want to apply.
     
  15. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    In the spirit of sharing here's a very tiny chunk of the shader i'm working on showing how to support both distance static tesselation. Hope this will help someone (as explained above, the tesselation won't show in the shader forge preview only in game / in editor)

    $ShaderForgeTess.PNG
     
  16. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Node grouping is a popular request, there will probably be more support for such functionality at some point :)

    For inverse Lerp, you can use the Remap node. Hold R and click, and set the "to" values to 0 and 1, and the from values, as your A and B "Lerp" values.
     
  17. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Thanks!
    There's no demo out yet, but the video tutorials should give you an idea of how it works :)
    http://acegikmo.com/shaderforge/tutorials/
     
  18. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    For inverse lerp i ended up doing it by hand instead of a single node, but i'll switch to your solution as it sounds better for readability.

    Another silly question, if using outline, how can i prevent it from being shown on the backface when also using culling? (or is that actually what the outline is? the backface of the object and thus never showing over it due to backface culling?)
     
  19. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    "when also using culling?" - Which one?

    The outline is a vertex normal extrusion with reversed face normals, and thus, frontface culling, but I'm not sure if it works correctly when using frontface culling on the main mesh
     
  20. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Sorry what i meant is when i'm using alpha (not culling, my bad) what see if i also use outline is the color of the outline (in transparent areas) instead of the background.
     
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Oh, you can't control that at the moment (If I understood you correctly).
     
  22. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Not a problem, was more of toying with the idea but i'll drop the outline from my shader for now :)
     
  23. hyogast

    hyogast

    Joined:
    Feb 24, 2014
    Posts:
    7
    Hi there!

    I want to do a shader that overlays other when I select an object.

    This "selection shader" have an emissive channel to make a glossy effect when selection.

    Is there any option for the shader to take the maps of the objects that overlays and add the glossy effect to that when the selection is on? I can do it by the Shader Forge options?

    Edit: I already have a script that changes the shader of the object by the time of the selection, but the shader does not remind the maps of the object.

    Thanks a lot!
     
    Last edited: Feb 24, 2014
  24. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Usually you don't want to switch shaders; make two materials, and switch between those, and you'll have full control over which texture maps are on which material, and in what state :)
     
  25. hyogast

    hyogast

    Joined:
    Feb 24, 2014
    Posts:
    7
    In my case, switch between materials its not efficient at all.

    I have a lot of selectable objects on the scene, and they are in different texture atlas, so making the shader changes is more efficient for me.

    I made a selection shader with the Strumpy and it reminds the maps of the objects and add the glossy effect (the selection shader have the same map slots, with the same name, so it takes the object map), but with Shader Forge I'm no capable of doing that..


    Sorry If I can not explain well.. My native language is spanish!
     
  26. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It should work as long as your properties use the same name in both shaders
     
  27. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I'm having a pretty weird issue, i've got all i need working just fine including displacement however when testing i notice that, as soon as i add displacement, things that are getting displaced on the back of the object appear "in front" of the object (as if the front was partially transparent). Without displacement it looks just fine (fully opaque)

    What you're seeing in the blue area are things getting displaced behind, on the other side of the sphere (when rotating i can 100% confirm there's no displacement issue, they're getting displaced behind not in front, no clue at all why they render over this, specially since they're backface culled untill displaced and behind both before after displacement)

    Any ideas?

    $Displacement Transparency.PNG
     
  28. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Actually here's a better example of the issue.

    In screenshot 1 the blue area is fine (opaque)

    $ex1.PNG

    I do nothing but zoom toward it in screenshot 2 (the whole of screenshot 2 is approx the same area is the blue area of screenshot 1) and look at the place in red, see through!

    $ex2.PNG

    Nothing is connected to the alpha or alpha cutout inputs, and backface culling is on.
     
    Deon-Cadme likes this.
  29. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    What's the desired effect, and how does your node tree look?
     
  30. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    The desired effect is just regular perpendicular displacement (heightmap style) and it actually works just fine (if you ignore the issue of seeing through other triangles, the vertexes are all moved where they should be).

    The tree is a bit big to post here as an example but the relevant part (the lerp is between 2 heightmaps) looks like this :

    $Displ.PNG
     
  31. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Also what seems to be blended behind is the same thing as what you can see while Inside the model (the extruded polys)

    While it's perfectly normal that i can see those "Inside" the sphere i don't understand why i can see them outside the sphere (behind perfectly opaque polys)

    $InsideSphere.PNG
     
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Double check your blending mode - are you sure it's set to opaque?
    Are you sure your heightmaps aren't (unintentionally) hit negative values?
     
  33. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Your lack of a demo forced me to buy it on the Asset Store and i am absolutely loving it so far, amazing work Acegikmo! I will definitely recommend this tool to other Unity developers.
     
  34. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Sorry that you felt forced!
    I'm glad you're liking it so far anyhow :)
     
  35. Powdered_sugar

    Powdered_sugar

    Joined:
    Aug 23, 2012
    Posts:
    64
    I don't think forced is a good way of describing it... let's just call it a compulsion :p The tool is too cool to pass up!
     
  36. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I don't see opaque but changing to off fixed it ty!
     
  37. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    Well you can always get a demo on some other place we all know about...
     
  38. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Been toying with shader forge the most of today and i am pretty impressed by how easy it makes making advanced shaders, but i am still trying to wrap my head around Physically Based Lightning, is there some good documentation on how this works in Shader Forge or are there some general knowledge to be found around this?

    Blinn-Phonn


    PBL


    Edit: Found some documentation on how to handle some aspects of PBL, my specular values were way off.
     
    Last edited: Feb 24, 2014
  39. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Is it possible to somehow have a shader recieve shadows while using the refraction node? I am trying to make a surface reflect using a RenderTexture and it seems to be working just fine, but i cannot seem to be able to recieve shadows while using Refraction. Is it possible to simulate the same effect in my diffuse node (I add the reflection to the base diffuse)?

    Without refraction


    With refraction
     
  40. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Are you in forward or deferred rendering? It seems like it should work, assuming you're forward rendered.
     
  41. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,135
    Is there a way to shatter an object into polygons in shader forge without DX11 or is that something I should script/make special models for?
     
  42. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can use vertex offset for that as well, as long as you have hard edges (split normals) in the model :)
    But it really depends on how you want it to shatter - you won't get any collision data to respond with a GPU animation like this
     
  43. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    I was in deferred, but doesn't appear to recieve any shadows in Forward rendering either.
     
  44. ok8596

    ok8596

    Joined:
    Feb 21, 2014
    Posts:
    40
    Hi, I want to make toon shading with Shader Forge and make this simple shader.
    http://i.imgur.com/awXWsLR.png

    This probably worked correct like this.
    http://i.imgur.com/zC4sxrZ.png
    But, when check the "Cast Shadows" and "Receive Shadows" to set shadow mapping..
    http://i.imgur.com/JlPgqPh.png
    The received shadow is black (Shading color is brown). And the received shadow overlap the shading shadow.

    I want this received shadow to be brown and blend the shading shadow.
    Could you please tell me?
     
  45. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @ok8596:
    Multiplying your shaded object by the light attenuation node is the cause of your "problem".
    What you want to do is map the light attenuation to a shadow color. Either do this by employing a lerp or you can do something similar like you did with the dot product (using an append node on the light attenuation to create UV coordinates to do the lookup inside your shading LUT).
    What you do with the shadow color is up to you - you could simply multiply it by your dot and diffuse color. Or you can lerp between shadow color and diffuse. Quite sime possibilities... it all depends on the look you want.
     
  46. King Phoenix W.

    King Phoenix W.

    Joined:
    Feb 4, 2014
    Posts:
    6
    Do you still plan to release Spherical Area Lights with Shader Forge? Cheers
     
  47. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    Iøm trying to figure out how i make a reflection have some falloff depending on it depth from the surface(blurs out), but i can't seem to figure out how. I am guessing that i should have some kind of gradient as the falloff paired with the Z depth for the length, but how?

    Basically this should fade out depending on the objects location from the ground:
     
  48. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Maybe, not sure! But I do want to make a tutorial for it at some point. Right now things may change quite a bit around the corner, so, I'm holding off on planning more things at the moment.

    Making it blur is tricky, but you should be able to fade it using the fresnel node multiplied by the reflection, which will approximate the effect you're going for.
     
  49. GMM

    GMM

    Joined:
    Sep 24, 2012
    Posts:
    301
    It does appear to be working, but the effect is not consistent depending on the angle the camera is facing the surface (is almost invisible in the surface when viewed from above, completely visible when viewed from the side).
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can use the remap node if you want values other than 0 to 1, which may be useful if you still want to keep reflecting even at a perpendicular angle