Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Project-Mysh

    Project-Mysh

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

    You have to use the Transform node in the vertex offset to get all plants bending in the same Wind direction.
    And if you noticed, all plants bend at the same time using your shader, and this looks very unatural. To fix this you can use some weaves to create a natural wind animation.

    P.D: Use global variables for wind direction and wind speed to control all plants at the same time.
     
  2. layola

    layola

    Joined:
    Aug 6, 2013
    Posts:
    94
    sf_fade_10162014.png
    what's wrong with this shader
    when I play in editor ,the alpha default value is zero.
     
  3. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Since this discussed to such a degree, let's work on a Wiki page:
    http://acegikmo.com/shaderforge/wiki/index.php?title=Lightmapping

    Started that now, is there anything you think should be added?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    @layola : My guess is that the time node is producing such high values that you will have values over 1 , for example:
    t/20= 5
    1 - 5 = -4
    Camp -4 to 0 and 1 = Alpha 0;
     
  5. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Looks like a solid start for the lightmapping-section of the Wiki.
    We could expand on it with an example shader graph.
     
  6. layola

    layola

    Joined:
    Aug 6, 2013
    Posts:
    94
    how to improve ?
     
  7. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The question what do you like to do with the shader?
     
  8. layola

    layola

    Joined:
    Aug 6, 2013
    Posts:
    94
    only fading(from 1 to 0)...when pass time
    like
    iTween.FadeTo(gameObject,0,1);
     
  9. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You need to control that using code. The trick here is that the shader needs to know when to start the fade and when to stop the fade. Right now, just using the Time node won't make it, because the Time node is essentially "seconds since startup".

    But in your case, you probably want an explicit start and end time. I recommend using a Value property node, and control it using code, with material.SetFloat("_MyValue", t), where t is your fade value.
     
  10. irwit

    irwit

    Joined:
    Sep 30, 2014
    Posts:
    55
    Hi

    Thanks for the however the shader example you have just showed is what i was describing as being wrong and not what I was after.

    In real life see through glass does not affect what is seen behind it, however red glass would tint what is behind it as red. So if you had a white object behind it would change to red. However if you have a black object behind red glass it would remain black.

    Using your method a white object would turn slightly red but a black object would actually become brighter and red which is incorrect and it why the method you suggest for creating a coloured glass shader is fundamentally wrong. The alpha needs to be set to red rather than a single value if that makes sense?


    I guess I get the same issue trying to create a see through glass shader as you cannot have reflections over the top of a completely transparent object. You need to have SOME alpha visible. In Vray for example transparecny and alpha are separate. Transparency will let eyes rays pass through but still allow a reflection over teh top.

    My only hack round this at the moment is to use the reflection from skyshop R channel in teh alpha then use a fresnel to multiply over the reflection. This kind of works but isn't really ideal.

    Its seems neither effects are currently possible within shader forge?
     
  11. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Again - try setting the blending mode to multiply instead of alpha blended, and disconnect the alpha
     
  12. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Thanks for the advice. I will insert the transform node.
    What do you mean by weaves?

    Is there any way to get the values from the windzone transmitted into the shader? I know there probably is not but can not hurt to ask.
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey @libin71. If you are wanting to put a lot of detail in your trees you should try @larsbertram1 Custom Tree Importer script. It is really amazing and makes the trees work on the terrain.

    Edit- Sorry but first link was incorrect. Went to a similar thread that I never heard of:confused:. The current one should work. Hopefully
     
    Last edited: Oct 17, 2014
  14. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Any news about area lights?


    Many thanks
     
  15. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not yet. As I've mentioned before, I've begun a complete rewrite of the entire plugin, but, yes, area lights will be part of it :)
     
  16. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Hi,

    A question

    Is it possible to have the Light Wrapping effect wrap around a selected object on scene, to emulate effects like light scaterring around the sun or halo around the moon etc ?

    Thanks
     
  17. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not entirely sure what you mean. Yes, you can use the light wrapping input to make an effect like that, but I'm not entirely sure what you mean by "around a selected object on scene".
    Yes, if you apply a material using a light wrapping shader, I guess? (Not quite sure what you're asking)
     
  18. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Say i have a sky dome using the shader and want this effect to wrap only around a sun object that moves and is between the camera and the skydome and appear only there in the skydome shader. That is, a localization of the shader effect in a specific spot of an object (this could be a global question on the matter i guess)

    Something like masking the shader effect using a scene object position (or other means).
     
  19. libin717

    libin717

    Joined:
    Oct 15, 2014
    Posts:
    6
    All right.Thank you for your help!
     
  20. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @irwit:
    Are you speaking about absorption of certain wavelenghts by your tinted glass? That should be possible with SF but requires the SceneColor node and a grabPass - Unity Pro features.
    Also requires some colorspace conversions and a solid understanding of the physics (optics) and math involved I think to get it right.
     
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Just wrote an article on RGB color elimination this, in case you need it :)
    http://acegikmo.com/shaderforge/wiki/index.php?title=Color_Elimination

    ColorElimination.png
     
  22. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Nice. I just implemented a height fog for a water surface shader with a similar effect. :)
     
  23. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey guys. I am having this problem. I created these two shaders and they work great in most cases. Though someone tried a scene I made and the models using these shaders were complete black. He is using a Mac.

    If someone can just test these out and find the problem. I can not figure it out. They are not using Dx11, which is what I first thought the problem is.

    These are using the diffuse and specular ambient fake hemi-spherical setup that I asked about before. So that might be the problem too. Once again though I do not know why.

    Thanks
     

    Attached Files:

    Last edited: Oct 19, 2014
  24. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey.

    I do not know why I forgot but to get the baking of transparent shaders to work you have to put them in the transparent shader category. So with my shader instead of: TFP_Shaders/TFP_Leaf_Shader
    I changed its name in the code to: Transparent/Cutout/TFP/TFP_Leaf_Shader

    It now bakes the shadows great.
     
  25. marggob

    marggob

    Joined:
    Feb 24, 2013
    Posts:
    65
    Hello. Do you plan to support "Enlighten" in "Unity5"?
     
  26. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Try adding
    #pragma target glsl
    to your shader and see if this fixes the issue. Also make sure the OpenGL rendering is not excluded (from a quick glance at TFP-BumpedSpecular it looks ok).
     
  27. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Thank you for the help. Will add that line and see if it works for him.

    I checked and OpenGL is enabled. Does it cause any problems if you would to just enable all the options Like PS3 and 360?
     
  28. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Yes
     
  29. donov

    donov

    Joined:
    Apr 15, 2013
    Posts:
    55
    when will there be a SALE!!!! :D
     
  30. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Whenever Unity want to do it, so, I don't know
     
  31. RUBILYN

    RUBILYN

    Joined:
    Jun 22, 2013
    Posts:
    54

    Hello Dear Friends ! Can Someone be kind enouph to Convert this UNREAL4 Shader to SHADERFORGE Gem Nodes for the WIKI please ! Its something Really Needed.

    We tried to make this conversion for days but ... Its really out of our league ...

    Thanks So Much in Advance.




    --

    Nodes & Sourçe Code Provided Bellow


    Visual Nodes Guide Full Size: http://s27.postimg.org/aaanohrbl/POM4.jpg




    Custom code blocks are as follows:

    CalcParallax

    Code (JavaScript):
    1. float CurrRayHeight = 1.0;
    2. float2 CurrOffset = float2( 0, 0 );
    3. float2 LastOffset = float2( 0, 0 );
    4. float LastSampledHeight = 1;
    5. float CurrSampledHeight = 1;
    6. int CurrSample = 0;
    7. while ( CurrSample < (int) InNumSamples )
    8. {
    9. float4 Temp = Material.Texture2D_0.SampleGrad( Material.Texture2D_0Sampler, InTexCoord + CurrOffset, InDX, InDY );
    10. CurrSampledHeight = ( ( Temp.r * InChannelMask.r ) + ( Temp.g * InChannelMask.g ) + ( Temp.b * InChannelMask.b ) );
    11. if ( CurrSampledHeight > CurrRayHeight )
    12. {
    13. float Delta1 = CurrSampledHeight - CurrRayHeight;
    14. float Delta2 = ( CurrRayHeight + InStepSize ) - LastSampledHeight;
    15. float Ratio = Delta1/( Delta1 + Delta2 );
    16. CurrOffset = ( Ratio ) * LastOffset + ( 1.0 - Ratio ) * CurrOffset;
    17. CurrSample = InNumSamples + 1;
    18. }
    19. else
    20. {
    21. CurrSample++;
    22. CurrRayHeight -= InStepSize;
    23. LastOffset = CurrOffset;
    24. CurrOffset += InStepSize * InMaxOffset;
    25. LastSampledHeight = CurrSampledHeight;
    26. }
    27. }
    28. return CurrOffset;

    Output Type: CMOT Float 2
    Inputs are:

    1. InNumSamples
    2. InStepSize
    3. InTexCoord
    4. InDX
    5. InDY
    6. NormalHeightMap (Not actually used, just there to ensure texture doesn't get optimized out)
    7. InMaxOffset
    8. InChannelMask

    CalcSilhouette

    Code (JavaScript):
    1. if( InUseSilhouette > 0.0f )
    2. {
    3. clip( InFinalCoords );
    4. clip( 1.0f - InFinalCoords );
    5. }
    6. return InFinalCoords;
    7.  
    Output Type: CMOT Float 2
    Inputs are:

    1. InFinalCoords
    2. InUseSilhouette

    NOTE:Make sure that the height map is the first texture you drop into the material graph as the above custom code block accesses that texture directly viaMaterial.Texture2D_0andMaterial.Texture2D_0SamplerIf you don't drop it in first, it will be referencing the wrong texture. To fix that you will need to change those two values to whichever one is assigned to the heightmap.




     
  32. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    This is a DX11 only shader ? (Due to the tesselation)
     
  33. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    If you mean in the post above - no, it's a parallax occlusion mapped shader :)
     
  34. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,348
    Wow, please post a graph that does that :) !!!!

    It seems the rocks are formed by a pefect mesh, seemed too good to be paralax, this is what i usually see in DX11 displacement mapping samples

    There is no mesh deformation at all in this example ?
    .
     
    ThunderTruck likes this.
  35. Cascho01

    Cascho01

    Joined:
    Mar 19, 2010
    Posts:
    1,347
    Sorry for this stupid little question:
    Is it possible (in Shaderforge) to have shadows on alpha blended object?
     
  36. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hey, I have a few questions regarding to the UE4 POM shader. The terminology is slightly different but most of them are the same as Unity. I hope Unity shader forge has all the functions that UE4 shader editor has.

    So ;

    Camera vector = View Dir

    Vertex normals = Normal dir

    Tex Coord = UV Coords

    DDX / DDY = No Idea.

    Also is there a way to copy-paste texts from code edit mode ? Ctrl+V doesn't do the trick.
     
  37. Project-Mysh

    Project-Mysh

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

    I have a very simple question:
    How I can expose vertex colors in beast lightmap for GI baking?
    Im using vertex colors as diffuse for some mobile models. Using a texture its working.
     
  38. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    Folks, sorry to bother, but someone already found a way to replicate this?

    is some kind of volumetric lights, or at least a simulation of it, .

    Many thanks for attention
     
  39. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    @angelodelvecchio

    Hey angel. What you're looking for seems more like lens flares rather than volumetric lighting. Unity has some defaut lens flares which create horizontal streaks with bloom which creates an effect like in your picture.

    Although I have been working on some volumetric light effects that look like this.



    Play it here if you like to see it in action : http://www.mediafire.com/download/rq7if370x72tz2a/Night+Scene+UFO.rar
     
  40. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    hey cactus !!! Many many thanks for attention !, but is not this., this "volumetric" might simulate a kind of radiosity around the lights,
    something about the "cone light" in the shader forge demo,

    Many thanks


    *** good night scene ! i loved it
     
    Last edited: Oct 22, 2014
  41. irwit

    irwit

    Joined:
    Sep 30, 2014
    Posts:
    55
    Hi Acegikmo

    My bad, i should've read your earlier comments. I must have missed them. Again apologies and thanks for your patience to reply twice to the same question! :)

    Im not sure where you mean to change blending modes, do you mean the blend node? I thought that could just blend two image inputs?

    Sorry for being such a noob here and thanks again for the help, hugely appreciated!
     
  42. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    POM is a very expensive effect, so this doesn't come cheap.
    You can set the quality level on it as well, it looks like it's cranked up very high in the image posted.

    I don't have a graph on it, but I do believe people have made a few for UDK and UE4.

    ddx and ddy aren't available in SF yet, but you should be able to use them in the code node. They're a function accepting a vector input, like so: ddx( myUvCoord )

    No problem. It's in the blending settings of the shader, not in the node tree.
     
  43. irwit

    irwit

    Joined:
    Sep 30, 2014
    Posts:
    55
    ahh, thats awesome! Thanks for the help! Hugely appreciated!
     
  44. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    There is no answer about exposing vertex colors as "_Color" or "_MainTex" to beast lightmaping?
    I really need it to get nice results baking GI.
     
  45. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not sure what you mean by "exposing vertex colors". Vertex colors can't be edited with a shader/material, they're part of the mesh data, just like normals/verts/uvs/tangents, etc.

    That said, you can use _MainTex and _Color, and have beast read from them. More info here:
    http://acegikmo.com/shaderforge/wiki/index.php?title=Lightmapping
     
  46. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    I dont want to edit vertex colors, i want them to effect Global illumination baking. When I use vertex colors, beast bake the scene like all my objects are "white", its not geting the color information from vertex colors.
     
  47. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Ah, no idea how to do that. If beast doesn't do that on any of the Unity materials, I doubt you can get it to do it.
     
  48. kurai

    kurai

    Joined:
    Jan 9, 2012
    Posts:
    118
    Hi there,
    I'm a total newbie trying to understand shaders better. Here is what I'm trying to do. I've got a low-poly triangulated surface (which is not flat, but slightly perturbated) and I'm attempting to use it as a low-poly sea for a scene. Now, my idea is to create a ripple/wave animation by using the vertex offset. I've tried both with a sine wave and with a triangle wave which multiply a vector3 (0,1,0) so to move my vertices only on the y. Problem is (quite logically!) that this way I'm moving the entire mesh rather than some vertices in a ripple fashion.
    Now, I'm experimenting without knowing too much, but can someone point me in the right direction in how to obtain a wave effect by offsetting only certain vertices? Thank you so much!
     
  49. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Ok, thank you anyway!
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You need to change it not only over time, but over space as well. Usually you can use the world position node for that, to offset the phasing of the wave generator.

    This might help: http://acegikmo.com/shaderforge/wiki/index.php?title=Waveforms