Search Unity

Shader Forge - A visual, node-based shader editor

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

  1. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    This is actually pretty easy, and I apologize if I insult your experience level. I think what you are trying to do in convert what is a single float (0-1) noise result into two different ints (one for cols:__Pos_X and one for rows:__Pos_Y). The tricky unknown here is probably the modulus function (Arithmitic->Fmod).
    1) take the output of (noise result * 16) floor this and Divide by 4, and you have your row (__Pos_Y)
    2) take the output of (noise result * 16) floor this and Fmod by 4 and now you have your col (_Pos_X)

    I hope that helps as wasn't too confusing.
     
  2. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    Thanks for the quick response, and I don't go near shaders much so I don't really get a chance to learn too much about them.

    I have done what I think you meant, but it has tried to fit the 4x4 texture set into a 3x3 noise tile set (check screenshot).

    I have attached the "new" shader and hopefully it's just something stupid I am doing.
    ShaderCube.PNG
     

    Attached Files:

  3. Sinaz20

    Sinaz20

    Joined:
    Nov 16, 2009
    Posts:
    53
    Are we able to get the CameraGBufferTexture# textures into a Shader Forge post effect? If so, how?
     
  4. Deleted User

    Deleted User

    Guest

    Sorry for being late. Anyway this is happened because the asset only work with included unity 5 first person controller.

    P.S = On the collider of included controller, stay on a spherical shape instead of a capsule shape, that will ensure a better teleport transition (like on example scenes).
     
    Last edited by a moderator: Apr 5, 2016
  5. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    This works a lot better with the controller supplied, but in my own scene I placed 2 CircleGates (1 & 2 from Prefabs) and the character and I can't get the character to go through them, the player just collides with the inner face of the portal.
     
  6. Deleted User

    Deleted User

    Guest

    In this case verify if 'istrigger' flag is active on gates colliders, because this problem is generally caused by it. If the problem persist go a look into examples scenes (those mentioned in the previos comment), and make a comparison.

    P.S = Don't forgot to fill "Second Gate' variable on gate manager script of both prefabs (first gate with second gate and vice versa).

    P.P.S = I have found a quite serious bug of latest second (that I have forgot to fix), then to avoid problems, download again package from my previous comment.
     
    Last edited by a moderator: Mar 25, 2016
  7. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    The istrigger bool is ticked, in fact I cannot un-tick it, probably controlled by your script.
    I have filled in the secondGate variable in each of the gates, but I am still unable to walk between them, which I don't understand as the prefabs I am using were dragged in from the example scene which works.
     
  8. Deleted User

    Deleted User

    Guest

    Yes, for convenience 'istrigger' is controlled by my script. However at this point, I think that there is a problem on scene (if you said that all work correctly on example scene, even if I have unserstand well), because your problem is related to trigger event, and then to Unity.
     
    Last edited by a moderator: Mar 25, 2016
  9. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    I have rebuilt the example scene in one of my own scenes and it seems to be working, but when I collide with the gate, I get this error:

    The nearClipPlane of Main Camera is not equal to 0.01
    UnityEngine.Debug:LogError(Object)
    GateManager:OnTriggerStay(Collider) (at Assets/Gater/Scripts/GateManager.cs:351)

    My camera's near clipping plane is set to 0.01 despite the fact this is popping up, so I have no idea what is causing this to happen, any ideas?
     
  10. Deleted User

    Deleted User

    Guest

    Strange, try to check if clipping plane of your main camera (in this case those of character) is set to 0.01, or there is any script that change this value. In alternative try to check this value with a Debug.Log.
     
    Last edited by a moderator: Mar 26, 2016
  11. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    I don't suppose anyone had been able to take a look at this yet? I am still trying to get this working, but have had no luck yet.
    I am still getting the strange artifacts in the centre that look like Z-fighting, and the tiles still no not fit or scale correctly.
    Everything I try either gives me another problem or makes things a lot worse; the downside to not knowing enough about shaders or what I am doing :(

    I have been looking into this on Google but have found virtually nothing, it seems the only instance of this technique being used is in Portal, so there is almost no info on how it was done.
     
  12. elizeusz

    elizeusz

    Joined:
    May 2, 2012
    Posts:
    49
    Hello i have latest version of Unity and Shader Forge i get this error :
    Could not create a custom UI for the shader 'Shader Forge/SmokeShader'. The shader has the following: 'CustomEditor = ShaderForgeMaterialInspector'. Does the custom editor specified include its namespace? And does the class either derive from ShaderGUI or MaterialEditor?
    UnityEditor.DockArea:OnGUI() Can somebody help me with this ?
     
  13. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    @Acegikmo You posted on your forum a while back about triplanar setups, but I can't find anything about solving the normal map tangent-space issue.

    While waiting to see if anyone can help me with my main shader:
    I decided to create my secondary one for smaller objects (not the large environment areas such as walls which require the solution I am trying to get working above), but when I try to combine the normals, I get...well...strange results to say the least.

    It's like the normal maps have been flipped and merged or something along those lines.

    I have attached the shader to see if anyone can work out what I am going wrong.

    http://neatcorporation.com/forums/viewtopic.php?t=8
     

    Attached Files:

  14. Ulven2

    Ulven2

    Joined:
    Apr 23, 2012
    Posts:
    64
    I'm having a problem in ShaderForge when trying to make a replacement shader for the basic specular setup. If you make a 'Specular Mode' PBR shader, and then name the input SpecColor (to be in line with what Unity calls it and various amounts of code which manipulates this input), the shader does not compile properly.
    Shader error in 'Shader Forge/NewShader': undeclared identifier '_SpecColor_ST' at line 109 (on d3d11)
    Attached example shader of the problem
     

    Attached Files:

  15. Ravart

    Ravart

    Joined:
    Mar 9, 2011
    Posts:
    42
    Has someone a radar blueprint to share or ideas? Thanks
     
  16. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    Just an initial thought but I'd use a scaled fresnel to manage the radar "ping", but things like the dots that appear (items of interest/enemies etc) would have to be added in another way (scripted).
     
  17. Studio_Akiba

    Studio_Akiba

    Joined:
    Mar 3, 2014
    Posts:
    1,422
    @Acegikmo Are there any official/free tutorials on using the "post-processing" shaders on cameras?
     
  18. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Experimenting with RenderTextures and Vector Field maps :)

     
    kaimelis, ZJP, AdamGoodrich and 3 others like this.
  19. wolfen231

    wolfen231

    Joined:
    Apr 22, 2014
    Posts:
    402
    You could try this UDK tutorial on a radar material. Often (but not always) most all the nodes are the same.
     
  20. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    hello!
    There is a node in unreal engine called 'absolute world position'. This node looks like the same as the world position node in shader forge, except it comes with some options: Include material offset or exclude material offset.
    Now this is real magic, because if you do a triplanar setup it instantly fixes the 'not aligning problem' with displacement and projection.
    How can we do this in shader forge. Whenever I try to create a simple setup with planar projection on both diffuse and vertex offset and displace it along normal direction the two textures won't line up.
     
  21. Deleted User

    Deleted User

    Guest

    hopeful likes this.
  22. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Missing since January 31.2016.
    This is one of the most important assets (with NO competitor) in the Unity Galaxy. We are in trouble.
    Unity Technologies where is your native Shader Editor?.
     
    Deleted User likes this.
  23. Deleted User

    Deleted User

    Guest

    Unfortunately @Acegikmo has shifted his focus on VR (with "Budget Cuts" game - https://twitter.com/JoachimHolmer/status/717350473208967168). Then I not think that we will see a new ShaderForge version (or related other things) so early. The only useful thing that he did not do (but that was willing to do), was to expand the ShaderForge development team.
     
    Last edited by a moderator: Apr 5, 2016
  24. stationx

    stationx

    Joined:
    Jul 9, 2012
    Posts:
    251
    No offense, but this is why I completely dislike the asset store and the whole business model of Unity. If for whatever reason developers cannot maintain their asset anymore, you are totally stuck and left with an asset that you cannot use anymore. This is general the issue for most assets, not limited to shader forge.
     
    SpyChar and Deleted User like this.
  25. wolfen231

    wolfen231

    Joined:
    Apr 22, 2014
    Posts:
    402
    Report major bugs to his bug tracking. I believe he still does review it.
     
  26. Deleted User

    Deleted User

    Guest

    I totally agree, and ShaderForge is the asset put in the better conditions after all, others has been removed because were no longer updated for very long time, even if they were paid (Portalizer for example. Which it was one of the main reasons why I released my asset "Gater" free of charge).
     
    Last edited by a moderator: Apr 7, 2016
    wolfen231 likes this.
  27. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Made a smooth grass shader using RenderTexture component. It's incredibly light on performance since it doesn't do any computing with the grass meshes themselves and uses the terrain lighting as proxy. Also the grass is transparent and have soft edges rather than hard edged cutout shader. The scene doesn't drop below 70 fps. view it in HD

     
  28. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Wow, that looks stunning. Great work.
     
  29. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    SpyChar and wolfen231 like this.
  30. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    On the other hand, shaders from the asset store usually fill a need for customers for a year or two until Unity gets around to developing their own version. Unity users aren't required to buy anything from the store. They can make what they need themselves or wait for Unity to release the feature.
     
  31. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I apologize for suddenly disappearing on you all :(
    Budget Cuts, our VR project, is currently taking almost all the time I have, including spare time. There's very little time left for SF, which now mostly comes down to support rather than development.

    I've considered finding someone to maintain it, but even that's a big time sink in and of itself, not only to find someone, but also to guide that person in the code.

    Not sure if these are comforting words, but, we are using Shader Forge in the project at least, so if any Unity update breaks SF or if we need additional features or bugfixes, I'll get those fixed at least.

    Those of you who are helping people in this thread - I wouldn't be able to maintain this community on my own, massive thanks for being super helpful and posting cool stuff!
     
  32. unitywlp

    unitywlp

    Joined:
    Jan 3, 2014
    Posts:
    146
  33. wolfen231

    wolfen231

    Joined:
    Apr 22, 2014
    Posts:
    402
    Great to hear Acegikmo! Good luck with your Budget Cuts! Why does it sound like I am telling some one good luck with laying people off.... am I in a living Office Space scene now?
     
  34. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Hello shader forge forum, is there a way to uniformly increase emission to the whole model as an object is exposed to light? They are values of 0 to 1 afterall.


    And I want the emission to drop to 0 as the model gets completely dark.


    I have been trying it out as it seems simple, but it is more complicated than I thought.
    Thanks!
     
  35. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    The possible ways to do this 'correctly' are rediculous - how would you even decide how lit an object is? per pixel shown on screen? Per pixel from the lights' perspective?

    The dodgy way would be to raycast between the object (or several points on said object) to any lights that could affect them. So that's all directional lights, and any near point and spot lights. Then, in the script that controls the raycast/s, figure a way to compute that number (average over several casts, I dunno), then change the material's emission property.
     
  36. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I can't export iOS builds from windows man. Sorry about that :(
     
  37. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    Is there no way to obtain the average amount of light affecting it from the shader alone?

    I have thought of using raycast, but if possible, I would want to avoid it. Hence is why I seek for help here, in hope of perhaps, an experienced users around here would be wary of a more elegant workaround to this.
     
  38. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    I'm not sure what you're trying to achieve. Are you trying to create a slider that when dropped to zero will darken the whole mesh ?
     
  39. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Shaders work at the vertex and pixel level and they work on a single one at a time(graphics cards parallelize this but that's the basic explanation). You'd have to calculate the average outside of the shader and pass it in via a parameter and then work with that otherwise, all you have is the data at that particular vertex or pixel.
     
  40. IL4Mi3y

    IL4Mi3y

    Joined:
    Dec 29, 2014
    Posts:
    38
    Hi, can I export a shader from shader forge to get a normal shader that I can sell in a package on the asset store?
    Greetings.
     
  41. Gekigengar

    Gekigengar

    Joined:
    Jan 20, 2013
    Posts:
    738
    That, and the other way around too.

    It should shine brightly when exposed to light (Depending on its intensity).

    So I should create a script that would pass the input into a shader paremeter?

    If I used raycast to pass the distance as light exposure, that wouldn't be accurate.

    (For example, the character's body is blocked by a wall, but the hand is exposed to light.)

    And moreover, every single light source would be shooting raycast every update, which is pretty expensive processing wise to achieve.

    Or do you by chance have a more efficient way to do this?
    I would be glad if you could enlighten me some way! :D
     
    Last edited: Apr 8, 2016
  42. unitywlp

    unitywlp

    Joined:
    Jan 3, 2014
    Posts:
    146
    i am asking for android build
     
  43. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Oh. I might be able to get it back on monday but I don't have android SDK built on my Home PC.
     
  44. unitywlp

    unitywlp

    Joined:
    Jan 3, 2014
    Posts:
    146
    i am curious to know the fps and the draw calls and the poly count on avg
     
  45. Cactus_on_Fire

    Cactus_on_Fire

    Joined:
    Aug 12, 2014
    Posts:
    675
    Here you can see the stats in the up right corner. This scene has around 500K polygons - 1000Ktriangles. But I tested +2M polygon scenes and they don't drop below 60fps.

     
    Gekigengar, unitywlp and hopeful like this.
  46. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    Yep, I already do it.

    It's also best practice to mention shader forge compatibility (and version) on the asset store blurb, and to post screenshots in this thread.

    Obviously, you want to make sure you're not including shader forge in the asset, just the shaders. With the new asset store tools (a massive downgrade in my opinion) for me that means making the shaders in one project, and creating a new empty project, and pasting just the shaders in from the dev project for submission.
     
    IL4Mi3y likes this.
  47. Jesus

    Jesus

    Joined:
    Jul 12, 2010
    Posts:
    504
    In what can only be described as absolutely shocking, violent abuse of the vertex offset function, this entire terrain was built using Unity Cubes. Admittedly, lots of them.

    The height mapping was easy enough, just grab a texture in world position, then move everything up that high, not too difficult. Then find all the sides of the cubes, raise them above the ground, then stretch them in random directions and apply noise based masks on their V coordinates to cut out shapes for ground scatter, then scale that ground scatter based on 10 procedurally generated biomes (and then things like rock type, which also varies by biome and normals) handled within the shader. Then grab the bottom of the cubes, and flip them, position them just above ground and cut out rocks, dirt clumps, etc for a little parallax. Also, adjust the normals by height and slope, then add some custom low-poly-looking faceting in a triangular pattern.
    island720.png
    Then, the image effects. HDR, obviously, because who wouldn't. SSAO and Global Fog, then Bloom and Tonemapping. Edge Detection, AA and Vignetting, and Tilt Shift.
     
  48. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    I'm having some serious slow down issues that I'm fairly sure are SF related, as they just started happening after finishing implementing a terrain shader. I followed the wiki plus some other bits and pieces I've found around the place.

    A couple clues I have:
    1. Profiler shows "GPU: Other" taking up to 66ms, and repeatedly spikes between 16ms and 66ms.
    2. On Unity startup, I get two of these errors:
    Recursive Serialization is not supported. You can't dereference a PPtr while loading. (Constructors of C# classes may not load objects either eg. EditorGUIUtility.TextContent should be moved to OnEnable. See stacktrace.)
    UnityEditor.AssetDatabase:LoadAssetAtPath(String, Type)
    ShaderForge.SF_Resources:LoadInterfaceIcon(String)
    ShaderForge.SF_GUI:get_Icon()
    ShaderForge.SF_Editor:.ctor()
    UnityEditorInternal.InternalEditorUtility:LoadSerializedFileAndForget(String)
    UnityEditor.WindowLayout:LoadWindowLayout(String, Boolean)

    I tried running my game without the SF terrain shader attached to anything, but whether that should fix it or not I'm not sure. It didn't improve with it turned off, but turning my terrain object off did keep "other" under 8ms.

    *Just loaded default window layout and that seems to have fixed it(!?). Re-loaded the SF shader in the SF window, added it back to my terrain, opened and closed things a few more times but still not getting anything resembling the original huge slow down, just some less frequent, repeated spikes of 33ms, which aren't great obviously.

    Closing and re-opening Unity after the above find seems to no longer have the Recursive error either.

    Any ideas?
     
  49. IL4Mi3y

    IL4Mi3y

    Joined:
    Dec 29, 2014
    Posts:
    38
    I want to convert this shader to shader forge.
    http://trolltungakreative.com/Unity/LowPolyWaves2.shader

    I think it is not that difficult, but I can't handle the animation of the vertices. I don't know how to deal with it.
    I tried using a Time Node and do some stuff with sin-waves but I only get weird results.
    Can someone help me?
     
  50. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    I'm also curious, in regards to a terrain shader, I'm trying to fade the terrain slowly out into the distance to blend it with a 'distant terrain' object. To do this I'm mostly following the distance blend type examples (http://acegikmo.com/shaderforge/wiki/images/8/8a/DistanceBlend-InAction-Grass.png), and have gotten it working on a terrain with a very basic, single texture shader. However, when I try and copy paste that same node network into my terrain shader, then plug it into Opacity, there's no change. Tried on FirstPass and BasePass shaders with no luck.

    Also tried DepthBlend to see if I could get any opacity on overlapping geometry (just for the hell of it), still no luck.

    Do I need to do something with regards to the basemap or splat map or something like that? I'm also unsure if/when I need to recompile the terrain shaders (if at all?). Or maybe add another pass?

    Thanks for any help!