Search Unity

Strumpy Shader Editor [Now Open Source]

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

  1. Deleted User

    Deleted User

    Guest

    dreamora: that's true, but still there are some main functions which can be used for opengl es 2.0
    Ninja, created with strumpy a pseudo bump effect for iOS .

    and if there where a iOS button in strumpy editor, which switches to only Opengl ES2.0 functions that would be a great thing. =D
     
  2. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    By Inspector I meant the Unity material inspector.

    I doublechecked, I had no duplicate shader name, and I am pretty sure the names I exported under (test1, test2, etc) were valid.

    Thus far, I have not found a way to duplicate the issue I was having; I have created a new project and recreated the shader from scratch and all is good. I retried importing a previous sgraph and exporting a shader with it in the new project folder, works fine. Must have been a fluke.

    Incidentally, when I export the shader to my Assets folder, I get a dialog that says 'It is not recommended to store your XCode project inside your Unity Assets folder, since this could lead to a damaged Unity Project. Are you sure you want to continue? Choose Cancel if you are unsure.'- is this normal or not? since I am not exporting anything from XCode nor am I saving XCode files into the Assets folder, it seems...odd.
     
  3. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Also, is there a node for comparative (If) statements? I am trying to duplicate a UDK graph, there is a node called 'If'; it has 5 inputs, (A, B, A>B, A=B, A<B) and a single output. Is there a node to compare to 'Camera Vector' and 'Reflection Vector'?
     
  4. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    he made a bumpy iOS shader, but from what I can tell, he has not actually tested it on device. I can tell you, because I only develop for iOS, that if you need custom lighting (cell shading) at least right now, it may look fine in the editor, but you get errors on the device.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    That and the other point is: I thought you wanted 30FPS, not 10FPS and that is what happens rather fast if you use pixel lighting which you basically need to to make any reasonable use of surface shaders.
    Keep in mind, surface shaders are by definition about surface <-> light interaction, if you don't have pixel lights, they are not serving much use, doing straight cg or even better GLSL will do the same job with much less code and thus significantly higher performance

    Surf shaders are great for consoles and desktop where you have the needed bandwidth, fillrate and raw calculation power but for mobiles its like using a cruise missile to hit the bullseye on a dart board.
     
  6. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Just as a simple test, I loaded the included Rim Light graph and put it up on my 4G Ipod Touch...and the output is as follows:



    As you can see, it seems that either A) SSE needs some work in supporting GLES 2.0 or B) the hardware is not in fact using GLES 2.0 with SSE output shaders. I'm voting for option A, as you can use any of the Unity included pixel shaders (such as BumpedSpecDiffuse) and they work:



    Give him time guys, I am sure he is aware of how bad we want iOS support, and I am sure it is no small thing to get it in there.
     
    Last edited: Dec 20, 2010
  7. Deleted User

    Deleted User

    Guest

    dreamora: but what about the RNM tricks?
    i just see results and i want to be able to rebuild these with a nodesystem like strumpy. =)

    3D Ninja did this for IOS with Strumpy

    and Geenz did the RNM stuff for iOS
     
    Last edited by a moderator: Dec 20, 2010
  8. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    After 3.2 iOS is the next big thing on my list. It makes me a bit sad that the emulator and device are displaying different things :(
     
  9. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Me too, but I would seriously pay you for this tool just so I dont have to learn yet another programming language, too many stuffed into my head already along with 2.5 yrs of Fullsail Uni, need to reserve room for processing overhead :)
     
  10. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Not much to do about it unless:
    1. Apple no longer uses tile based gpus
    2. UT implements imagination technologies OpenGL ES Simulator for rendering
     
  11. Deleted User

    Deleted User

    Guest

    Forcing the subject brought me to this answer =)
    Cool - No i can sleep without having shader nightmares anymore! xP

    Without any doubt - i would pay for it too! definitely!!!!!
     
  12. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I noticed that SSE stops functioning (spams NullReferenceException) when I try to add a Matrix from the input, is this a known bug or something on my end? (I tried it with a blank graph)

    Kinda related, would using matrixes be possible to achieve RGB to HSV hue shifting? I know it is possible in SM3.0 without matrixes but I'm hoping it could get down under the limit for SM2.0, that might be far-fetched..

    (i found this online)

    Color TransformHSV(
    const Color &in, // color to transform
    float H, // hue shift (in degrees)
    float S, // saturation multiplier (scalar)
    float V // value multiplier (scalar)
    )
    {
    float VSU = V*S*cos(H*M_PI/180);
    float VSW = V*S*sin(H*M_PI/180);

    Color ret;
    ret.r = (.299*V+.701*VSU+.168*VSW)*in.r
    + (.587*V-.587*VSU+.330*VSW)*in.g
    + (.114*V-.114*VSU-.497*VSW)*in.b;
    ret.g = (.299*V-.299*VSU-.328*VSW)*in.r
    + (.587*V+.413*VSU+.035*VSW)*in.g
    + (.114*V-.114*VSU+.292*VSW)*in.b;
    ret.b = (.299*V-.3*VSU+1.25*VSW)*in.r
    + (.587*V-.588*VSU-1.05*VSW)*in.g
    + (.114*V+.886*VSU-.203*VSW)*in.b;
    return ret;
    }
     
  13. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Another poster discovered the matrix bug a few pages back. I've fixed it in the code base ;)

    As for RGB > HSV this might prove a bit more useful to you. The article says they do it in SM2.0. You can probably accomplish the same output using lerps instead of if's.
     
  14. dawg

    dawg

    Joined:
    Nov 15, 2010
    Posts:
    1
    First off I have to say I love this editor. I am using the Pro version 3.1 of Unity. I have already tackled a fairly troublesome multi-texture blend material and it works great. But I have encountered a really severe issue and I cannot figure out what is going on. I am getting the same error as gaustwick.

    "MissingReferenceException: The object of type 'Material' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    StrumpyShaderEditor.PreviewNode.RenderPreview ()
    StrumpyShaderEditor.NodeEditor.Update (UnityEditor.EditorWindow parent)
    NodeEditorWindow.Update () (at Assets/Editor/ShaderEditor/NodeEditorWindow.cs:22)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/GUI/DockArea.cs:212)
    UnityEditor.HostView.Invoke (System.String methodName) (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/GUI/DockArea.cs:205)
    UnityEditor.HostView.SendUpdate () (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/GUI/DockArea.cs:261)
    UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at E:/BuildAgent/work/71ca6fec1b41cc30/Editor/Mono/Generated/InternalUtility.cs:461)"


    when I open the editor it starts throwing this error and it kills my system performance. When I hit update shader it stops the error but I lose the material sphere and it throws a different error.

    "screenviewcoord[1] < 0 || screenviewcoord[3] < 0
    UnityEngine.Camera:Render()
    StrumpyShaderEditor.PreviewRenderer:Render(Mesh, Vector3, Quaternion, Camera, IEnumerable`1, Color, Material, RenderTexture, Boolean)
    StrumpyShaderEditor.PreviewNode:RenderPreview()
    StrumpyShaderEditor.NodeEditor:Update(EditorWindow)
    NodeEditorWindow:Update() (at Assets/Editor/ShaderEditor/NodeEditorWindow.cs:22)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()"

    At this point the material sphere seems to have disappeared. If I click and move any window (except the editor) the sphere shows up right in the middle. I have attached screen grabs of the 2 errors.
    $errorSreenShot.jpg $errorSceenShot2.jpg
     
  15. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    How would it be possible to convert this unreal 3 material?
     
  16. God-at-play

    God-at-play

    Joined:
    Nov 3, 2006
    Posts:
    330
    I've had the same issue as dawg. It seems to be caused by what the material settings of the material that gets loaded automatically. I can't remember how I fixed it, it was either naming the material or making sure the pixel shader wasn't blank, or something...
     
  17. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Dawg / God at play:

    Last week I managed to track down some issues with the way SSE was handling the preview material (it seems that unity sometimes decides that the material is no longer used... especially if you are clicking run scene and then stopping ect). What I have done is marked the material to never be destroyed. It should fix this issue and is in 3.2.
     
  18. no204

    no204

    Joined:
    May 27, 2010
    Posts:
    7
    Hello!

    I love this plugin, making shaders with this is simpe and fun. Thanks!
    But now, I wanted to remake the MatCap shader in the strumpy's editor, and I am failed. Im not a shader expert, cant read out much thing from the source. Tried to learn out the technique from several litsphere shading, environmentla mapping, projecting documentation, but with no succes. I have to realize, this is not my world. Basicly I had the idea in my mind, but I cant make it out.

    It would be very nice if somebody could help me, please!
    Thanks in advance.
     
  19. no204

    no204

    Joined:
    May 27, 2010
    Posts:
    7
    Lol, looks it works now :) Or at least, multiplying the normal with the view vector looking quite fine.
    New question (the previous one still stand, if somebody know a better method): if no normalmap attached to the shader, it not takes the vertex normal into work by itself, so the shader simply multiply by zero, resulting bad uv calc. So, how can I tell the shader in strumpy's editor to use the vertex normals, if no normalmap avaiable?
     
  20. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Anyone willing to help me figure out how to render shells and fins using SSE? I'd like to use it to try some NPR rendering techniques but am not sure where to start. I have code examples, but they dont really help me much: http://www.xbdev.net/directx3dx/specialX/Fur/index.php
     
  21. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    What particular part are you having problems with? "Can you make me a shader" type questions really aren't going to fly.
     
  22. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    I am having problems with the whole thing :)
    Naming schemes and functions look completely different between UDK and SSE aaand i dont even know where to start.
     
  23. duke

    duke

    Joined:
    Jan 10, 2007
    Posts:
    763
    I'm seeing constants, multiply nodes, a lerp or so. They're all in SSE.
     
  24. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hi Aubergine,

    SSE isn't the UDK editor and they are built on some differing principles (i.e. SSE maps to the unity surface shader model). If you look at the post where you found the download link there is a tutorial written by clamps about how he made his planet shader, and there is also a readme / introduction written by texel. These should help you get going. If you have any more specific questions I'll be happy to answer them.
     
  25. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    Would you kindly make a simple graph of 2 textures blending according to object vertex normals (if vertex is up and in defined angle limit blend the second one)
     
  26. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Here is a shader that will blend 2 textures based on world normal. If a normal is up in the y direction it will use texture 1 fully, if it is on the xz plane or negative y it will use texture 2. In between it will blend.
     

    Attached Files:

  27. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Hey does this editor works only for Unity Pro??? I cant see my preview cube, neither to put texture on somehow.
     
  28. devilkkw

    devilkkw

    Joined:
    Jun 24, 2009
    Posts:
    175
    like this,i'm a totally noob on the shader,and this extension give me help.
    what is correct way to create a reflective shader?
     
  29. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    AAAAAAAAA does it require Pro license?????
     
  30. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    The preview does, the generated shaders do not.
     
  31. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    But if it does not, how can i put my texture map into color, specular or any other input. I can make Color node but i cant see where to put texture in. Could someone explain on short how to put texture on node?
     
  32. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Hi Janpec, if I'm hearing you correctly, all you need to do is put the outputs of each into the inputs of a multiply node, then put the output of the multiply node into the Albedo channel.

    Also note that to use a texture, you'll need to use both a Sampler2D node and a Tex2D node and put the outputs of the Sampler2D node into the respective inputs of the Tex2D node.
     
  33. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Could you walk me over steps?
    I really really cannot find a way to input texture into shader editor. I cant even find a single selction picker for texture in any of nodes.
    Could you tell me simple what do you do to create custom diffuse shader with custom texture. Just what node you need to apply texture to it.
     
  34. NathanWarden

    NathanWarden

    Joined:
    Oct 4, 2005
    Posts:
    663
    Maybe I'm confused, are you just trying to get a texture in there so you can see it in the previewer?
     
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    First things first, have you looked at any of the documentation or included example shaders?
     
  36. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I looked documentation all over, however i didnt see any included shaders.
     
  37. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    If you click the load button there will be a list of example shaders that you can look at. They will help you understand how the system works.
     
  38. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I have looked into examples, and i still cant understand where to put texture in. I think its some sort of bug. I loaded Normal map shader, and when i click on Diffuse or NormalMap node there is nowehre texture input in details window. I am guessing it should be there a texture input right? Or is the name of node important so it load texture according to name? For example if i name Diffuse node - diffuse1, will it load diffuse1 texture from my project folder?
     
  39. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    I think you misunderstand... you use SSE to set up how the shader works (what kind of input it takes, textures, numbers for a calculation). Actually plugging the specific texture into the shader output by SSE is done in the material inspector in Unity:


    In SSE, name the Master node mySampleDiffuse.

    Right click, go to Input>Sampled2D, and click that.
    Left click and drag from the RGBA output of the Sampled2D node to Albedo.
    Optionally, click the Sampled2D node and name it something else (like DiffuseTex).

    Your result will look like this:



    Click the Export button in the SSE window, and save the shader in your project folder.

    Now, create a new material, and change the shader for that material to mySampleDiffuse. The inspector for the material will change, and should look like this:



    Now, you can pick a texture from the inspector as normal, and you're done.

    Hope this helps.
     
    Last edited: Jan 2, 2011
  40. wannabeartist

    wannabeartist

    Joined:
    Jun 20, 2009
    Posts:
    272
    Hi!

    Just starting out with this great tool!

    One question: When I hit update shader button on the default example, I get this warning:

    "There are inconsistent line endings in the 'Assets/Editor/ShaderEditor/Resources/Internal/Temp/TempShader.shader' script. Some are Mac OS X (UNIX) and some are Windows."

    Is there a way to prevent it or should I just ignore it?
     
  41. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Noradninja thank you so much for this extensive explanation. Seems like i was really searching at wrong end. I was really thinking of texture input same as it is done in UDKs mat editor.
    I have got it working now. Thank you again for explaining to me.
     
  42. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @noradninja - Excellent noob tutorial!
     
  43. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    This is covered i think 2 or 3 pages back in the thread.
     
    Last edited: Jan 2, 2011
  44. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    No problem guys.

    Incidentally, if you want normal maps, be sure to input the texture into Normal on the Master node, and switch the Default Texture on the Sampled2D node to normal.
     
  45. Skjalg

    Skjalg

    Joined:
    May 25, 2009
    Posts:
    211
    Hi there stramit.

    I was wondering if you had implemented zooming and if so, how did you do it? I'm struggling hard with manipulating the GUI.Matrix.
     
  46. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    We have not implemented zooming yet. We intend to either add zooming or a 'mini-map' sometime in the future.
     
  47. no204

    no204

    Joined:
    May 27, 2010
    Posts:
    7
    Hi guys!

    Please somebody help me to remake this shader with nodes! I tried to make this trough weeks but no succes yet...:(

    Thanks in advance!
     
  48. wesrm

    wesrm

    Joined:
    May 20, 2009
    Posts:
    193
    Hi,

    I can't seem to figure out how to use the sampler2D node UV set to have my color texture to use the first UV set on my mesh and my lightmap texture to use my mesh's 2nd UV set (lightmap UVs). I have two sampler2D nodes, each feeding into their own tex2D node with the UV parameters from the sampler2D nodes targeting their respective tex2D UV parameters. However, each sampler2D is still using the first UV set. I know I have this hooked up wrong, but I'm not sure how to fix it. Can some please let me know how to make a texture use the 2nd UV set?

    Thanks!
     
  49. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Easy! There is a MeshUV node. It has outputs for both UV1 and UV2. You still use a normal sampler node just don't hook up the UV output from it. The disadvantage of using a MeshUV node is that you don't get the 'nice' scaling and UV offsets that unity applies internally on the material, but it's very handy for what you are trying to do or if you are using too many vertex interpolators.
     
  50. wesrm

    wesrm

    Joined:
    May 20, 2009
    Posts:
    193
    Great! Thanks very much : )