Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    I don't know if its reported, but SF gives alot of these errors with latest unity:

    Serialization depth limit exceeded at 'ShaderForge::SF_PreviewSettings'. There may be an object composition cycle in one or more of your serialized classes.
     
  2. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @XilenceX:
    That U4 example is very simple and only there to show the basics I guess. I'll see if I can post something on the weekend.
     
  3. rosevelt

    rosevelt

    Joined:
    Oct 23, 2012
    Posts:
    47
    Hello,

    Thanks for a great product.

    Is there a way to do a decal like functionality? Looking for a way to have an texture atlas and to offset/bound an image out of it and project it on the mesh at specific offset.

    If possible, can you post a graph for this please?

    Thanks!
     
  4. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    Thanks that would be awesome if you get around to it!

    I already tried that, but ofc all 0s in a vector 3, or 4 just means Black for SF. :) So the transition ends up being darkened instead of getting a red hue. I wish there was a "add no color information" node or setup, but for diffuse blending it doesn't work with vectors. ;( Normals blend perfectly fine with a 0.5 0.5 1 vector though.

    If you blend between only 3 textures it would be possible to set the base texture vector 3 to something "neutral" (turquoise in my example) in the transition area. However with 4 textures with different colors there will always be one transition that looks bad with this setup. ;(
     
  5. negativecap

    negativecap

    Joined:
    Jan 27, 2013
    Posts:
    99
    I'm trying to re-create a shader that uses object-radius, and I don't see such a node in the docs, is there any way to re-create that node in shader forge?

    edit: what I'm looking for is some way to get object size in the shader in order to scale the texture coords.
     
    Last edited: Jun 21, 2014
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Edit: Because I'm so pretty and nice and whatever, it's my day off, here's a super basic example of a shader that uses this to make it so that no matter how much you scale an object, the texel density is the same.



    Keep in mind that this only works if your scaling is uniform across xyz.
     
    Last edited: Jun 21, 2014
  7. Tony_Beretta

    Tony_Beretta

    Joined:
    Aug 6, 2012
    Posts:
    17
    I'm trying to do a kind of mirror shader.
    There is a way to slide a texture, with Panner and View Dir, without to have the texture distorted?
    What kind of numbers come out from the View, Reflection or Normal Dir nodes?
    I've tried with Screen Pos too, but it's the same.
    If I connect Sliders to the Panner simulating UV input I get the effect I need, but I need to do it with camera movement and with all the "view" nodes I don't get the same result because distortion.

    Someone can help me?
     
    Last edited: Jun 22, 2014
  8. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Hi,

    I´ve just tested DX11 Tesselation+Displacement with Shaderforge and it works fine.
    The tesselation value works on the whole mesh by default.
    What I need now, is

    - Tesselation based on distance
    For example a water surface with nicely tesselated waves close to the camera and no tesselation far away from the camera.

    - Tesselation based on edge length
    the longer the edge, the larger tessellation factor should be applied

    Please see this to read more about these useful features.

    My question is, if we can implement it using shaderforge, or only my manually editing the shaders code?

    Thanks, Carsten
     
  9. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Tessellation based on distance is a thing, but as I recall, edge length tessellation is yet to be implemented.
     
  10. Guideborn

    Guideborn

    Joined:
    Jun 15, 2013
    Posts:
    231
    How was the toon shader in this achieved?
     
  11. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    Looks like a simple ramp shader with some hatching overlaid in screen space, affecting the darkest areas most, though I am curious about how the nose outline was defined...
     
  12. Rob_SeriousGamesInternational

    Rob_SeriousGamesInternational

    Joined:
    Jan 17, 2014
    Posts:
    1
    Hey Joachim,

    Has there been any update on getting real time shadows to work alongside single lightmaps with shaderforge shaders? Image to illustrate my problem:
    SF_Lightmaps_Shadows.jpg
    As you can see the Unity standard diffuse shader supports lightmapped models and then draws any real time shadows on top of them, allowing for the blending of static and real time shadows. Bottom is the same exact scene/shot but with the materials shader switched to a basic shaderforge shader with 'lightmap support' ticked, and the real time shadows are no longer drawn.

    Cheers,
    Rob
     
  13. anthonynajjars

    anthonynajjars

    Joined:
    Jun 19, 2014
    Posts:
    7
    Hello, I'm trying to add a "Blend" where the meshes intersect, using a simple Blend fading on the Alpha of the shader. But I get weird results like transparent meshes or just the entire object turning black. I was playing a bit with the sorting and the blending mode but got no results. Can someone show me the proper way to achieve this? Cheers!

    journeyping.jpg

    And here is a screenshot that illustrates the problem:

     

    Attached Files:

    Last edited: Jun 24, 2014
  14. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Hi there, i saw in faq that shader have some problems in forward pass with alpha when we use deffered lightning render mode. So we must use deffered pre-pass, but there is no translucency and light wrapping.
    Question: will there be fix of this?
     
  15. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You won't be able to have light wrapping using deferred pre-pass. I suspect light wrapping may work if I update that system in SF specifically for Unity 5, but it's not possible in Unity 4.x.
    Transparency is hairy in all engines, especially when using deferred, due to how deferred works.
     
  16. sundance

    sundance

    Joined:
    Mar 19, 2014
    Posts:
    52
    Ok, i see..
    I have problem. On the one hand i have great glow effect for my emission witch works only with deferred render. And on the other i have shaders with transperency, translucency and light wrapping for forward.
    Maybe there are any tricks to make them compatible?

    I found solution. Thx to all)
     
    Last edited: Jun 26, 2014
  17. negativecap

    negativecap

    Joined:
    Jan 27, 2013
    Posts:
    99
    Yup. That's exactly it, thanks!
     
  18. CaseJnr

    CaseJnr

    Joined:
    May 14, 2014
    Posts:
    43
    How do I get WorldReflectionVector() from surface shaders in shader forge?

    //Surface Shader Code
    float3 normal = UnpackNormal( tex2D(_NormalMap, IN.uv_DiffuseMap) );
    float3 worldReflectionVector = WorldReflectionVector (IN, normal);
     
  19. jotapeh_

    jotapeh_

    Joined:
    Nov 16, 2012
    Posts:
    45
    I'm having trouble upgrading my version of ShaderForge from 0.32 to 0.34. Every time I download/import into my project, it stays at 0.32.

    I've tried:

    - Downloading the newest version from the Asset Store and Import/Updating
    - Deleting the entire ShaderForge folder
    - Deleting my Library

    and several combinations of the above. Looking under Editor/ and Plugins/ I don't see any files from ShaderForge, so how is this possibly happening? Is there somewhere global that Unity keeps its copy of ShaderForge, and if so, how can I force that to update?

    EDIT: SOLVED -- In case anyone else has this problem, delete your Shaders/ShaderForge folder
     
    Last edited: Jun 26, 2014
  20. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    Im trying to use this procedural noise, works perfeclty, but Im getting yellow/black color.
    Why?
     

    Attached Files:

  21. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    I found the solution.
    The output needs to be float3. :)
     
  22. wsz

    wsz

    Joined:
    Oct 20, 2012
    Posts:
    19
    Just connect the multiply node in the specular. Or not?
     
  23. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi,

    A simply tecnical question: ¿why static batching is not working when i use vertex colors as "color" and not a texture? if the same model share the same vertex color... why its not batching? The same happens with the "color" node.

    I have to do this stupid thing to get the material batched (multiply an empty Texture 2D with the vertex colors):

    sf_phongvertexcolors_6272014.png

    This saves me 30 Draw calls.. but have no logic for me....
     
    Last edited: Jun 27, 2014
  24. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I don't know much about surface shaders, but it sounds like you simply need the view reflection node, which is in world space as it is :)
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge Beta 0.35 is now out!
    • Fixed a bug where shaders, especially larger ones, took a very long time to open
    • The camera will now pan when dragging a connection to the edge of the node view
    • You can now switch tessellation mode to edge length based tessellation
    • You can now switch mode on the quickpicker to use either the scrollwheel, or the cursor position
    • The slider node looks and works a bit better (added a margin to the slider, and gave more space for dragging the node)
    • Fixed a bug where sliders using a larger min value than max value, caused massive performance drops
    • Fixed a bug where you got serialization depth errors when running Shader Forge in Unity 4.5 and above
    • Fixed a bug where you couldn't open compiled shaders in Unity 4.5
    • Fixed a bug where you couldn't use depth testing in the normal input
     
  26. anton1987ru

    anton1987ru

    Joined:
    Nov 16, 2012
    Posts:
    15
    Hello! i try to create glow by alpha channel shader but i have a trouble.
    my shader in unity is not work.
    Basic i find this threat and try recreate this method by Shader Forge
    http://ahmedsawalha.blogspot.ru/2013/06/howdy-guys-idecided-to-write-this.html
    all what i create is this isolate each other intensity of diffuse and emitter light
    still not bad but diffuse is blury

    Standart Unity3D Diffuse shader is perfect in this effect! but i can recreate this shader in Shader Forge please help!

    Code (CSharp):
    1. Shader "Diffuse" {
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _MainTex ("Base (RGB)", 2D) = "white" {}
    5. }
    6. SubShader {
    7.     Tags { "RenderType"="Opaque" }
    8.     LOD 200
    9.  
    10. CGPROGRAM
    11. #pragma surface surf Lambert
    12.  
    13. sampler2D _MainTex;
    14. fixed4 _Color;
    15.  
    16. struct Input {
    17.     float2 uv_MainTex;
    18. };
    19.  
    20. void surf (Input IN, inout SurfaceOutput o) {
    21.     fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
    22.     o.Albedo = c.rgb;
    23.     o.Alpha = c.a;
    24. }
    25. ENDCG
    26. }
    27.  
    28. Fallback "VertexLit"
    29. }
     
    Last edited: Jun 28, 2014
  27. XilenceX

    XilenceX

    Joined:
    Jun 16, 2013
    Posts:
    122
    After long hours of experimenting I managed to get my 4 texture blend shader to work as intended. Blending 4 Diffuse, Normal and Specular (in the alpha channel of Diff) worked perfectly.

    However I've got a problem again. I've packaged 4 grayscale Detail Diffuse textures into one texture and I blend them into the main diffuse to "fake" a higher resolution/detail. Compiling this shader works at first, but when I restart Unity and it compiles again it breaks down with these errors:

    The rest of the errors are basicaly a repetition of that last error there claiming that all the parameters are missing values.

    I also plan to include detail normalmaps, but as soon as I try to add the first one I get this error:
    "Shader error in 'BlendShaderPack/Splatmap Blend Shader2': Program 'frag', Constant register limit exceeded; more than 32 constant registers needed to compiled program at line 152
    Keywords: SPOT, SHADOWS_DEPTH, SHADOWS_SOFT"

    So what do those errors mean and how can I avoid them and still make the shader I need?!?
     
  28. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not sure what could cause that. A DoF/Blur post effect perhaps?


    Seems like it could be a number of things. It looks like some of your value properties have the same name, which would break the shader, or it could be that your shader is too expensive for the platform you're targeting
     
  29. anton1987ru

    anton1987ru

    Joined:
    Nov 16, 2012
    Posts:
    15
    Standart Glow post effect
     
  30. Beardbotnik

    Beardbotnik

    Joined:
    Jul 27, 2013
    Posts:
    49
    Generally for this I wouldnt use an intersection shader but rather have the objects that you wish to be blended use vertex colors to blend the way you want. So for Journey it could have been where the rocks and ruins had a shader that could blend between the sand and the base texture and they just paint the vertex colors at the bottom of the ruins or rock to get the effect. I've seen that effect used for blending grass or moss at the bottom of cliff-sides as well.
     
  31. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533


    I'm trying to make an ocean shader, and attempting some vertex offset. I can't seem to get anything other than all vertices uniformly pushed up (the effect is the entire ocean plane is just a little higher but still flat). Its odd because the material preview in shader forge shows crazy bumpy deformation. I'd like the vertices to be raised based on a height map to make some low frequency mesh-deforming waves. Does anyone know how to accomplish this?
     
  32. anthonynajjars

    anthonynajjars

    Joined:
    Jun 19, 2014
    Posts:
    7
    Thanks, I'll try the method you suggested!
     
  33. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Is that your game or a reference picture?
     
  34. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Its my game! Still trying to figure out that vertex offset
     
  35. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    What is the vertex offset based on? If it's based on a texture, have you made sure the texture is applied in the material being used?
     
  36. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    That was it. That's pretty embarrassing. Thanks Acegikmo.
     
  37. MadeofVertices

    MadeofVertices

    Joined:
    Jun 29, 2014
    Posts:
    2
    Acegikmo,
    In a post a few months back you stated that in order for a shaderforge emissive shader to be taken into account for beast lightmapping
    "1. Your shader path has to start with "Self-Ilumin/"
    2. You need a texture called "Illum", where its alpha channel will be used to mask the emission
    3. You need a color property called "Color" to control the emission color
    4. You need a value property called "EmissionLM" that controls the strength of the illumination"
    Would it be possible to know what nodes I should use to combine color/value and the texture into the emission slots of the shader itself?

    Thanks!
     
  38. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'm pretty sure you can just multiply them all together:

    Emission <- Illum texture RGB * Illum texture Alpha * Color * EmissionLM
     
  39. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,363
    I would like to know that as well, seems amazing

    Is that a ready sample in the pack ? I have not got the latest version yet

    If not, would be just amazing to have such a sample in a coming release :)
     
    yezzer likes this.
  40. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    It's not planned as a sample, but I have something planned for it down the line :)
     
  41. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,363
    Nice to know, will be very usefull

    A preset or prefab perhaps ? :)
     
  42. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You'll know at/after Unite 2014 ;)
     
  43. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,363
    Nice :), cant wait

    Your effects are really incredible, i still get hypnotized looking at the vertex shader moving around the knot :)

    The only thing is that i barely have the time to learn to create the shaders, so ready samples are always amazing to have
     
  44. P1st3ll1

    P1st3ll1

    Joined:
    Dec 13, 2012
    Posts:
    69
    How can I make a shader to work with a projector ? Like the Projector Light Shader ?
    (pretty noob with shader script) XD
     
  45. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    I think that light projectors can only load from textures, so you'd need a way to output the shader to a rendertexture, which means you'd need Unity Pro. I'm not sure if there's an easy way to do this directly from Shader Forge though.
     
  46. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120

    Not for nothing, but being able to make effects like that was a big part of the reason I bought the Asset. Kind of sucks it is apparently not doable, or was just faked for that scene. Should have been a warning bell when you didn't explain how to do it in the video, and there were no references to it anywhere on the thread.
     
  47. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    This is actually explained on the store page.

     
  48. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    Murgilod, I don't want to argue, and Its not like I'm really upset I bought the asset, and its not like I could get a refund if I wanted one. But since you responded...

    The guy posted a video showing off the product. The functionality doesn't exist in the delivered product. Its false advertising and lying.

    Its my fault because I didn't read the release notes carefully enough to see that "Real time spherical lights" which was the title of the youtube post, is not even a freaking included feature.

    Its like watching a commercial for a hambuger with a big meaty patty, and you buy it at mcdonalds and when they give it to you, its just bread, and on the wrapper it says "Sorry, no meat yet. Maybe in a few months".
     
    Last edited: Jul 2, 2014
  49. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    This functionality is not in at the moment and on the store page itself is said to not be in it. The store page itself even provides a disclaimer about this specific effect. That is the exact opposite of false advertising.

    Then it is not false advertising, but the fault of you, the consumer.

    No it isn't. It's like if you overheard a McDonalds employee talking about putting guacamole on the burgers even though the menu says "guacamole possibly coming soon" and then trying to order guacamole on your burger, only to claim "false advertisement" when your burger does not have guacamole on it.
     
  50. bmccall1

    bmccall1

    Joined:
    Jul 28, 2013
    Posts:
    120
    That would make sense, unless of course the employee produced, created, and published a VIDEO online saying "Check out our guacamole burgers".

    I said it before I'm not in the mood to argue with you and don't really care about your opinion. Posting a video showing off features that don't exist is false advertising even if you hide some verbiage about the feature NOT existing down below the scroll level on the store page. I'll make sure anyone who asks knows to read the release notes very very carefully before reading this product.

    In fact, you know what? I had no interest before in commenting publicly about this feature not existing despite actively demonstrating it online, but now, thanks to you, I plan to make sure that anywhere it is advertised, I will post to ensure they know precisely what they are getting.

    I'll make sure other customers aren't "AT FAULT" (as you put it) in the future.

    I hope that was your intent. Now if you'll excuse me I need to find youtube links and forum posts.