Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    That is what I am having trouble finding.

    My understanding of how they achieve the different tiles at the top or bottom (or at the water edges) is a different shader on a separate object.

    Here I have a map open in Hammer, and I have selected the top tiles, which are separate objects, they can be moved independently from the others, as their own BSP/CSG models.

    Due to this, my guess would be that they are handled in a completely different shader and material.

    I'm still trying to find the shader but the Portal 2 folder structure is like trying to find a needle in a haystack, they don't even keep their shaders in one place, they are scattered everywhere with strange names.

    But getting back to the matter at hand, I think adding the ability to have a top and bottom tile would be harder than it is worth, how do you know how tall the room is, and what happens if the tiles are 2m tall each for example and the room is 9m tall, do you end or start half-way through a tile?

    I think that would be very cool, but more trouble than it's worth.
     
  2. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Hey cactus...

    ...the DX11 tesselation limit is apparently 63 subdivisions so don't do what I did and just use a Unity plane scaled up 10x and still get blocky results.

    RGB_spikes.png

    EDIT I'm using normal (phong?) tesselation maybe it'd work better with edge length based?
     
  3. DuvE

    DuvE

    Joined:
    May 22, 2016
    Posts:
    169
    Anyone know how to make Double Sided + Refracted shader without weird vertex artifacts?
     
  4. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I use like 10 value tesselation on a 100x100 poly plane I exported from max, works much better that way.
    Can you post the node tree for the vector displacement sphere you used above ?
     
  5. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    can't post it yet, still some things to sort out (normal and detail normal blending, and I want to remove some of the faceting that's caused by the tesselation normal recalculations.

    Also, quick tip for tesselation values, stick to odd numbers, turn on wireframe and you'll see what I mean.


    EDIT: trying to work out some sort of standard compatibility for this. when baking, it'd have to normalize the channels obviously, but is there much done in tangent space or world space? I can see tangent space being more useful for things like dragon scale and the like, but on the other hand this isn't like height mapping where an approximate cage (offset) would just automagically work. World space may be useful for things like waves, but would be completely useless for anything that moves, rotates or animates. And you could always bake the wave is tangent space and it would work on a ball of water...
    displacement more tests.png

    (I added a bit of blue (out) to the up/down/left/right bits otherwise there was z fighting because it was displacing sideways through the mesh)
     
    Last edited: Jul 24, 2017
  6. bobi_z_nairobi

    bobi_z_nairobi

    Joined:
    Jul 18, 2017
    Posts:
    10
    Is there a way to replace unity billboard grass shader?
    When i try, this is the best result i can get. It is invisible, but when i try to paint the terrain with the grass, this is what i can see:


    I tried to set vertex positioning to billboard,I set the order to 2000 + 200, like grass billboard should have, set render type to grass billboard, but nothing helped.
     
  7. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Tangent space is more useful to generate more fantastic graphics like growing these kinda things on any surface with a nice animation. I was trying to get the tangent space displacements on a sphere to create some sort of rolling smoke effect, where the smoke can create complex shapes with a few simple textures. Looks like you sorted out the normal recalculation issue though, the reflections seem accurate.

     
  8. yusefkerr

    yusefkerr

    Joined:
    Apr 5, 2011
    Posts:
    179
    Hello, I'm trying to create a shader that looks like its been roughly sketched in charcoal. I wondered whether there were any approaches to doing this that achieved rough looking edges on the silhouette of a convex mesh. I'm still experimenting but I wondered if there were any docs on doing this with vertex offset or displacement. Or alternatively a way to use the "outline width" with a mask to rough it up a bit. Any suggestions?
     
  9. LittleRainGames

    LittleRainGames

    Joined:
    Apr 7, 2016
    Posts:
    97
    Hey that's really nice. Is it on a terrain or a mesh? Does the shader handle the spawning of plants, or is that a script?
     
  10. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    They are separate meshes. It doesn't have any plants though.
     
  11. SF_futurlab

    SF_futurlab

    Joined:
    Feb 4, 2016
    Posts:
    19
    Hi, I'm working on a simple Toon shader much like the default Unity one (but in Shader Forge so I can add some extra functionality). Its mostly working and the ramp is respecting Directional and Point lights - but the falloff distance of the point lights is not behaving as expected:
    shader_pointFalloff.JPG
    As you can see, the radius of the point light is not working. Here's my setup:
    shader_pointFaloffSF.JPG
    I'm guessing I need to put a light attenuation in there somewhere - but I can't figure out where. Any help would be greatly appreciated!
    Many thanks, Sean
     
  12. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    plug it into the multiply with the light color.
     
  13. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
  14. metteigel

    metteigel

    Joined:
    Aug 6, 2012
    Posts:
    33
    Hey. So i Downloaded 1.36 and wanted to Update to 1.37.
    So i deleted ShaderForge, downloaded it again, doesn't work.
    Create a new Project, doesn't work.

    And i can't Load Shaders anymore.

     
  15. UndercoverCheese

    UndercoverCheese

    Joined:
    Oct 2, 2013
    Posts:
    4
    Hello everyone.

    Can anybody shed a bit of light on a problem I am having. I am trying to create object rotations from a shader and I am a bit lost. So far I have managed to create a kind of skew effect which tells me I am sort of on the right track but I am stuck. any help even if it is just pointing in the right direction will be appreciated.

    mShader.PNG
     
  16. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    ok, you'll probably want to work relative to the object here. If you subtract the Object Position from World Position you get the pixel position relative to that object's "0" location.

    Another thing you might want to do is when you rotate it, work in 'absolute' so turning will be around Y axis, then transform that using the transform node from World to Object.
     
  17. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504

    This may seem straightforward and/or a bit snarky, but the simplest way in 90% of cases is to read the shader from shadertoy, and just replicate it with nodes yourself. Find out what values go where, and just do that. Most if not all of the functions will be the same (sin, divide, mesh UVs, etc) so it's just a matter of working through it.
     
  18. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    How would one convert this simple shaderToy code to Shaderforge.
    Thanks in advance.
    https://www.shadertoy.com/view/ldBGDc

    float t;
    bool keyToggle(int ascii) {
    return (texture(iChannel1,vec2((.5+float(ascii))/256.,0.75)).x > 0.);
    }

    float spiral(vec2 m) {
    float r = length(m);
    float a = atan(m.y, m.x);
    float v = sin(100.*(sqrt(r)-0.02*a-.3*t));
    return clamp(v,0.,1.);

    }

    void mainImage( out vec4 fragColor, in vec2 fragCoord )
    {
    t = iTime;
    if (keyToggle(84)) t=-t; // 'T'
    if (keyToggle(83)) t=0.; // 'S'

    vec2 uv = fragCoord.xy / iResolution.y;

    vec2 m = iMouse.xy/ iResolution.y;
    if ((length(m)==0.) || (iMouse.z<0.)) m = vec2(.9,.5);

    float v = spiral(m-uv);
    if (keyToggle(50)) { // '2'
    m = vec2(.9,.5);
    if (!keyToggle(82)) uv.y = 1.-uv.y; // 'R'
    if (!keyToggle(84)) t = -t; // 'T'
    v += (1.-v)*spiral(m-uv);
    }

    uv = fragCoord.xy / iResolution.xy;
    vec3 col = (keyToggle(32)) ? texture(iChannel0,1.-uv).rgb : vec3(v);

    fragColor = vec4(col,1.);
    }
     
  19. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    This should get you started.

    spiral example.png
     
    EmeralLotus and hopeful like this.
  20. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Wow, that looks good, did you make that texture?, what method (inside shader forge) can you use to make it look like that?, because i tried that tiny image inside and i get this result (using the G channel as the vertex modifier, and the R and B as R-G + 1 as blue channel for the normal map "construction".

     
  21. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Also, does anyone knows why this happens?


    i was using a custom plane made in blender, i thought it was a normal problem, but then i applied the material to an unity's plane and it looked the same. I found out a workaround, to fix this i have to rotate the plane in 180 degrees on the Y axis:




    it looks like a "flipped normals" problem but i dont know how to solve it, i tried a few things, using the "Transform" node, multiply the normals by -1, but they just mess up even more the normals... soo, help :( ?
     
  22. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    That probably is a flipped normals problem. If you're rotating it by 180 degrees, then both the worldspace X and Z components are wrong (the worldspace Y component is good). In tangent space (normal map) you could try multiplying the X and Y components by -1.
     
  23. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
  24. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Yaaayy, thanks :), i was mapping the UVs with world space coordinates, i just added a "One Minus" node and VOILA!

     
  25. Remer

    Remer

    Joined:
    Mar 24, 2013
    Posts:
    79

    Attached Files:

  26. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
  27. Remer

    Remer

    Joined:
    Mar 24, 2013
    Posts:
    79
    Can you make an example?
     
  28. deadlycrow

    deadlycrow

    Joined:
    Feb 10, 2014
    Posts:
    166
    Just try to connect the V output of the UV coord into the opacity ;)
     
  29. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Might want to double check that last one. (0.5, 0.5, 1) may look like a normal map color, but I think that you need to plug in un-normalized inputs, so (0,0,1).

    Way to check is if you assign that material to a plane, set your slider to 0, then pit a point light directly ahead of the camera, or a directional light pointing down just in front of the camera. Crank up the smoothness and ckeck where the highlight is.
     
    chippwalters likes this.
  30. chippwalters

    chippwalters

    Joined:
    Jan 25, 2017
    Posts:
    68
    I have a question about SF PBR settings. Here is a very flat basic white render of a building front, using a default Unity material set to white with no gloss.



    Here is the same created as a PBR shader in SF:



    Notice it's quite a bit darker, and has some funny glows. Here's the node graph:



    So, what am I missing? Why is it so dark? Thanks anyone for any help.

    Turns out if the settings are set for DEFERRED, things work fine. But I need forward as I'm making a mobile app. Any help is much appreciated.

    After more investigation, it definitely has something to do with baking. Not baked in FORWARD works the same as the regular WHITE material. Once Enlighten bakes, it gets darker very quickly. Unity 5.6.2f
     
    Last edited: Aug 23, 2017
  31. chippwalters

    chippwalters

    Joined:
    Jan 25, 2017
    Posts:
    68
    Thanks Jesus. I'll check it out. Much appreciated!
     
  32. chippwalters

    chippwalters

    Joined:
    Jan 25, 2017
    Posts:
    68
    Update on the PBR inconsistencies of Shader Forge...

    I created the below image using Amplify Shader basic white material AND BAKED...



    As one can see, it's exactly like the default Unity White shader....



    I know Amplify Shader does work directly with the surface shader, so this shouldn't be much of a surprise. It is surprising to me Shader Forge is so off color and value wise. I'll now be switching over to AS. Just wanted to post this here just in case others are having the same problems.
     
  33. Oab

    Oab

    Joined:
    Aug 16, 2012
    Posts:
    17
    Shader forge price reduce?
     
  34. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    yeah, noticed that it's gone down to $40 from $80 (?) on the asset store. Dunno when that happened.
     
  35. Ooi

    Ooi

    Joined:
    Nov 22, 2015
    Posts:
    11
    The new update also stated, "Source code is now included". I'm concerned about the future of this asset.
     
    buttmatrix likes this.
  36. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    This example uses a free barrel from the Unity asset store. Same sort of principal as the tile shader in terms of picking between options, but with just 1 alternate (dirt/rust/etc). Integrating the 2 now with a vertex painter so you can vertex paint dirty tiles that don't repeat either!

    dirt_application_shader.png
     
  37. ATeam_Production

    ATeam_Production

    Joined:
    Nov 23, 2013
    Posts:
    82
  38. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    Is it possible to drive the transparency of an object based on the shadow? for instance if part of the object is fully lit then that part will be completely opaque, but if another part of the object is fully in shadow then it will appear fully transparent.

    It seems like driving that should be pretty simple but I just can't seem to get it to happen.
     
  39. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Look for the Shader Forge Custom Lighting node graph. I think there's even a vid on youtube. You're basically after the lighting part, or at least the Lighting Attenuation and the Normal - dot - Light Direction and the Half Angle Specularity bits. Light Color won't be useful here. Play around with those bits and then you'll know what and how you need to plug into transparency.

    There's a few elements there. I see individual particles, little specks floating in space flickering in and out. The main pattern is noise based on the inside of a rotating cylinder. Then there's the radial bloom. Tackle those one at a time.


    Question, where are the latest docs for using SF to make post effects? I found a few things but I'm not sure they're up to date - is there something like Unity's 'latest version' page or similar?
     
    ATeam_Production likes this.
  40. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    Thanks Jesus!

    This is where I ended up, and it seems to work like a charm.
     

    Attached Files:

  41. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    Ok so as an update, the shader that I made to render things transparently when unlit and opaquely when lit seems to work in the editor, but it shows up as completely black on my android device. Is there something I need to do in order to make sure shader forge shaders, or transparency in general, will work on android?
     
  42. TSI25

    TSI25

    Joined:
    Sep 22, 2013
    Posts:
    11
    Silly me, it was just that OpenGL wasnt checked off in shader settings
     
  43. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    yeah that is one thing you want to put on a checklist somewhere or get in the habit when the project is starting out - make sure everything is dx9/dx11/dx12/gl ready, and make sure you're working only with the colour space (linear/gamma) and rendering type (forward/deferred). Every scene, every camera, etc in that project is rendered the same way. Get that baseline and make sure you set it to default in your mind.

    Unless you're cheeki breeki trying to sneak in some sekrit strats to rush frames like you rush b. Then I start doing forward-only and depth-only objects together in the scene, on the same layer, rendered by 2 camera with different rendering paths. But this I would not recommend.
     
  44. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Hey jesus. still wondering how you did the vector displacement. Would you mind posting a screenshot of the node tree as is ?
     
  45. mb28

    mb28

    Joined:
    Oct 7, 2012
    Posts:
    27
    Is it possible to access submeshes in Shader Forge? I've searched all over and can't seem to find the answer or which node would allow access to this. I'm trying to reduce draw calls and it would be awesome if I could do this through a shader approach.
     
  46. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    my shader clips shadow , im using unity 2017.1
    what setting do i need to change to remove this error?
    shadowclip.jpg
     
    vbs likes this.
  47. MP-ul

    MP-ul

    Joined:
    Jan 25, 2014
    Posts:
    230
    Do you guys know how to integrate the UnityChan Outline.cg file in shader forge? since shader forge does not have brightness and saturations functions! I need it for an Anime shader
     
  48. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    after some testing ive found the problem.it has to do something with shadow cascades. turning up shadow cascades to 2 or 4 removes the problem. dont know why tho
     
  49. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    Hi, I've found that created basic particle shader wont read color alpha from particle component, any way to fix?
     
  50. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Doesn't it just grab vertex color alpha? Or is that the problem?

    I know in some recent versions they added in custom data streams (there should be docs on those somewhere).

    Actually SF has RGB to HSV (and back) nodes. Hue, Saturation and Value (Brightness) are there.

    In the future, can you post more about what you're trying to do - some examples with textures, snippets of the code you want to replicate, etc, even MS Paint diagrams or whatever.