Does anyone know if the capability exists or has created a shader for velvet or satin? Specifically looking for effects to change with incidence angle to get the satin, velvet look. Thanks in advance. Cheers, Gary
I did experiment with cloth rendering some 4 years back. The easy and cheap trick in that time was to use a special cubemap to get satin/velvet-like look. I might dig up the cubemaps and the shaders somewhere (it was long time ago).
Thanks Aras. I hope to be able to do this in Unity. I use this capability often in software rendered scenery. I have seen some nVidia and DirectX shaders that do this. Gary
Hi Gary. You could use the X-Ray shader from the wiki as a start. It works like the Facing Ratio node in maya which can be used to create velvet -> Maya Velvet shader tutorial. More info on the Facing Ratio shader node here. /Patrik
Yes I thought about using that shader... I just don't know enough yet about coding one. I will use that as a start since no one else has one created yet. Thanks for the tip. Cheers, Gary
Recreated the velvet effect from Steve J. Tubbrits maya tut by combining the X-Ray shader (wiki) + standard Self-Illumin/Diffuse + a little copying from the shader tuts in the docs. Could be used for all kinds of rim-light effects aswell, just create a texture that fits your needs. Maybe a rimlight color can be added to control the look a bit more... Code (csharp): Shader "SC/Velvet" { Properties { _Color ("Main Color", Color) = (1,1,1,0.5) _MainTex ("Base (RGB) Rim-Light Ramp (A)", 2D) = "white" {} } SubShader { //make Self-Illumination depend on Facig Ratio Pass { Tags {"LightMode" = "PixelOrNone"} Color [_PPLAmbient] CGPROGRAM // profiles arbfp1 // vertex vert // fragment frag // fragmentoption ARB_fog_exp2 #include "UnityCG.cginc" float4 _Color; sampler2D _MainTex : register(s0); //sampler2D _BumpMap : register(s1); struct v2f { V2F_POS_FOG; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; v2f vert (appdata_base v) { v2f o; PositionFog( v.vertex, o.pos, o.fog ); o.uv = TRANSFORM_UV(0); float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); o.uv1.x = dot(viewDir,v.normal); o.uv1.y = 0.5; return o; } half4 frag (v2f i) : COLOR { half4 texcol = tex2D( _MainTex, i.uv ); half4 texcol2 = tex2D( _MainTex, i.uv1 ); return texcol * _Color * texcol2.a; } ENDCG SetTexture [_MainTex] {} } UsePass " Diffuse/PPL" } //FallBack "Self-Illumin/VertexLit", 1 FallBack "Normal-Diffuse", 1 } Use a texture with a gradient alpha channel. See the attached file for an example.
My friend I thank you soooo much! You should post it on the wiki now! Cannot thankyou enough!!! You are mighty! Cheers, Gary
That is so nice - now for a chance to earn some bonus points: This shader can be easily converted to use texture combiners (instead of a fragment program) hence work on just about anything. Try to give it a shot for brownie points ;-)
Challange accepted ;-) I was a bit lazy when i did this I admit. Didn't think about the best way, just copied pasted it together from other shaders. Could be a good exercise in texture combiners though! /P
Got it working without the fragment program One thing I don't get is how the different uv coordinates are used. Seems it automatically maps the first UV set to the first texture stage and the second UV set to the second texture stage? Is that right? I don't need BindChannels to do that? Code (csharp): Shader "SC/Velvet" { Properties { _Color ("Main Color", Color) = (1,1,1,0.5) _MainTex ("Base (RGB) Rim-Light Ramp (A)", 2D) = "white" {} } SubShader { //For Velvet look, Make Self-Illumination Depend on Facig Ration Pass { Tags {"LightMode" = "PixelOrNone"} Color [_PPLAmbient] CGPROGRAM // profiles arbfp1 // vertex vert #include "UnityCG.cginc" sampler2D _MainTex : register(s0); struct v2f { V2F_POS_FOG; float2 uv : TEXCOORD0; float2 uv1 : TEXCOORD1; }; v2f vert (appdata_base v) { v2f o; PositionFog( v.vertex, o.pos, o.fog ); o.uv = TRANSFORM_UV(0); float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); o.uv1.x = dot(viewDir,v.normal); o.uv1.y = 0.5; return o; } ENDCG SetTexture [_MainTex] { constantColor [_Color] combine constant * texture } SetTexture [_MainTex] { constantColor (0,0,0,1) combine previous lerp(texture) constant } } UsePass " Diffuse/PPL" } FallBack "Normal-Diffuse", 1 }
That's correct. BindChannels is only when you don't use vertex programs; when you do you control what gets output to what yourself.
Shader is on the wiki -> Velvet shader. Also, did a little creative alpha channeling for a satin like look:
Simply AWESOME!!! Thank you so much for your efforts on this. I hope that I won't be the only using this really cool shader!!! Cheers, Gary
Just playing around. I modeled a spider and put the Velvet Shader on it. gives more like a painted metal effect. Norby
I just don't know enough yet about coding one. I will use that as a start since no one else has one created yet.
Creative spam? 3 semi-related replies, and what looks like an affiliate link for the website. I apologize if this is not the case... -Jeremy
Ouch, accusing someone of being a spam bot :wink: I really doubt it, but we'll keep an eye on it... no offense jordan. Unless you are a bot, which in that case, "01100110 01110101 01100011 01101011 00100000 01101111 01100110 01100110".
Such language! I don't know if it's scarier that I knew what that said right away, or that I bothered to make sure I was right. --Eric
Any way to add traditional bump/spec to this so that the rim light follows the normal map? I've been trying to make a rim lit bump/spec/diffuse shader and this seems like the closest hope for what I'm looking to do. http://forum.unity3d.com/viewtopic.php?t=24333
Hi, the shader do not seems to work anymore. Does somebody knows where to find it for last version of unity ? Thanks.