Hi I've been doing some shader porting from Crysis to Unity's shaderlab today. I tried to port WetLayer just now, and even though it "works", it doesn't really work as it should, giving some interesting and colorful results! I am pretty sure that it's because I don't know how to return the pixelshader properly. I don't know what to return there lol. Here's the shaderlab shader: (I've commented out 2-3 lines because I just didn't know how to convert them to shaderlab) Code (csharp): Shader "Edvinas/WetLayer" { Properties { WetMultiplier ("WetMultiplier", Float) = 1.0 DarkeningAmount ("DarkeningAmount", Float) = 0.125 DetailBumpTile ("DetailBumpTile", Float) = 0.2 BumpScale ("BumpScale", Float) = 0.3 AnimScale ("AnimScale", Float) = 1.0 NoiseOffset ("NoiseOffset", Float) = 0.0 VariationTileU ("VariationTileU", Float) = 4.0 VariationTileV ("VariationTileV", Float) = 4.0 VariationTileW ("VariationTileW", Float) = 4.0 detailBumpSampler ("detailBumpSampler", 2D) = "bump" {} bumpMapSampler ("bumpMapSampler", 2D) = "bump" {} envMapSampler ("envMapSampler", 2D) = "white" {} fresnelShlickMapSampler ("fresnelShlickMapSampler", 2D) = "white" {} noiseMapSampler ("noiseMapSampler", CUBE) = "" {} } SubShader { Pass { Cull Off Blend One OneMinusSrcAlpha ZWrite Off CGPROGRAM #pragma target 3.0 #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" //samplers samplerCUBE noiseMapSampler; sampler2D detailBumpSampler; sampler2D envMapSampler; sampler2D fresnelShlickMapSampler; sampler2D bumpMapSampler; //floats float WetMultiplier; float DarkeningAmount; float DetailBumpTile; float BumpScale; float AnimScale; float NoiseOffset; float VariationTileU; float VariationTileV; float VariationTileW; struct v2f { float4 Position : POSITION; float4 tcBase : TEXCOORD0; float4 tcDetail0 : TEXCOORD1; float4 tcDetail1 : TEXCOORD2; float4 vReflectionWS : TEXCOORD3; float4 vEye : TEXCOORD4; float4 shadowTC : TEXCOORD5; }; // Common functions half4 EXPAND( half4 a ) { return a * 2 - 1; } half3 EXPAND( half3 a ) { return a * 2 - 1; } half EXPAND( half a ) { return a * 2 - 1; } half2 EXPAND( half2 a ) { return a * 2 - 1; } half4 GetFresnelTex( float NdotI, float bias) { return tex2D( fresnelShlickMapSampler, float2(NdotI, bias) ); } half GetFresnel(half NdotI, half bias, half power) { half facing = (1.0 - NdotI); return bias + (1-bias)*pow(facing, power); } half4 GetTexture2D(sampler2D MapSampler, float2 texTC) { half4 texColor = tex2D(MapSampler, texTC.xy); return texColor; } half3 GetNormalMap(sampler2D bumpMap, float2 bumpTC) { half3 bumpNormal; bumpNormal.xy = EXPAND(tex2D(bumpMap, bumpTC.xy).xy); bumpNormal.xy = EXPAND(tex2D(bumpMap, bumpTC.xy).ga); bumpNormal.z = sqrt(saturate(1 - dot(bumpNormal.xy, bumpNormal.xy))); return bumpNormal; } float4 HPosToScreenTC(float4 HPos) { float4 ScrTC = HPos; ScrTC.xy = (HPos.xy * float2(1,-1) + HPos.ww ) * 0.5; ScrTC.xy += 5.0 *HPos.w; return ScrTC; } v2f vert ( appdata_base i) { appdata_tan n; v2f o; o.Position = mul(glstate.matrix.mvp, i.vertex); o.tcBase.xy = i.texcoord.xy; float3 vScale = float3(VariationTileU, VariationTileV, VariationTileW); o.tcDetail0.xyz = i.vertex.xyz * vScale.xyz + float3(0, 0, frac(5 * AnimScale)) + NoiseOffset; o.tcDetail1.xyz = i.vertex.xyz * vScale.xyz * 2 + float3(0, 0, frac(5 * AnimScale * 2)) + NoiseOffset; float3 vEye = normalize( - i.vertex.xyz ); o.vEye.xyz = vEye.xyz; // float3 worldTangentN = mul((const float3x3)i.vertex, n.tangent); //float3 tcRef = reflect( vEye.xyz, worldTangentN.xyz); //o.vReflectionWS.xyz = tcRef; //-> should be transformed to eye space, but looks weird in non-closed objects // Output the screen-space texture coordinates o.shadowTC = HPosToScreenTC(o.Position); // Bump strenght setting - used for compensating mipmaps bump strenght removal o.tcBase.w = (o.Position.w * 0.5 + 1) * 0.1; return o; } float4 frag (v2f IN) : COLOR { half fFinalDarkening = 0; half4 cBump = half4(0,0,1,1); cBump.xyz = GetNormalMap(bumpMapSampler, IN.tcBase.xy); half3 vEye = normalize(IN.vEye.xyz); half NdotE = saturate( dot(cBump.xyz, vEye.xyz) ); half fFresnel = GetFresnel(NdotE, 0.5, 5); cBump.xy += (tex2D(detailBumpSampler, IN.tcBase.xy * DetailBumpTile).xy*2-1) * BumpScale; cBump.w = texCUBE(noiseMapSampler, IN.tcDetail0.xyz).w; cBump.w *= texCUBE(noiseMapSampler, IN.tcDetail1.xyz).w; cBump.w *= 2; cBump.w = cBump.w * 2.0 - 1.0; cBump.z = -cBump.w; // Get main vectors/coeficients half3 vNormal = normalize(cBump.xyz); // normalize reflection vector and add some perturbation into it half3 vReflectionWS = normalize(IN.vReflectionWS.xyz) ; half3 envMap = GetTexture2D(envMapSampler, vReflectionWS.xy* 0.5 + 0.5 + vNormal.xy * IN.tcBase.w).w; envMap = saturate(envMap *2-1) * fFresnel; half fOcclShadowAcc = 0; half4 cFinal = 0; cFinal.xyz = envMap * fOcclShadowAcc * WetMultiplier; cFinal.w = DarkeningAmount; return cBump; } ENDCG } } } I honestly like some of the results, COLORFUL! But I'd also like to know what I've done wrong and why it's not showing the right results I've also attached zip file containing the original Crysis WetLayer shader which I was porting as well as the textures originally used for this shader, if you want to look at it. Thanks