Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Strumpy Shader Editor [Now Open Source]

Discussion in 'Works In Progress - Archive' started by Tim-C, Aug 2, 2010.

  1. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    Just a suggestion that might be silly cause I yet dont even master the shaders related stuff, but... could in the preview be shown some kind of parameter-number-leter that shows how good-bad is the performance of the shader we've just invented?
     
  2. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Because of how surface shaders are generated, you need to be able to access the compiled shaders to see how many instructions they actually consume, something which, while you can manually access, is not exposed to be automatically analyzed (In contrast to, say, the Unreal Material Editor, which apparently reports the instruction counts)

    To further complicate things, because the shaders can compiled to vs*/ps* GLES ARBfs/vs and/or GLSL, the actual instruction counts vary (GLES and GLSL in particular, since they are compiled by the end-users hardware)- It also doesn't help that not all instructions operate at the same speeds.

    A basic guide though, would have the cost of operations as such (least to greatest)

    Code (csharp):
    1. Swizzle
    2. Add, Multiply, Subtract, Exp2
    3. Dot, Cross
    4. Lerp
    5. Divide
    6. Smoothstep
    7. Reflect
    8. frac
    9. fmod
    10. Sign, Any, All, Abs, Step
    11. Min/Max
    12. Saturate
    13. Clamp
    14. Sqrt, RSqrt, Normalize
    15. Log, Sin, Cos, SinCos (It's about the same to get both sin/cos from the same value)
    16. Distance, Length (They are very close in cost)
    17. Texture Read
    18. Dependent Texture Read
    The actual differences in cost between any of these increase with progressively newer graphics cards- Where on older hardware it was generally advantageous to use textures as lookup tables, you can now generally get away with calculating allot of that information on spot.

    If you really want to get into the cost differences between functions, you need to keep in mind that HLSL/CG were modeled after the C programming language and higher level functions, making allot of people forget that it compiles down to assembly-like languages. For those, Unity uses ARBfp or PS_2 (or PS_3_0, though that adds nothing new supported by CG)

    The CG compiler does allot of optimizing for you, and I've done a fair bit of checking with how it actually compiles the generated programs out- The only things you ever have to be wary of are, since the shader editor uses a float4 structure, mistakenly performing operations in four dimensions rather then an intended three, which can easily be rectified using the mask node (That this works impresses me of the CG compiler honestly), or by manually editing the generated shader to remove the ambiguity.
     
  3. capnbubs

    capnbubs

    Joined:
    Jan 26, 2009
    Posts:
    85
    Thanks Texel, that will help a lot.
     
  4. loken

    loken

    Joined:
    Mar 25, 2009
    Posts:
    109
    As someone who has almost no experience writing shaders, I have to say this addon has offered great insight into how they actually work. It's been a ton of fun.

    A couple of questions though.

    1. How are fallback shaders handled? If things go wonky on a computer of lesser graphics capability, does the engine just push things to the vertex lit path? Will there be any nodes to handle different fallback scenarios?

    2. Any plans to make this useful for post-processing effects?
     
  5. capnbubs

    capnbubs

    Joined:
    Jan 26, 2009
    Posts:
    85
    I implemented the extra fixes that you suggested Texel, but I still have a very strange problem with the direction the light appears to be hitting the normalmap.

    The direction that light appears to be coming from seems to gradually change across my surfaces, is this something to do with the way I am using the world position to create my UVs?

    It's happening over very large distances, I guess about a 90 degree shift in the lighting direction over a few hundred distance units, but it seems random and I can't work out a pattern.

    If I just knew what was causing it I might be able to fix it myself.

    [edit]:

    On further examination it appears that the light may just be coming from a direction 90degree to the side of the light source.
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Is that massive sized surface reasonably subdivided?
     
  7. capnbubs

    capnbubs

    Joined:
    Jan 26, 2009
    Posts:
    85
    Yes, plenty of polys and it lights fine, the problem only arises with the normal maps. The surfaces appear to be lit fine from a distance when you can't make out the normal mapped lighting.

    [edit]

    Here's an example:



    Notice the shadow from the directional light, then look at the direction the rocks on the floor texture are being lit. It's almost as if they are being lit from the left but the directional light is the only light in the scene.
     
  8. Pulov

    Pulov

    Joined:
    Feb 20, 2010
    Posts:
    824
    @Texel
    MMM I see that it seems quite complex with such many posible paths and so many variables to monitor evaluate but after all they all come out on to a unique window wich is the preview.

    So may be using the FPS there could be obtained a number betwen 1-10 to evaluate its efficiency.

    10 is the performance with fo 500 spheres with just a texture shader and the rest of values is an interpolation obtained from the fps you get with 500 spheres with your shader.

    Just a cheap idea, may be works may be is stupid... dunno__>
     
  9. capnbubs

    capnbubs

    Joined:
    Jan 26, 2009
    Posts:
    85
    Ok it's definately something to do with using worldPosition as my coordinates for the texture mapping.

    I tried UV mapping the mesh and the bumpmap works just fine using the premade UVs.

    [edit]

    I may have found the problem, looks like I may have had my x and z the wrong way round in one of my Swizzles =D

    [edit]

    So I fixed the ground normals, but now the cliffs are driving me mad!

    [edit]

    I've come to the conclusion that I'm way out of my league with this, I loaded up texel's triplanar advanced example and even on that the lighting direction on the normal maps is all over the place.

    I'll probably keep trying to fix it but since I don't really know what is causing the problem I'm just using trial and error.

    If anybody has any ideas please let me know =]
     
  10. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    The preview attempts to render at 33hz, but because the whole window has to re-render each update almost all of the time in preview rendering is actually rendering the graph. So while it would represent complexity, it would more be just the number of nodes you used, not the cost.

    Capnbubs, to be honest, before you even mentioned reversed normals I never noticed, as I've only used the technique with shallow homogenous textures. It would likely end up being much clearer in code, rather then by nodes, as opposed to many other effects, because of how redundant it can be. I'll have to look at it more to see what I can find. If you send me your graph file, I will certainly take a look at it.

    (Alternatively, it may be a problem with the tangent/binormal generation? Try compiling with #pragma debug and #pragma glsl_no_optimize and looking at the GLSL program to see if that clears anything up)
     
  11. capnbubs

    capnbubs

    Joined:
    Jan 26, 2009
    Posts:
    85
    I think I've actually found the problem now, I still need to do some tests to make sure but I think I'm getting problems because the model is rotated to fix the Y axis. I didn't realise but when mapping the texture in this way rotating the object messes with the normals in a weird way.

    I'm going to try fixing it now and I'll report back if it works.

    Thanks for the help so far.

    [edit]

    Alright, I found out the problem is being caused because the normal maps require a tangent which they get from the UV map?

    I don't know much about how normal maps work beyond the basics. Creating a UV map from directly above seems to have worked for the top projection texture.
     
  12. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Beta 2.2
    Some features some bug fixes.



    Contributers
    Stramit
    Texel

    Documentation
    Remember to check out Texel's documentation here.

    Features
    Comments can now be added to nodes. Each node has a comment section it it's properties. Comments can be toggled by the checkbox on the bottom bar.

    Changelog:
    - Update preview renderer to use correct sin / cos time
    - Update node drawer to be able to toggle comments
    - Fix for broken behavior of SinTime Node, causing compiler failures
    - Draw errors and comments with GUIBox to cut down on GUILayout expense.
    - Fix preview backdrop rendering in front of mesh when using deferred rendering pipeline in editor
    - Added comments feature (Yay!)
    - New Connections are now beizier
    - Right click context menu drops properly when scrolled

    Asking for help with shaders
    Someone said earlier that they didn't feel this was the place to ask about specific shaders made with the editor... We disagree. If you are using this editor and would like some assistance post away. If you would like something explained, post away. Just remember that the best way to get help is to paste a screenshot / sgraph file of what you need help with and be as explicit as possible!

    We want this tool to be as usable as possible so any / all feedback is welcome!
     

    Attached Files:

  13. priceap

    priceap

    Joined:
    Apr 18, 2009
    Posts:
    274
    Hi -
    First: Fantastic Visual Shader Editor! - thank you for the amazing community contribution!

    Question: I have attached a screenshot to show what I am going for, which is to introduce a color into the limb of the lighting on the surface. This would be for a fake-sss kind of effect, or for a skin shader - which I know there is already a great one for unity, but I was just trying to figure out how to do this in your shader editor.

    I set the main color to black to show only the emissive limb lighting - mainly because it does not match up with the preset light sources in the preview. As you can see at the far right, I am manually setting a vector for the position of a light, which could be set during run-time by a script I suppose, but it would not take into account multiple lights in this case.

    The question is - how would you acquire the light model information in order to ramp through colors so that you could create things like this (or toon shaders, etc.) based on the multiple light positions in the scene? (I have done this in Maya or MentalMill by being able to add a shading model node upstream in the graph.)

    Sorry for not knowing the correct terminology.

    thanks!
     

    Attached Files:

  14. ForceX

    ForceX

    Joined:
    Jun 22, 2010
    Posts:
    1,102
    WOW 2.2b is just amazing. Thanks for creating this.

    In the display window in the bottom left. Is there a way to move the object u,d,l,r? When i import a custom model that has it's world pivot located at it feet. The model goes out side the box and i cant move it to bring the entire model into view.

    Thanks again :)
     
  15. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    @priceap

    With Unity3, for the deferred shading model the lighting are calculated separately, and as such that kind of effect is sadly out. If you open the exported shader, you can do some modification of the lighting model inside that (for effects like toon, anisotropic, or stepped lighting).

    @ForceX

    The preview scaling and position is all automatic, there are no existing controls for panning the view- the pivot is a mistake though, handling of the offset slipped at some point, should be fixed next release.
     
  16. WarpedAxiom

    WarpedAxiom

    Joined:
    Oct 27, 2006
    Posts:
    245
    On the topic of the TriPlanar shader – which we are no longer on – does anyone else get an unsightly sort of line running across the geometry wherever the texture repeats? Oh, if only this could be fixed... what wonderful things a man might do...
     
  17. priceap

    priceap

    Joined:
    Apr 18, 2009
    Posts:
    274
    Thanks for the reply, Texel.
    I opened the exported shader code, and like code from other editors like mentalMill, the first thought is to work from scratch rather than weed through the dense output - but not to be knocking it at all.

    It is just a thought, but maybe the "Master" node could be treated as not the final (or inaccessible) stage, but some means to remap what is being calculated within it from the albedo or specular, etc.. I think a lot of interesting shader effects could be achieved this way, such as ambient lighting effects opposite light sources, stepped lighting (thanks for the term), sketch/texture stepped effects, bounced-light-patterns, etc., all of which rely on the lighting model as a base from which to calculate new results.

     
  18. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Hey priceap,

    The plan in future will to be allow custom lighting algorithms to be used. This will include custom output structures (within the limits of unity, some things are expected to be there like normal ect) and lots of good stuff like that. I am still trying to figure out the best way to implement this kind of thing and it won't be in the next major beta release, but there are definitely plans for this to be done!
     
  19. priceap

    priceap

    Joined:
    Apr 18, 2009
    Posts:
    274
    Thanks for the reply and info, Stramit -
    The continued development plans sound exciting. It made me go back and open up MentalMill again to be sure I remembered how it worked, and I also did a similar thing with Maya in its Hypershade editor. I know there is tons of behind the scene work that would have to be done to implement such a thing, but I thought I would post the pretty pictures of how the interface does it. In both of these cases, the user can add a shading model (in this case a phong) and then actually take the outputs from that and manipulate them further. In the case of mentalMill, the simple example uses the diffuse (albedo) as an input for a lerp between two colors, and then the same with the specular, and then adds the two together. The flow goes left to right, and the final result in the shader is the ouput of the "Math Color Add" node (rather than the phong node!). Similarly in Maya, the combined diffuse and specular is clamped 0-1 and used to set the v-coordinate position of a very handy ramp node in which the user could set the colors or even insert textures, or whatever, and this is then output on a "surfaceShader" node.

    While playing with your SSE interface, I have tried imagining how it could work in a similar way, but not depart from the system you are already developing. I am not sure what would work best, but one thought was about being able to switch an option on the Master node in the details box, which could open up connections on the left side of the node, making the channels outputs as well as inputs. But of course, its totally up to the masters programming this excellent tool!

    thanks
    alan



     

    Attached Files:

  20. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    man, this is a dream come true...i was going to start developing a game inside of unity and this is PERFECT...i am not necessarily a programmer, but with this shader editor, I can quickly texture my models just like I do in XSI and focus on the games look and feel...

    Don't have Unity beta...:( (still on Unity 2.6) but I would love to add a suggestion of creating a node that will allow an object to have two different colours on the front and back... example the front would be red and the back would be blue. This would be awesome for stuff like long coats, very similar to the Front-Back switch node in XSI. And it would also save me polygons so i don't have to physically model thickness for a character's free flowing robe and i can just texture it.

    And I am already aware that with Normal Mapping, this could be difficult.

    But again...kudos...and i can't wait to play with this...
     
  21. overhill

    overhill

    Joined:
    Jun 18, 2010
    Posts:
    6
    I was missing this so much in unity after using udk for a while.

    This is pure awesomeness.
     
  22. kattkieru

    kattkieru

    Joined:
    Jan 2, 2006
    Posts:
    130
    This is unbelievable. :) I wish I weren't so swamped at work; I'd love to give this a serious go.

    I've read the thread, so while I hope these questions haven't already been answered I don't remember seeing them:

    - Is it possible to sample baked lightmaps using your shader to light characters? I saw a neat trick earlier this year where there were no actual lights in the scene, but the shader on the character sampled the level's overall lightmap for illumination and it worked surprisingly well.

    - Is it possible to inject code functions into your shader tree somehow? The nice thing about a tool like this would be the ability to save on texture ram by doing some shaders through pure math (voronoi crackles come to mind).

    As a side note, I was just wondering: Did you just start writing this cold, or did you see a writeup somewhere on how to make node-based shading systems? I'm quite interested in writing my own -- not for Unity, but for Renderman-compliant renderers -- and while nodes and connections are fine I've never quite gotten code generation working in my head, let alone as an app. :)

    Seriously, thanks for all your hard work. I fifth the notion of Unity buying this from you and making it an official part of U3. :)
     
  23. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    When the custom lighting graphs are implemented you will able achieve what you want (and hopefully more). It won't be quite like how you described but it should be pretty ace ;)

    This would require some major voodoo with knowing which lightmap you were closest to. Unity does not provide this data to the material system so we can't figure that out. Beast supports light environment volumes for having global / bounce lighting effect dynamic objects but this is not implemented in unity yet. Maybe in 3.1?

    In the back end it is possible, but it is currently not exposed at the user level. This is something that will probably get promoted to user land in the next release or the one after.

    Yep, started writing it cold. It took about 3 weeks to put beta 1 together of coding for 2/3 hours in the evenings after work. I built it based on what I knew about shaders and lexical parsing / tree building (for compilers ect). There was no real resource available to read from and I made mistakes and had to backtrack and refactor parts of the code as I did the implementation.

    Thanks for the kind words. I am really happy with how the editor is going and would love to see more people use it!
     
  24. Per

    Per

    Joined:
    Jun 25, 2009
    Posts:
    460
    Is there any possibility of an option to flip the sheet/nodes horizontally. I'm used to a left to right nodes approach, with upstream being left, downstream being right, the final result coming out as the last node on the right.
     
  25. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    While on the code end, I found it's rather simple to perform the flip, but there is a technical restriction involving the way we draw the node scroll area- because of how Unity draws the scroll view, things break when we start pushing negative coordinates in (there seems to be some miscalculation with the scrollbar ranges)- I'd experimented with this previously, but found I continuously lost nodes or had an incomplete scroll range when I pushed nodes to the left, rather then the right (This is why you can't expand the area by dragging nodes off the lefthand side)

    With that said, we are already planning on switching from GUILayout commands to direct GUI, which may make it more feasible. Having tried a few different layouts, I'm curious any other ideas/options you have to make the layout more comfortable or usable.
     
  26. Clamps

    Clamps

    Joined:
    Nov 7, 2009
    Posts:
    220
    Hi all,

    I don't suppose anyone here would know how to make a shader that uses 1 texture to mask between two others?
    So that one could have bricks, masked by an image that is the mortar... and then from behind that mask one can see a 3rd image (grass or whatnot)?
    Obviously the mask might be an alpha from one of the two other textures, but the important thing is masking between them.
     
  27. Westmark

    Westmark

    Joined:
    Nov 1, 2009
    Posts:
    187
    Hi Clamps

    you can use lerp for that. :)
     
  28. Clamps

    Clamps

    Joined:
    Nov 7, 2009
    Posts:
    220
    Thanks for the tip. Now I know what LERP does. :D
     
  29. Westmark

    Westmark

    Joined:
    Nov 1, 2009
    Posts:
    187
    hehe no problem :D
     
  30. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Update on Beta 3.0

    Features
    - Custom lighting (for both prepass / forward)
    - Vertex Position modification
    - Multi-select nodes
    - Drag select nodes

    Been pretty busy lately but hoping for the first of second week of October.
     
  31. Westmark

    Westmark

    Joined:
    Nov 1, 2009
    Posts:
    187
    Uhh sounds nice :D

    I'm really looking forward to vertex manipulation :D
     
  32. maxfax2009

    maxfax2009

    Joined:
    Feb 4, 2009
    Posts:
    410
    Looking forward to:

    - Custom lighting (for both prepass / forward)
    - Vertex Position modification

    Your editor is the best add-on to Unity of all time, GREAT work.
     
  33. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    537
    where is beta 3.0?

    i can't wait to try.
     
  34. langju

    langju

    Joined:
    Jul 1, 2009
    Posts:
    207
    Yes this is a real great tool !!!

    So, i cannot wait to try the vertex transformation :)
     
  35. WarpedAxiom

    WarpedAxiom

    Joined:
    Oct 27, 2006
    Posts:
    245
    Since no one responded to my question, I thought I'd back it up with photographic evidence.

    This is the TriPlanar example graph, unaltered, in action. All I've done is export it and used it with a material. Notice the pixellated lines running across the surface? Can this be fixed?
     
  36. FierceForm

    FierceForm

    Joined:
    Jun 25, 2010
    Posts:
    124
    Hi,

    I'm getting a compiler error when using the following graph.

    http://dl.dropbox.com/u/3838396/ProducesCompilerError.sgraph

    Pretty much, as suggested by Texel, I take the R channel from a texture map, saturate it, then use the Any function and put it into the clip channel, and it returns an error. This code was supposed to clip the texture based on whether the R channel is 1 or not, so I could use some DexSoft models the way I received them.

    Thanks,

    Christian Howe
     
  37. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    I took the shader as given and it compiled properly for me on OSX with the 2.2 version of the shader editor. What version of the shader editor are you using, what is the error that appears on compilation, and are you on windows or osx?

    As an aside that shader probably isn't doing exactly what you want. The way clip works is that any value LESS then 0 is clipped. So if the r channel is 0, the pixel will still exist. I tweaked the shader a bit, to apply a small subtraction to the incoming value (0.1 float constant), this will make anything roughly less then 0.1 be clipped.



    In addition to this you do not need the any node because as you are have already splatted one component to all channels, they will all be the same value :D

    If you are on windows, removing the 'any' node might fix the issue. I have not tried that node on windows. Also try upping the shader model to 3.0 instead of 2.0 in the master node configuration. If any of this works can you let me know, but also give me the error you were receiving before, I'll code in some error detection for this case then.
     
  38. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    I'll have to get Texel to respond to you as he wrote this shader. It might be an unfortunate limitation of the algorithm though.
     
  39. SquaxShaun

    SquaxShaun

    Joined:
    Jun 22, 2009
    Posts:
    63
    I just got round to checking this out, and it's awesome :D Thanks guys
     
  40. FierceForm

    FierceForm

    Joined:
    Jun 25, 2010
    Posts:
    124
    I removed the Any node with the same results. I'm using SM3 on Windows, with the editor version 2.2 and Unity 3.0f4. I think it has to do with the saturation, since the error refers to _sat. About the clipping, I knew that, I just never got that far because of the error. =P

    Here is the error.

    Code (csharp):
    1.  
    2. Shader error in 'ShaderEditor/EditorShaderCache': D3D shader assembly failed with: (26): error X5911: _sat not permitted on tex* instructions.
    3.  
    4. Shader Assembly: ps_3_0
    5. ; 22 ALU, 4 TEX
    6. dcl_2d s0
    7. dcl_2d s1
    8. dcl_2d s2
    9. dcl_2d s3
    10. def c1, 0.00000000, 1.00000000, -0.01000000, 2.00000000
    11. def c2, 2.00000000, -1.00000000, 0, 0
    12. dcl_texcoord0 v0
    13. dcl_texcoord1 v1.xy
    14. dcl_texcoord2 v2.xyz
    15. dcl_texcoord4 v4.xy
    16. texld r0.yw, v0.zwzw, s1
    17. mad_pp r0.xy, r0.wyzw, c2.x, c2.y
    18. mul_pp r0.w, r0.y, r0.y
    19. mad_pp r0.w, -r0.x, r0.x, -r0
    20. add_pp r0.w, r0, c1.y
    21. rsq_pp r1.x, r0.w
    22. mov r0.w, r0.z
    23. rcp_pp r0.z, r1.x
    24. dp4 r0.w, r0, r0
    25. rsq r0.w, r0.w
    26. mul r0.xyz, r0.w, r0
    27. dp3_pp r0.x, r0, v2
    28. max_pp r0.y, r0.x, c1.x
    29. texld_sat r0.x, v1, s2
    30. texld r1.xyz, v0, s0
    31. abs r0.x, r0
    32. mul r1.xyz, r1, c0
    33. texld r0.w, v4, s3
    34. cmp r0.x, -r0, c1, c1.y
    35. mul r1.xyz, r1, r0.y
    36. add_pp_sat r0.y, r0.x, r0.x
    37. add_pp_sat r0.y, r0, r0.x
    38. mul_pp r0.z, r0.w, c1.w
    39. add_pp_sat r0.x, r0.y, r0
    40. mul oC0.xyz, r1, r0.z
    41. add oC0.w, r0.x, c1.z
    42.  
    43. UnityEditor.AssetDatabase:ImportAsset(String, ImportAssetOptions)
    44. StrumpyShaderEditor.NodeEditor:Update(EditorWindow)
    45. NodeEditorWindow:Update() (at Assets/Editor/ShaderEditorScripts/NodeEditorWindow.cs:20)
    46. UnityEditor.EditorApplication:Internal_CallUpdateFunctions()
    47.  
     
  41. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    I've looked through the thread and perhaps could be having a blind moment but how do I add shadows to the shader?
     
  42. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    You are right. I just had a look over this in windows and it looks like it is a shader compiler bug, and I have raised the issue here. But there is a workaround you can use until this is fixed. Instead of using saturate, you can use a clamp node with 0 being start and 0.9999999 (any more 9's then this and the compiler will treat it as 1, and saturate will be implicitly used).

    Using the workaround in a shader graph


    Hi ZachGriffin.

    In Unity 3 surface shaders shadows are implicit (i.e built in). You have to configure your game objects / world to work with shadows and it should 'just work'. Have a look in the unity manual at the beast lightmapper and the dynamic shadow sections and it will explain how to set it up!
     
    Last edited: Sep 26, 2010
  43. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    Thanks for your response Stramit. After checking the built-in shaders I had a feeling that might have been the case. I have shadows working with all the objects using the built-in shaders but nothing on the shader I made using the editor. I've attached the flow graph below for a basic splatting shader; do I need to assign the albedo and alpha slots for them to work?

     
    Last edited: Sep 26, 2010
  44. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    Aint that a graph :p you should try and divide it up a bit more an add some comments to the nodes to describe what is happening. In beta 3 you will be able to multi select nodes to move groups around, so it might be better to wait for it's release before tidying up the graph.

    Anyway to your question:

    The best way to think of shadows is as area where light is being occluded, and this means that for a shadow to appear on a surface there has to be some lighting that takes place on the surface (i.e interaction with lights). If you are just using emission then there is no consideration of illumination form lights taking place on the surface, as the surface is generating it's own light. An emission object can still cast shadows though. To be straight up, you will need to write to the albedo, or specular channels if you want an object to receive shadows.

    Emission sphere - casts, but does not receive shadows


    'Normal' sphere - casts and receives shadows


    (Can you tell I didn't configure the shadowing at all :p)
     
    Last edited: Sep 26, 2010
  45. ZachGriffin

    ZachGriffin

    Joined:
    Apr 1, 2010
    Posts:
    49
    I appreciate the help Stramit! The albedo slot did the trick. I'm used to albedo being the amount of reflection and not the diffuse colour. I'm nearly there converting all the shaders I wrote for 2.6 and trying to get it looking the same: Two more questions while I have you here: Do I need to manually write in the parallaxOffset function after I export or is it in there? How do I enable the sampler2D to take the tiling and offset into account?
     
    Last edited: Sep 26, 2010
  46. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    That game's looking mighty fine there!

    As to your questions:
    1) Beta 3 will have a offset sample function (parallax), I just didn't get around to writing one for beta 2.2. Until then you will have to manually do it.

    2) If you want to use unity's built in scaling / offset you can set that in the material properties. It is not configurable at the moment for the preview though (is this where you are trying to do it)? If you don't want to use unity's built in you can do it by multiplying / offsetting the uv you are passing into the texture sample node.
     
  47. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,627
    Quick feedback:

    1) Your shader editor is all kinds of awesome :D

    2) Can you map "Update Shader" to the F5 key? It seems to make sense. Also rename it to "Refresh Shader" so people can guess the f5 shortcut on their own.

    3) This probably needs some discussion with other users too, but, I don't really like the way node connection is happening. I mean the click, move and click again. Maybe I'm used to other node editors, but Hold Down -> Drag -> Release seems less cumbersome to me.

    4) While the previous one is up for discussion, this one isn't. Why can't I drag any of the sliders? (in range nodes etc).

    5) Why is the flow right to left? I actually don't mind this, somehow it made sense, just wanted to ask.

    6) Multiple selections? I wanted to delete a bunch of nodes at a point and selecting them one by one was kind of a pain. Although some kind of lasso selection or something is not going to be that easy to implement (I guess).

    7) It needs more shader graph examples and more complicated ones. So someone can study them and figure out how to do things.

    That's all.... For now! :) Great job
     
  48. asteins

    asteins

    Joined:
    Sep 21, 2010
    Posts:
    2
    Downloading... thanks a lot, looks realy promising!
     
  49. therobear

    therobear

    Joined:
    Sep 28, 2010
    Posts:
    22
  50. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,627
    While we should wait for an answer from stramit, yeah I think preview is not supported on unity.