Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Strumpy Shader Editor [Now Open Source]

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

  1. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,500
    I had no trouble installing it in 3.4 Pro PC here.

    General question (or possible feature request):
    Is there any way to set your default starting folder for opening/saving files? It's a little annoying to have to keep navigating up to my sgraph folder each time I want to save/load a shader graph. (Not storing them in the default place SSE wants to store them).

    Great work on an awesome editor! Takes the fear out of shader writing!
     
  2. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi everyone,

    can anyone tell me how to get rid of the normal and tangent part of the vertex shader "VertexInputMaster"? I want to create a shader that only has position and vertex color. As for now, I apparently cannot remove those parts of hte vertex shader, is this right?

    Thanks for helping
     
  3. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    You should simply be able to ignore it- The compiler will (for the most part) remove what your not using. If your unsure if it was properly removed, you can try it both ways, and use the mouse-over from the instruction counter to see how large the vertex program comes out to.
     
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Package works fine if you import it into unity instead of double clicking it. My error. Seems pretty beefy and complex.
     
  5. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Thanks for the reply... I was a little bit confused by the Unity spill saying that the renderer was trying to fit in the tangents but couldn't find any.
     
  6. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    This is how I would tackle the problem:

    1) Add a vector 3 input to the shader (this will be the 'world position' you talked about)
    2) Translate the incoming position into world space (using a matrix transformation and this matrix _Object2World)
    3) Subtract the world vector from the world position and normalise (this will give the per vertex direction to the world position in world space)
    4) Translate this direction vector back into object space using _World2Object
    5) Take the raw vertex position and modify using this new direction vector.

    You'll need to write a script to pass this position in each frame.
     
  7. low_seb

    low_seb

    Joined:
    Jun 13, 2011
    Posts:
    76
    hello everyone

    thanks for gives us this great tools

    I need some advices for a ground shader

    my shader so far



    and the graph


    I have two question about this
    I like to add maybe two layer more ,how can reach this ,with the RGBA channel ?

    and I like to mix the normals channel with a global normal map channel (the entire ground) ,its possible?

    thanks by advance ,I am very noob at shader and I tried to reconsruct some shader used in 3ds max
     
  8. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    Looking good, if you want to add another layer you will need to add an extra texture (as I am sure you are aware!). I take it if you try and add another layer you will get an error about being out of interpolators. If some texture use the same UV's you should share the UV channels. This will free up more channels.

    If you want to add another layer it might make sense to have the r channel of the mask determine the amount of texture one, the g the amount of texture2, and the b the amount of texture 3. You could then add float multipliers to decide how much of each you want.
     
  9. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Wow, is that ground a mesh? Looks SICK... and I love the gems in the ground too...
     
  10. SvenEV

    SvenEV

    Joined:
    Jul 22, 2010
    Posts:
    4
    Hi,
    I would like to create some custom nodes and couldn't figure out how to write one yet. Is that possible? If yes, are there any hints or examples for that?
    Thanks in advance!

    EDIT: Okay, I found an earlier post in this thread and was able to create a custom node that returns 1 if two float4s are equal and 0 otherwise.
     
    Last edited: Aug 6, 2011
  11. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    This looks great and should be part of the Unity editor really. Well done!
     
  12. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey Stramit, I don't know if you are tried out the interactive cloth, but there is an issue with it where your surface is dulled to a point where it sticks out like a sore thumb... and perhaps in your next update, you could create a "hack" that allows the cloth to be lit correctly... :)
     
  13. podperson

    podperson

    Joined:
    Jun 6, 2006
    Posts:
    1,371
    I just found out about this, accidentally installed the second version (missed the 2010 ;-) ) and loved it, then installed the latest 4.0a and it broke, then figured out I needed to delete all the old files and reinstall and it worked fine (Unity 3.4 Mac). Very nice.

    My biggest wish would be support for creating fixed function shaders. I realize that surface shaders are sexy and all.

    Great stuff. Keep up the good work.
     
  14. warby

    warby

    Joined:
    Mar 23, 2009
    Posts:
    162
    has anyone successfully made an alpha transparent shader with sse ? because i cant figure out how to do it i tried making the simplest possible alpha shader and its not working:

    http://nopaste.info/b3338e8f28.html




    am i missing something ?
     
  15. ThermalFusion

    ThermalFusion

    Joined:
    May 1, 2011
    Posts:
    906
    @warby

    You will need to change the Blend Type to do full multileveled alpha blending, but you will most likely end up with sorting issues.

    If you want to make a cutout effect rather than semitransparent, add a subtraction node, plug the alpha into one of the arguments, and then either a constant ranging from 0.0 - 1.0, or a slider input with the same range.
     
  16. warby

    warby

    Joined:
    Mar 23, 2009
    Posts:
    162
    thanks man that helped ! :)

    i went through all of them earlier and could not tell any kind of difference i must have had some other issue in parallel at the time ( like wrong material on my object or something

    FIXED !
     
  17. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey everyone, I decided to take a moment to settle a shader I've been trying to work on...and it is a double sided shader for stuff like jackets, but the only problem I am running into is getting the normal maps working on both sides... I have the normal maps working for the front and not the back... is there a bit of code that will allow this behaviour? I do need a shader specifically designed for clothing that will be simulated...i tried to get away with having the backside black, but that is not acceptable.

    And it looks like I will have to set up my shaders so that they are truly double sided :)

    I was trying to set up the normal map in the custom channel, but that wasn't going to work...

    Any help would be appreciated. Thanks :) (the graph is included in this post)

    Code (csharp):
    1. Shader "NeptuneImaging/Front-BackShader"
    2. {
    3.     Properties
    4.     {
    5. _FrontDiffuse("_FrontDiffuse", 2D) = "gray" {}
    6. _BackDiffuse("_BackDiffuse", 2D) = "gray" {}
    7. _FrontNormalmap("_FrontNormalmap", 2D) = "gray" {}
    8. _BackNormalMap("_BackNormalMap", 2D) = "gray" {}
    9. _FrontGloss("_FrontGloss", 2D) = "black" {}
    10. _BackGloss("_BackGloss", 2D) = "black" {}
    11. _FrontSpecPower("_FrontSpecPower", 2D) = "black" {}
    12. _BackSpecPower("_BackSpecPower", 2D) = "black" {}
    13. _BackGlossStrength("_BackGlossStrength", Float) = 0
    14. _BackGlossMasking("_BackGlossMasking", Float) = 0
    15. _BackAdditiveMasking("_BackAdditiveMasking", 2D) = "black" {}
    16. _FrontGlossStrength("_FrontGlossStrength", Float) = 0
    17. _FrontGlossMasking("_FrontGlossMasking", Float) = 0
    18. _FrontAdditiveMasking("_FrontAdditiveMasking", 2D) = "black" {}
    19. _FrontSpecularSpread("_FrontSpecularSpread", Float) = 0
    20. _BackSpecularSpread("_BackSpecularSpread", Float) = 0
    21.  
    22.     }
    23.    
    24.     SubShader
    25.     {
    26.         Tags
    27.         {
    28. "Queue"="Geometry"
    29. "IgnoreProjector"="False"
    30. "RenderType"="Opaque"
    31.  
    32.         }
    33.  
    34.        
    35. Cull Off
    36. ZWrite On
    37. ZTest LEqual
    38. ColorMask RGBA
    39. Fog{
    40. }
    41.  
    42.  
    43.         CGPROGRAM
    44. #pragma surface surf BlinnPhongEditor  addshadow dualforward fullforwardshadows noambient nolightmap vertex:vert
    45. #pragma target 3.0
    46.  
    47.  
    48. sampler2D _FrontDiffuse;
    49. sampler2D _BackDiffuse;
    50. sampler2D _FrontNormalmap;
    51. sampler2D _BackNormalMap;
    52. sampler2D _FrontGloss;
    53. sampler2D _BackGloss;
    54. sampler2D _FrontSpecPower;
    55. sampler2D _BackSpecPower;
    56. float _BackGlossStrength;
    57. float _BackGlossMasking;
    58. sampler2D _BackAdditiveMasking;
    59. float _FrontGlossStrength;
    60. float _FrontGlossMasking;
    61. sampler2D _FrontAdditiveMasking;
    62. float _FrontSpecularSpread;
    63. float _BackSpecularSpread;
    64.  
    65.             struct EditorSurfaceOutput {
    66.                 half3 Albedo;
    67.                 half3 Normal;
    68.                 half3 Emission;
    69.                 half3 Gloss;
    70.                 half Specular;
    71.                 half Alpha;
    72.                 half4 Custom;
    73.             };
    74.            
    75.             inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
    76.             {
    77. half3 spec = light.a * s.Gloss;
    78. half4 c;
    79. c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
    80. c.a = s.Alpha;
    81. return c;
    82.  
    83.             }
    84.  
    85.             inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
    86.             {
    87.                 half3 h = normalize (lightDir + viewDir);
    88.                
    89.                 half diff = max (0, dot ( lightDir, s.Normal ));
    90.                
    91.                 float nh = max (0, dot (s.Normal, h));
    92.                 float spec = pow (nh, s.Specular*128.0);
    93.                
    94.                 half4 res;
    95.                 res.rgb = _LightColor0.rgb * diff;
    96.                 res.w = spec * Luminance (_LightColor0.rgb);
    97.                 res *= atten * 2.0;
    98.  
    99.                 return LightingBlinnPhongEditor_PrePass( s, res );
    100.             }
    101.            
    102.             struct Input {
    103.                 float2 uv_FrontDiffuse;
    104. float2 uv_BackDiffuse;
    105. float3 viewDir;
    106. float4 meshUV;
    107.  
    108.             };
    109.  
    110.             void vert (inout appdata_full v, out Input o) {
    111. float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
    112. float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
    113. float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
    114. float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);
    115.  
    116. o.meshUV.xy = v.texcoord.xy;
    117. o.meshUV.zw = v.texcoord1.xy;
    118.  
    119.             }
    120.            
    121.  
    122.             void surf (Input IN, inout EditorSurfaceOutput o) {
    123.                 o.Normal = float3(0.0,0.0,1.0);
    124.                 o.Alpha = 1.0;
    125.                 o.Albedo = 0.0;
    126.                 o.Emission = 0.0;
    127.                 o.Gloss = 0.0;
    128.                 o.Specular = 0.0;
    129.                 o.Custom = 0.0;
    130.                
    131. float4 Tex2D0=tex2D(_FrontDiffuse,(IN.uv_FrontDiffuse.xyxy).xy);
    132. float4 Tex2D1=tex2D(_BackDiffuse,(IN.uv_BackDiffuse.xyxy).xy);
    133. float4 Step0=step(float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ),float4( 0.0, 0.0, 0.0, 0.0 ));
    134. float4 Split0=Step0;
    135. float4 Lerp0=lerp(Tex2D0,Tex2D1,float4( Split0.z, Split0.z, Split0.z, Split0.z));
    136. float4 Sign0=sign(float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ));
    137. float4 Assemble0_0_NoInput = float4(0,0,0,0);
    138. float4 Assemble0_1_NoInput = float4(0,0,0,0);
    139. float4 Assemble0_3_NoInput = float4(0,0,0,0);
    140. float4 Assemble0=float4(Assemble0_0_NoInput.x, Assemble0_1_NoInput.y, Sign0.z, Assemble0_3_NoInput.w);
    141. float4 Step4=step(float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ),float4( 0.0, 0.0, 0.0, 0.0 ));
    142. float4 Split4=Step4;
    143. float4 Lerp1_2_NoInput = float4(0,0,0,0);
    144. float4 Lerp1=lerp(Assemble0,float4( Split4.z, Split4.z, Split4.z, Split4.z),Lerp1_2_NoInput);
    145. float4 Tex2D5=tex2D(_FrontSpecPower,(IN.meshUV.xyxy).xy);
    146. float4 Add2_1_NoInput = float4(0,0,0,0);
    147. float4 Add2=Tex2D5 + Add2_1_NoInput;
    148. float4 Tex2D4=tex2D(_FrontAdditiveMasking,(IN.meshUV.xyxy).xy);
    149. float4 Multiply3=Tex2D4 * _FrontGlossMasking.xxxx;
    150. float4 Add3=_FrontGlossStrength.xxxx + Multiply3;
    151. float4 Multiply2=Add2 * Add3;
    152. float4 Tex2D2=tex2D(_BackSpecPower,(IN.meshUV.xyxy).xy);
    153. float4 Add1_1_NoInput = float4(0,0,0,0);
    154. float4 Add1=Tex2D2 + Add1_1_NoInput;
    155. float4 Tex2D3=tex2D(_BackAdditiveMasking,(IN.meshUV.xyxy).xy);
    156. float4 Multiply1=Tex2D3 * _BackGlossMasking.xxxx;
    157. float4 Add0=_BackGlossStrength.xxxx + Multiply1;
    158. float4 Multiply0=Add1 * Add0;
    159. float4 Step1=step(float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ),float4( 0.0, 0.0, 0.0, 0.0 ));
    160. float4 Split1=Step1;
    161. float4 Lerp2=lerp(Multiply2,Multiply0,float4( Split1.z, Split1.z, Split1.z, Split1.z));
    162. float4 Tex2D9=tex2D(_FrontSpecPower,(IN.meshUV.xyxy).xy);
    163. float4 Add6_1_NoInput = float4(0,0,0,0);
    164. float4 Add6=Tex2D9 + Add6_1_NoInput;
    165. float4 Tex2D8=tex2D(_FrontAdditiveMasking,(IN.meshUV.xyxy).xy);
    166. float4 Multiply7=Tex2D8 * _FrontGlossMasking.xxxx;
    167. float4 Add4=_FrontSpecularSpread.xxxx + Multiply7;
    168. float4 Multiply4=Add6 * Add4;
    169. float4 Tex2D7=tex2D(_BackSpecPower,(IN.meshUV.xyxy).xy);
    170. float4 Add7_1_NoInput = float4(0,0,0,0);
    171. float4 Add7=Tex2D7 + Add7_1_NoInput;
    172. float4 Tex2D6=tex2D(_BackAdditiveMasking,(IN.meshUV.xyxy).xy);
    173. float4 Multiply6=Tex2D6 * _BackGlossMasking.xxxx;
    174. float4 Add5=_BackSpecularSpread.xxxx + Multiply6;
    175. float4 Multiply5=Add7 * Add5;
    176. float4 Step2=step(float4( IN.viewDir.x, IN.viewDir.y,IN.viewDir.z,1.0 ),float4( 0.0, 0.0, 0.0, 0.0 ));
    177. float4 Split2=Step2;
    178. float4 Lerp3=lerp(Multiply4,Multiply5,float4( Split2.z, Split2.z, Split2.z, Split2.z));
    179. float4 Master0_2_NoInput = float4(0,0,0,0);
    180. float4 Master0_5_NoInput = float4(1,1,1,1);
    181. float4 Master0_7_NoInput = float4(0,0,0,0);
    182. float4 Master0_6_NoInput = float4(1,1,1,1);
    183. o.Albedo = Lerp0;
    184. o.Normal = Lerp1;
    185. o.Specular = Lerp2;
    186. o.Gloss = Lerp3;
    187.  
    188.                 o.Normal = normalize(o.Normal);
    189.             }
    190.         ENDCG
    191.     }
    192.     Fallback "Diffuse"
    193. }
     

    Attached Files:

  18. Texel

    Texel

    Joined:
    Dec 25, 2009
    Posts:
    61
    Neptune_Imaging: A while back I'd posted this image, but it seems to answer your question, so I'm throwing it up again. In the event you need to use normal maps, just be sure to multiply the value I'm outputting to normals with your normal map. (It may also be necessary to multiply it by a constant (-1,-1,1,1) to correct for flipped binormals/tangents aswell, if your flipping your backface texture)
     

    Attached Files:

  19. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    I was trying to get the normal maps working, but i think I got lost in the addition of the maps... i am doing this so that all of my shaders will have the ability to do true backfacing... and the graph is so large now I forgot where the nodes are. So basically, I could plug a multiply node into the normal slot, plug the assemble back into the multiply slot and then i could probably using another multiply node and blend my two normal maps... right now I am using a lerp node to blend the two together...

    EDIT: SOLVED!! I added the assemble and lerp nodes and used a constant of 1,1,-1,1 :)

    But now the normal map is weakened by the multiply node :(

    Thanks a bunch :)
     

    Attached Files:

    Last edited: Aug 10, 2011
  20. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yep that would be really sexy - including seeing the ES 2.0 output so we can learn to slowly make our own coded shaders. But probs to texel and stramit.

    Spoke to texel a few times on IRC, he is a bit of a mad genius.
     
  21. Drewson

    Drewson

    Joined:
    Apr 19, 2009
    Posts:
    168
    Sorry for the noobish question, but how to I make the preview sphere show up? I can't seem to figure it out...
     
  22. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    The preview sphere only works in Pro.
     
  23. CG3D

    CG3D

    Joined:
    Jun 5, 2009
    Posts:
    4
    Hey I can't seem to install Strumpy on Unity 3.4 either, I've tried to get it from the Asset store and install it manually with no success. Any ideas? :confused:

    (No luck on a Mac or a PC, with Unity 3.4)
     
  24. ScienceFiction

    ScienceFiction

    Joined:
    May 28, 2008
    Posts:
    393
    Thanks for the recording! This looks very nice, best cell-shading effect I've seen in Unity.
     
  25. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    Grab it from this thread. There is a link on the first page to the latest version. Are you using OSX Lion?
     
  26. CG3D

    CG3D

    Joined:
    Jun 5, 2009
    Posts:
    4
    Aha - it was a conflict with my project scripts / etc. I created a new project and Strumpy is working again. :D
     
  27. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    I'm trying to make geometry appear to dissolve the further from the camera it is.. I started by using the Clip example, and then added the screenDepth node in. I can't seem to get it to work for things at a distance, but it will work for objects close to the camera.

    If I send the values over to the Emissive node, it appears as I'd expect... surfaces far away are darker and showing the dissolve texture, while things up close blend to solid white.

    can anyone help? I thought it would be easy but I'm not getting good results.
     
  28. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    If you want things to change based on distance from camera you are probably over thinking things a tiny bit by using the depth buffer!

    What you want to to do is take the _WorldSpaceCameraPos and the worldPos (this will be the world position of the pixel being rendered) and subtract them from one another then calculate the distance. This will give you the distance between them in world space! You should then use this value for your coloring.
     
  29. tooncraft

    tooncraft

    Joined:
    Apr 29, 2011
    Posts:
    20
    Hello Stramit, Excellent work on the shader editor.
    But for someone like me without any experiene in coding or shader creation its still really tough.

    Is there a graph example of a shader using a glow map and alpha transparency.
    Im trying to get a shader for some jellyfish-like udersea creatures that are partialy transpearent and have self-illuminating spots (via glow maps).

    Any help would be appreciated.
     
    Last edited: Aug 15, 2011
  30. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Easy Mode:

    Look at the included Rimlight shader. This will give you a basis for the partial transparency you are looking for. As for self-illuminating spots, you can either use an animated texture in the Emission channel, or use the vertex graph to animate vertex color cycling, depending on what kind of detail you need in the spots. Pics below. Not sure if it's what you are looking for, but it might help anyway.

    *EDIT* Incedentally, how do I seperate the channels in an image? I wanted to use the RGB values for the Emission here, but not the Alpha, the Split node seems to be the way to do it but it did not work the way i expected at all...

    $Screen Shot 2011-08-15 at 4.37.43 PM.png
    $Screen Shot 2011-08-15 at 4.37.57 PM.png
    $Screen Shot 2011-08-15 at 4.38.05 PM.png
    $Spots.png
    $Screen Shot 2011-08-15 at 4.39.24 PM.png
     
    Last edited: Aug 15, 2011
  31. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,436
    Hey stramit, I have a question for you... do you think on your next update of SSE, you could have the inputs on the master nodes coloured? Such as "Albedo" is red and any node you plug into the albedo, turns red... It would be just a visual cue just in case I have a S***load of nodes like I do for my "Super Shader"

    :)
     
  32. tooncraft

    tooncraft

    Joined:
    Apr 29, 2011
    Posts:
    20
    Thanks noradninja,

    Im not quite sure if thats what I need.
    I need to be able to plug in 2d texture maps (one for the glow map and one for the alpha map).
    Basically I was hoping there was something that combined Unitys Transparency and Sellf Illuminaion Materials with a slot for using 2d image maps for each as well as being able to tap into the alpha channel from the map(s).

    $_example.jpg


    I truely appreciate your help.
     
    Last edited: Aug 15, 2011
  33. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Let me look into it, I'll PM you if I can figure it out. It's something I need to do for my NPR shader as it is.
     
  34. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    excellent! that points me in the right direction, I'm wondering though, is _WorldSpaceCameraPos available in the shader editor? I managed to use it by editing the shader file after exporting, but I have to do that for any change in the shader graph.

    **Edit**
    Thanks for the help, I got it all working, was as simple as doing this, then multiplying it with a float Range
    float4 Distance0=distance(float4(_WorldSpaceCameraPos.x,_WorldSpaceCameraPos.y,_WorldSpaceCameraPos.z,1.0),float4( IN.worldPos.x, IN.worldPos.y,IN.worldPos.z,1.0 ));
     
    Last edited: Aug 16, 2011
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    Can you elaborate on what you mean by this I don't quite understand. you should just be able to drag an RGBA into emission and RGB will be used. Emission will ignore alpha channel.
     
  36. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    :( I just noticed that it is not in there.... It will be in the next release.
     
  37. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    It's a nice idea but unfortunately a bit impractical. Nodes can be plugged into multiple inputs in the graph (what color should they be then?). It also messes up the node coloring based on what 'state the node is in. I'll see if there is something that I can do to make it a bit cleaner through (no promises).
     
  38. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    This has some limitations given how unity handles 'glow' post process. It uses the written alpha value for the glow, as well as for the transparent blending. So you have the limitation of the glow amount being tied to the alpha value. This is not really desirable, at all.

    The standard unity transparent just does:
    -Sample Texture
    -Write RGB to diffuse
    -Write A to alpha

    The standard unity Illum Shader does:
    -Sample texture
    -Write RGB to diffuse
    -Write A to alpha
    -Write RGB * Illum Texture alpha to emission

    The best way I can think of is this:
    -In your texture put 'color' into RGB and illum into A
    -Sample texture
    -Write RGB to diffuse
    -Write A to alpha
    -Write RGB * A into emission

    This will be one texture sample, and should be adequate for simple needs. The limitation will be that the 'glow' will be the same as the alpha in these locations.
     
  39. SinisterMephisto

    SinisterMephisto

    Joined:
    Feb 18, 2011
    Posts:
    178
    Last edited: Aug 16, 2011
  40. tooncraft

    tooncraft

    Joined:
    Apr 29, 2011
    Posts:
    20
    Thanks Stramit,

    What I think I will have to do it break up the model into different materials.
    One using glow and the other transparency....but each using the same diffuse.
    Not sure how it will look though.
     
  41. okimoki

    okimoki

    Joined:
    May 13, 2010
    Posts:
    116
    Hi all, i would like to create a shader that uses RGBA info from one image then it takes another image (alpha) to do a transition with..
    I have an RBG image that uses its own alpha to cut out the, lets say a figure.. then i would like to use a gradient as another image to fade the first image with its own alpha into the scene.. second image would probably have two values that would animate.. like "clip black" and "clip white" to animate the transition - i would like almost sharp transition from bottom to top..

    Hope i was clear in what i want to achieve and hope that somebody can help me :)

    The thing i need most is the way to modify the linear gradient to be like this bbbbbbbbggwwwwwww (black grey white, where gg is gradient from pure black to pure white..).. and then to animate it from this: bggwwwwwwwwwwwww to this: bbbbbbbbbbbbbbbbggw
     
  42. phixell.p

    phixell.p

    Joined:
    Jan 14, 2011
    Posts:
    13
    Awesome tool. I have been asking for some help writing a two texture and two bump vertex blended shader for days and got no reply.
    I downloaded this tool and in a matter of two hours put one together. I don't know how optimized it is but it sure works!
    Thank you so much for this great tool!!

    By the way here is the shader code:

    Shader "Two_RGBA_Bump_VertexBlend"
    {
    Properties
    {
    _Base1("_Base1", 2D) = "black" {}
    _Normal1("_Normal1", 2D) = "black" {}
    _Normal2("_Normal2", 2D) = "black" {}
    _Base2("_Base2", 2D) = "black" {}

    }

    SubShader
    {
    Tags
    {
    "Queue"="Geometry"
    "IgnoreProjector"="False"
    "RenderType"="Opaque"

    }


    Cull Back
    ZWrite On
    ZTest LEqual
    ColorMask RGBA
    Fog{
    }


    CGPROGRAM
    #pragma surface surf BlinnPhongEditor vertex:vert
    #pragma target 2.0


    sampler2D _Base1;
    sampler2D _Normal1;
    sampler2D _Normal2;
    sampler2D _Base2;

    struct EditorSurfaceOutput {
    half3 Albedo;
    half3 Normal;
    half3 Emission;
    half3 Gloss;
    half Specular;
    half Alpha;
    half4 Custom;
    };

    inline half4 LightingBlinnPhongEditor_PrePass (EditorSurfaceOutput s, half4 light)
    {
    half3 spec = light.a * s.Gloss;
    half4 c;
    c.rgb = (s.Albedo * light.rgb + light.rgb * spec);
    c.a = s.Alpha;
    return c;

    }

    inline half4 LightingBlinnPhongEditor (EditorSurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
    {
    half3 h = normalize (lightDir + viewDir);

    half diff = max (0, dot ( lightDir, s.Normal ));

    float nh = max (0, dot (s.Normal, h));
    float spec = pow (nh, s.Specular*128.0);

    half4 res;
    res.rgb = _LightColor0.rgb * diff;
    res.w = spec * Luminance (_LightColor0.rgb);
    res *= atten * 2.0;

    return LightingBlinnPhongEditor_PrePass( s, res );
    }

    struct Input {
    float2 uv_Base1;
    float4 color : COLOR;
    float2 uv_Base2;
    float2 uv_Normal2;
    float2 uv_Normal1;

    };

    void vert (inout appdata_full v, out Input o) {
    float4 VertexOutputMaster0_0_NoInput = float4(0,0,0,0);
    float4 VertexOutputMaster0_1_NoInput = float4(0,0,0,0);
    float4 VertexOutputMaster0_2_NoInput = float4(0,0,0,0);
    float4 VertexOutputMaster0_3_NoInput = float4(0,0,0,0);


    }


    void surf (Input IN, inout EditorSurfaceOutput o) {
    o.Normal = float3(0.0,0.0,1.0);
    o.Alpha = 1.0;
    o.Albedo = 0.0;
    o.Emission = 0.0;
    o.Gloss = 0.0;
    o.Specular = 0.0;
    o.Custom = 0.0;

    float4 Tex2D0=tex2D(_Base1,(IN.uv_Base1.xyxy).xy);
    float4 Multiply1=Tex2D0 * IN.color;
    float4 Tex2D1=tex2D(_Base2,(IN.uv_Base2.xyxy).xy);
    float4 Invert0= float4(1.0, 1.0, 1.0, 1.0) - IN.color;
    float4 Saturate0=saturate(Invert0);
    float4 Multiply2=Tex2D1 * Saturate0;
    float4 Add0=Multiply1 + Multiply2;
    float4 Tex2D2=tex2D(_Normal2,(IN.uv_Normal2.xyxy).xy);
    float4 UnpackNormal1=float4(UnpackNormal(Tex2D2).xyz, 1.0);
    float4 Multiply0=UnpackNormal1 * Saturate0;
    float4 Tex2D3=tex2D(_Normal1,(IN.uv_Normal1.xyxy).xy);
    float4 UnpackNormal0=float4(UnpackNormal(Tex2D3).xyz, 1.0);
    float4 Multiply3=UnpackNormal0 * IN.color;
    float4 Add1=Multiply0 + Multiply3;
    float4 Master0_2_NoInput = float4(0,0,0,0);
    float4 Master0_3_NoInput = float4(0,0,0,0);
    float4 Master0_4_NoInput = float4(0,0,0,0);
    float4 Master0_5_NoInput = float4(1,1,1,1);
    float4 Master0_7_NoInput = float4(0,0,0,0);
    float4 Master0_6_NoInput = float4(1,1,1,1);
    o.Albedo = Add0;
    o.Normal = Add1;

    o.Normal = normalize(o.Normal);
    }
    ENDCG
    }
    Fallback "Diffuse"
    }
     
  43. asnane

    asnane

    Joined:
    Nov 23, 2010
    Posts:
    8
    helpful product. thnx.
     
  44. avittone

    avittone

    Joined:
    Aug 22, 2011
    Posts:
    3
    Hello all,

    I am sure that this has been answered before, but it is nearly impossible to search this thread as it is nearly 100 pages.

    I cannot create a transparent shader using the strumpy shader editor. I have tried all manner of options in the settings tab to no result. Is there a simple step by step for setting up a simple single color transparent shader with strumpy?
     
  45. solid

    solid

    Joined:
    Jan 15, 2010
    Posts:
    132
    Sorry for adding yet another question.
    Is there a Node equivalent to Overlay?
     
  46. avittone

    avittone

    Joined:
    Aug 22, 2011
    Posts:
    3
    I wonder if the problem I am having with transparent shaders in strumpy isn't actually due to Strumpy not being compatible with the latest (3.4) release of Unity Pro? I suggest this because the DepthBiasAlpha example sgraph does not appear transparent either.
     
  47. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    @ avittone
    I'm not sure if I've made any transparent shaders in strumpy since 3.4, but I can confirm that it definitely worked in the past. I might try it out tonight.

    @ Solid
    I don't think so.
     
  48. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    What do you mean by overlay? You can just add values together and it will 'overlay'.
     
  49. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,183
    *In settings change blend mode to custom.
    *Set src blend to srcAlpha
    *Set des blend to oneMinusSrcAlpha
    *Set queue and render type to transparent
    *Ensure you have a value going into alpha
     
  50. shenrik

    shenrik

    Joined:
    Aug 22, 2011
    Posts:
    6
    Hi guys, I just finished reading the whole thread! it took me long time but I finally got through :p
    There are some nice examples here! And it looks like a nice tool, it really should be integrated to unity.

    I'm just starting to learn about shaders, I'm trying to do a half lambert inside this tool but with no success so far:



    It looks like this:



    Whereas in code it look like this:

    half4 LightingHalfLambert (SurfaceOutput s, half3 lightDir, half atten)
    {
    half NdotL = dot (s.Normal, lightDir);
    half diff = NdotL * 0.5 + 0.5; //half Lambert here
    half4 c;
    c.rgb = s.Albedo * _LightColor0.rgb * diff * (atten * 2);
    c.a = s.Alpha;
    return c;
    }



    If I export the code from the graph I see that the stuff I'm doing inside strumpy is calculated as a pass, so I'm thinking that maybe it's not possible to do this kind of thing :(

    I'll continue exploring and I keep you posted if I find something :D

    See you guys and many thanks to strumpy and texel :)