Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Airborn-Studios

    Airborn-Studios

    Joined:
    Oct 31, 2012
    Posts:
    30
    Hey Joachim,

    I found a new bug.

    If i import dds files with custom mipmaps i can get access to the mipmaps with unity in the texture preview window, however once i use this map in shaderforge i can't controll the mipmaps at all.

    oh wait while i debug it, it seems like it can read the cubemap faces individually, just not the cubemap itself

    $cubemapbug.gif

    not sure this is a shaderforge bug :|

    :edit: okay this is definitely no shaderforge bug, if i duplicate one of the default cubemaps and exchange the textures it works as it should, if i create a new cubemap it doesn't

    :edit2: DANG! i'm a fool a newly generated cubemap is set to NOT use mipmaps by default, just like the default setting for a normalmap is, that it is no normalmap

    okay then, nevermind.
     
    Last edited: Mar 4, 2014
  2. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    You could try PIX that ships with the Microsoft DirectX SDK. Last time I used it though was back in the days of XNA 3... quite a long time ago. I don't know if you can get a recent version or if MS has moved on to a new product.
     
  3. bariscigal

    bariscigal

    Joined:
    Oct 26, 2009
    Posts:
    46
    Ok let me answer my own question.
    For the "realtime reflections" i have used the mirror 3 from wiki page.
    http://wiki.unity3d.com/index.php/MirrorReflection3

    In Shader Forge i have used the screen coordinates to generate the uv of the texture on the object. The uv setting should be "scene uvs" or it wont resize up. If you are using the script from the wiki page directly you need to rename the the texture nodes name to : ReflectionTex so the script can overwrite the texture each frame.

    The catch is under quality tab per-pixel screen coordinates should be activated or the uvs get messed up.

    $screenCorrdinates.jpg
     
  4. ApocX

    ApocX

    Joined:
    Sep 5, 2012
    Posts:
    1
    Any chance anyone could help with a rather simple shader request? I'm trying to make something of a fake interior shader. For the most part, I've got it down, but I can't seem to setup the correct controls to scale the cubemap. My first tests were simply multiplying a v3 against the reflected view angle - which worked for the most part. However, the illusion tended to fall apart if I rotated the geo, or backed the camera up.

    Cubemaps in unity seem to have a habit of getting larger the further the camera gets... I'd like the cubemap to stay the same size if at all possible,

    Update: Switched over to using a single texture and a parallax node. A bit easier to control, and the results are already looking better :)
     
    Last edited: Mar 5, 2014
  5. laurenstjong

    laurenstjong

    Joined:
    Feb 28, 2013
    Posts:
    6
    Mister Ace,

    There is a small problem I encountered using Shader Forge. The Diffuse color of a basic diffuse shader made in shader forge looks a bit more darker and greyish than the standard diffuse shader from unity. I noticed this after making a slightly more complex shader.

    $DiffuseWhiteAmbientColor.jpg

    $sf_candyv2_352014.png

    This is a screenshot made with a completely white ambient color, the diffuse tint set to white and with no additional lights in the scene.

    If anyone could doublecheck this issue i would be very great full.

    Thank you in advance
    Laurens 't Jong
     
  6. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    There's a checkbox called "Double incoming light" in the lighting settings, check that, and it should match :)
     
  7. laurenstjong

    laurenstjong

    Joined:
    Feb 28, 2013
    Posts:
    6
    Hey Ace

    That's great, it works thank you for the quick reply!

    If you don't mind me asking... Why is this? And what option should I choose when I want to work with physically correct lighting?

    Cheers
    Laurens
     
  8. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Unity multiplies lighting by two, for whatever reason, which means an extra instruction for all shaders, so I skipped it in SF by default.

    As for which you should use - you can use whichever you like, as long as you use the same for all shaders :)
     
  9. laurenstjong

    laurenstjong

    Joined:
    Feb 28, 2013
    Posts:
    6
    I wonder why they would do that.... thank you Acegikmo!
     
  10. Krisprollus

    Krisprollus

    Joined:
    Mar 5, 2014
    Posts:
    2
    I'm trying to create a shader rendering different textures based on the presence of light.
    As you can see in the first screenshot bellow, both textures blend, what am I doing wrong ?

    $doingwrong.jpg

    I'm using this configuration :

    $sf_visibility_352014.png
     
    Last edited: Mar 5, 2014
  11. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    Given you've said you've not been feeling great, and regarding that i hope you feel better soon! so i'm not going to put any pushy forum brat stuff on you, i was just wondering if you had any time frames for some of the rather fundamental work you seem to be aiming at regarding nested nodes/custom nodes and the like, i'm in no massive rush though, just figured an outline would help me prioritise my own work (there's a bit i'm really.. buhh about implementing with current methods to get a good result when a custom node would hit the sweet spot, but need a rewrite)

    You can disregard the above mind, when I feel like S*** there's no getting me to do ANYTHING so your continued work is appreciated. On that subject I might have to add that this is one of the most enjoyable ways of making things i like to make best (pretty things) i've ever encountered and the options are staggering and some of the upcoming features could start an almost exponential increase in incredible results from the dedicated graph enthusiasts. I really, on a personal basis, want to see how various shadertoy fooling both plays along in general and implements more in a rasterised environment, giving their usual approaches to getting things displayed is particularly different. I'm not sure how broad the scope of this all will be but it's enthusing.
     
  12. DavidMiranda

    DavidMiranda

    Joined:
    Nov 30, 2012
    Posts:
    617
    Hi. Thanks so much for doing this.
    I need to have tessellation. Since its quite expensive, I try to decrease the subdivision level by distance. But oh surprise, I see the subdivision is not continuous. I have made this in UDK, I think. Have you tried that. Could you maybe tweak the tessellation options?
    Maybe its related with this?

    [domain("tri")]
    [partitioning("fractional_odd")]
    [outputtopology("triangle_cw")]
    [patchconstantfunc("hullconst")]
    [outputcontrolpoints(3)]

    $05-03-2014 22-06-12.jpg

    Cheers.
     
    Last edited: Mar 5, 2014
  13. vivin

    vivin

    Joined:
    Jul 10, 2013
    Posts:
    15
    Just purchased this plugin, as the reviews and feedback sounded solid. Been playing around with this all day and im in love, this is a wonderful tool to use.

    Sadly I have been hit with the null reference exceptions error when trying to reopen the shader I was working on. I see there is a fix coming in 0.26, so ill need to be patient and wait :)

    While I wait, I thought to understand clearer what is happening under the hood. We were planning on going with deferred rendering for our game, it seems shader forge respects that and simply renders the objects with a shader forge shader applied in forward.

    Im not terribly technical on these things, but can anyone see an issue having large areas of a game render in forward? I'm planning on using this shader on the ground for instance.

    Also another area I cant quite explain, but it seems shader forge shaders handles multiple dynamic shadows? Default unity shaders in forward rendering dont. I assume there is a cost involved in doing this?

    cheers
     
  14. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    The tricky part is that "the presence of light" can only be detected on a per-light level, not after all lights have been rendered. This is because in forward rendering, you have separate render passes per-light, so they don't know much about each other at all.
    This might work if you're just using a single directional light.


    It should work fine; how does your node tree look?

    Forward rendered objects have a limit to the amount of per-pixel lights they can be affected by, so, if you have a terrain where you want a lot of light sources, you'll most likely get weird lighting behaviour. However, you can split the mesh up into multiple parts, and make sure you only have 1-3 light sources affecting each part.

    As for the shadows, SF enables shadows for point lights as well, which you can turn off in the point light itself, if you want to :)
     
  15. vivin

    vivin

    Joined:
    Jul 10, 2013
    Posts:
    15
    Thanks for the reply, I'll keep that all in mind while moving forward.

    I have stumbled upon a problem I cant quite figure out, its been a long day here, so maybe something obvious im not seeing?
    I have a channel in a mask texture(Green channel in this case) I want to create regions from it, so you can see in the graph the clamping/remaping. Now I want to take the 2 regions and multiple them to grab the difference between the 2, it all looks fine on the blend node, but when I plug the result into diffuse, it comes out with the result on the left. Maybe there is an even easier way to selectively select a value of a texture to use..and im not seeing it

    cheers $shaderForge01.jpg
     
  16. Krisprollus

    Krisprollus

    Joined:
    Mar 5, 2014
    Posts:
    2
    Thank you, it was the ambient light which is set to 0.5 intensity.
     
  17. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    Hey i have a question. I'm pretty good at materials and stuff. would you mind Acegikmo if i made a material pack for the asset store? if you would rather i didnt then i wont, but i thought id ask just in case. Love SF by the way, amazing product.
     
  18. AGeorgy

    AGeorgy

    Joined:
    Sep 16, 2013
    Posts:
    42
    Hi Ace!
    Can I in SF make DoF with mask?
    It is necessary that the background is not blured and the objects you want to blur transform to mask texture.
     
  19. CliveTheBankman

    CliveTheBankman

    Joined:
    Mar 7, 2014
    Posts:
    1
    I noticed somebody in the pre-Asset Store thread posted a cross-hatching custom lighting shader.

    Does anybody have a hot tip for creating this?

    I noticed a few pages back that blending based on attenuation might not be the approach with forward rendering - so maybe by inverting the dot product of normal / light direction and blending based on this?
     
  20. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    @Cynicat:
    Acegikmo will surely answer your question in time.But in the meantime you might flip back a few pages and reread the discussion about selling SF shaders on the Asset Store and the mixed opinions about it.
     
  21. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Sure, go ahead!
    I would appreciate a mention/link to either the SF website or to the SF asset store page though :)
    It should be relevant to your customers too, in case they own SF. That way they know they can open them as well, and tweak them

    SF isn't really adapted for making post FX, I'd recommend using the built-in image effects for that
     
  22. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Shader Forge 0.26 is now released
    • You can now use global variables!
    - Currently supported types: Value, Vector4, Color and Texture
    - Right click on a property and select "Make global"
    - Global variables can only be set from code. For example: Shader.SetGlobalFloat("_MyGlobalValue", 5.0f)
    - Currently, there's no way of making the nodes display their current global value
    • You can now pick and use Render Textures, as well as Procedural Textures (from Substances), in the Texture2D nodes
    • Added an experimental Shader Model 2.0 force feature
    • Added the d3d11_9x platform (Direct3D 11 for Windows RT)
    • Fixed a bug where box selecting while zoomed out didn't work properly
    • Fixed a bug where you could only see the first mesh, in meshes containing submeshes
    • Fixed a bug where the Channel Blend node broke when the mask component count didn't equal the color component count
    • Fixed a bug where arithmetic nodes sometimes caused null reference exceptions when loading shaders
    • Fixed a bug where drag-creating a new node on top of an existing one, caused it to lock up until you clicked again
    • Fixed a bug where some coordinates were offset when the SF window was docked
    • Ninjafixed a bug where the left separator reset its position when using hotkeys on OSX

    Changelogs for previous versions

    Enjoy :)
     
  23. Cynicat

    Cynicat

    Joined:
    Jun 12, 2013
    Posts:
    290
    ok thanks! i'm planning on making some automap shaders, surface shaders, and maybe do some tesselation explosions as well. yeah I'm definitely going to add relevant links to the ShaderForge website and asset store page. have a great day! =3
     
  24. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    This is great! I saw a post earlier about manually adding code to shader directly, apart from shaderforges additions, is this possible? I was hoping this could be done or custom nodes pop up soon or my node layouts are going to become vast being imagining
     
  25. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Not yet! But it is a planned feature :)

    Also, in case someone missed this at the bottom of the previous page:

     
  26. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Sweet. Going to download this update asap.
     
  27. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    239
    Any prevision on when it's going to be compatible with deferred ?
     
  28. t-tron

    t-tron

    Joined:
    Dec 6, 2012
    Posts:
    4
    Great tool! I am brand new to shaders and SF and was wondering if it is possible to write a custom shader to achieve a sort of rotating Photoshop paintbrush effect. I am using a unity trail effect attached to a moving object, but am looking to occasionally rotate the textures to achieve the attached effect. It seems that I can't rotate the trail in Unity and so far my experiments with the rotator node proved fruitless. I am able to rotate the texture node's UVs but that effect gets applied to all of the trail's nodes. I would like the nodes to smoothly rotate to achieve the attached. Any help would be super appreciated.

    http://imgur.com/An5HRZk
     

    Attached Files:

    Last edited: Mar 8, 2014
  29. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hey Ace,
    have you considered adding support for the different types of particle quads Unity3d exposes inside its Shuriken system?
    Currently you cannot use normal maps and the inbuilt lighting system of Shader Forge for particles ... at least I am getting some weird results for horizontal facing particles and I think there will be more trouble down the road with camera facing particles.
    I think of a pulldown menu inside the shader properties where you could chose between different types of particles - default to none with the current behaviour.
    Here's a picture showing the trouble I get with horizontal particle quads:
    $sf_unity3d_particles_bloodsplatter_shadingerror.jpg
     
  30. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    I've been working on this fairly simple shader with shaderforge, takes a splatmap and blends textures using the RGBA from the splatmap. It works fine till I try to run it on my nexus 5 or nvidia shield, everything looks black.

    Anyone have any insights or tips as to why textures would appear black on mobile? I've noticed this happens with skyshop shaders sometimes as well. I've tried tweaking all kinds of stuff, texture compression, force opengl ES 2.0 in shader forge, 32 bit buffer.. messing around with it googling around all day, it's just black black black on my android devices.

    This isn't necessarily an isolated shaderforge thing, but I thought I would check here to make sure there's no known issues with shaderforge and opengl es 2.0.
    Thanks~
     
  31. hobstob

    hobstob

    Joined:
    Dec 18, 2013
    Posts:
    20
    Awesome asset! Something I would like on the wish list is a way to undo changes that I've made. Other then that its a awesome asset.

    $Shader-work.jpg
     
  32. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Maybe! I'll have a look at it this week, to see if it's even viable to start making it work, or if it's too much. So we'll see :)
    Mind that deferred will be limiting when it comes to custom lighting, it will disable many of the inputs of the main node.

    I haven't really looked into particle shaders, I should really do that, thanks for the reminder :)

    Seems like your shader may be too expensive for the target platform. Are you using a lot of textures? Try reducing the amount of textures and/or properties, and see if it works somewhere along the way.
     
  33. mandydark2

    mandydark2

    Joined:
    Aug 13, 2012
    Posts:
    17
    Hello friend, always a joy as you release new developments in your pluging.
    Like I always remember one super important functionality would be the reflections in real time, this brings me really running and I could only find a script on the wiki using the camera and the transformation matrix to create reflection, works fine, but I can not use your pluging.

    If you like have a look is here: http://wiki.unity3d.com/index.php/SurfaceReflection
    So maybe it could be useful in the implementation to include functionality with Shader Forge.

    Thank you
     
  34. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Hey mandydark2,

    I've read several of these requests before. A lot of artists want realtime reflections. But I don't think Shader Forge is the right tool for this kind of stuff.
    At least in my eyes it is not the tool to present you with a one-click solution.
    Reflections highly depend on your rendering process. What objects to render? What layers to exclude/include? What camera to use for rendering the reflection?
    This is entirely bound to your gameplay mechanics and your scene setup. Even in UDK realtime reflections are not a single node solution inside the material editor - you have to place a special actor in the scene that writes a rendertexture into a rendertarget node of the material. Essentially it is doing the same as the wiki scripts.

    And here comes Alpha 0.26...
    With the latest release Joachim added this feature:
    This should be all you need to get realtime reflections going. Create the scene setup with the scripts from the wiki and reroute the rendertexture into your Shader Forge graph. Hope this helps.

    edit: I missed the matrix. Which means you probably need to hand edit the shader file to add the necessary calculation. So setting custom matrices is the only thing missing for now I think in SF.
     
    Last edited: Mar 10, 2014
  35. Airborn-Studios

    Airborn-Studios

    Joined:
    Oct 31, 2012
    Posts:
    30
    Maybe anyone knows what i'm doing wrong, it feels like only my specular gets changed by surrounding shadows, not the diffuse itself.

    i'm using a custom shader, and it seems like once i use a custom lighting model the self shadows get lost :(
     
    Last edited: Mar 10, 2014
  36. mandydark2

    mandydark2

    Joined:
    Aug 13, 2012
    Posts:
    17
    Yeah, you're right...

    Unreal uses a SceneRenderActor to capture the scene and you can adjust how far and near it captures.

    It is true that the shader forge has almost all the tools needed...
    and looking at the script I also agree with you that the only thing missing is pass the matrix to SF, I'll currently try to encode a solution that:

    1-Create a single object that can capture the reflection (similar to the UDK SceneRenderActor) and not have to assign the script to the wiki to each and every GameObject that needs to be reflective in my scene.
    2 - Use the Shader Forge to capture information matrix reflection from above GameObject. Since now, the global variables do not support matrix, I'll have to settle it manually to see how it goes.
     
  37. mandydark2

    mandydark2

    Joined:
    Aug 13, 2012
    Posts:
    17
    my friend acegikmo, I have seen in youtube your spherical light example (https://www.youtube.com/watch?v=3tHI2J9_c9k&list=UU7M-Wz4zK8oikt6ATcoTwBA) and I was wondering if it is possible to illuminate using emissive channel ... not only make an object glow but make the object itself to contribute to the lighting of scene, such as with Lightmass in UDK and emissive materials...

    From what I saw in the example, the spheres are bringing light and real scene brightness (bloom), the effect is so beautiful that I've been totally in love with him and would love you to tell me if it is possible to achieve what I just told you to write above.

    thanks like always
     
  38. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    You can make emissive materials for the lightmapper, but you have to follow a bunch of weird standards by the beast lightmapper in Unity.
    Here's a list of requirements:

    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


    As for real-time planar reflection - someone has been able to make real-time reflection with SF, without manual modification, I believe. Check it out here: http://shaderforge.userecho.com/topic/372456-real-time-reflection/
     
  39. DSebJ

    DSebJ

    Joined:
    Mar 30, 2013
    Posts:
    101
    I'm trying to build a shader that fades back and forth between two property specified colours.
    I've been able to get animations of textures working with UV coordinates but I'm a bit lost on this and it seems like it should be really simple.
    Any advise or suggestions would be appreciated :)
     
  40. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    Earlier, I was trying to get it to work with RGBA splat controlling 4 diffuse / normal textures, with IBL diffuse and specular lol. So that's what was apparently wrong. I think it must have been too much. As soon as I "forced opengl es 2.0" it started spitting out errors on compile saying that it was too many instructions.

    I ended up making the shader again, with only diffuse, and I got that working fine. I would really like to have normals because by the time I get this game out the door, mobile devices should be able to do normals. Tegra K1 is coming out in the near future, and honestly I think my nvidia shield could probably handle full normal mapping already.

    it looks okay with 4 diffuse blended together,
    $Screenshot 2014-03-10 19.29.10.png

    I'm going to try to see if I can get RGBA splatmap with 4 diffuse and normals blended together... I guess I'd be okay without specular and IBL. Or I could try cramming the specular data into the alpha channel of the diffuse textures, like skyshop does.

    Lots of fun, shader forge.. thanks for this valuable asset.
     
    Last edited: Mar 11, 2014
  41. p87

    p87

    Joined:
    Jun 6, 2013
    Posts:
    318
    I think you would want to use the Time node, which gets the current time. I'm not sure what kind of a value the time node gives you, but use the time to blend back and forth between textures and drive the animation some how.

    You'd probably want some kind of an input value or slider to control the speed of the animation. The time value is constantly changing, so I guess mabye figure out some clever use of arithmetic nodes and Time to drive the animation and blend back and forth between the two.
     
  42. vivin

    vivin

    Joined:
    Jul 10, 2013
    Posts:
    15
    Hi all,

    I had an idea last night which I wonder if it is possible to do in a SF shader.
    Is it possible to increase/decrease the uv tiling based on mip levels or distance from the camera? This would be very beneficial in reducing the tiling look from far away.

    thanks :)
     
  43. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620
    Color1 -> Lerp Top
    Color2 -> Lerp Middle
    Time * Speed -> Sin -> Lerp Bottom
     
  44. DSebJ

    DSebJ

    Joined:
    Mar 30, 2013
    Posts:
    101
    Yes that's what I'm trying. It's obvious how to do this if I could use a couple of if statements but I'm unsure of what I should be looking at with the nodes available :)
     
  45. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294

    It would be possible, but quite hard to pull off using a single texture without stretching and/or other issues. It will most likely look really odd. You're probably better off linearly blending between two textures, one near and one far texture. You can use the view position node, distance node, and world position node, to check distances, and the Lerp node to interpolate between a near and a far texture :)
     
  46. DSebJ

    DSebJ

    Joined:
    Mar 30, 2013
    Posts:
    101
    Thanks Marco, that works perfectly! :)
     
  47. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Except that you may want a Remap node between the Sin and the Lerp node. Sin outputs values between -1 and 1, and Lerp is meant for reading values between 0 and 1. Make a Remap node (R+LMB) and configure it as: from[-1, 1] to [0,1], and then plug it into the T input of the Lerp node :)
     
  48. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I could add an object scale node, yeah. Unfortunately it won't be able to read non-uniform scaling, just uniform scaling.
     
  49. mandydark2

    mandydark2

    Joined:
    Aug 13, 2012
    Posts:
    17
    Hi dude

    I've been playing the new nodes and I've finally gotten the work I DephtBlend node, objects intersect and create transparency, very cool!

    For some reason I fail to make SceneDepth node to work.

    Maybe I'm using it wrong, Ccould you explain me if that node does the same functionality as the PixelDeph the UDK?
    Simply I want to do is the object becomes more transparent as the camera approached him, like be walking into the fog.

    Thanks!
     
  50. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    Scene Depth is the distance from the object to the background. You want the distance from the object to the camera, which can be done using the world position node and the view position node, along with a few others. In this example, it's used for fading an additively blended shader: