- Home /
How to make a Diffuse Bump Blending
Hello every one.
I'm trying to realize a diffuse bump blending (whith shader).
For the moment I wrote this :
Shader "Diffuse Bump Blending" { Properties { _Blend ("Blend", Range(0, 1)) = 0.5 _MainTex ("Texture", 2D) = "" _Texture2 ("Texture 2", 2D) = "" _BumpMap ("Bumpmap", 2D) = "bump" {} } SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf Lambert struct Input { float2 uv_MainTex; float2 uv_BumpMap; };
sampler2D _MainTex;
sampler2D _BumpMap;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb;
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
}
ENDCG
}
Fallback "Diffuse"
}
I don't know how to add the blending effect to this shader. I have this code for the blending :
Shader "Blend 2 Textures" {
Properties { _Blend ("Blend", Range(0, 1)) = 0.5 _MainTex ("Texture 1", 2D) = "" _Texture2 ("Texture 2", 2D) = "" }
SubShader { Pass { SetTexture[_MainTex] SetTexture[_Texture2] { ConstantColor (0,0,0, [_Blend]) Combine texture Lerp(constant) previous }
} }
}
Any idea ?
Thanks !
Answer by taoa · Mar 28, 2011 at 01:09 PM
Try this:
Shader "Diffuse Bump Blending" { Properties { _Blend ("Blend", Range(0, 1)) = 0.5 _MainTex ("Texture", 2D) = "" _Texture2 ("Texture 2", 2D) = "" _BumpMap ("Bumpmap", 2D) = "bump" {} }
SubShader { Tags { "RenderType" = "Opaque" } CGPROGRAM #pragma surface surf Lambert struct Input { float2 uv_MainTex; float2 uv_BumpMap; };
sampler2D _MainTex;
sampler2D _Texture2;
sampler2D _BumpMap;
float _Blend;
void surf (Input IN, inout SurfaceOutput o)
{
float3 t1 = tex2D (_MainTex, IN.uv_MainTex).rgb;
float3 t2 = tex2D (_Texture2, IN.uv_MainTex).rgb;
o.Albedo = lerp(t1, t2, _Blend);
o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
}
ENDCG
} Fallback "Diffuse" }
Is it possible use different uv tile and offset by _$$anonymous$$ainTex and _Texture2?
Your answer
Follow this Question
Related Questions
Diffuse 2-sided shader only accepts light on one side? 2 Answers
shader diffuse color too dark 0 Answers
Cubemap Diffuse / Heightmap Shader Issues. 1 Answer
Weird shader thing 1 Answer
Shader texture blend performance 0 Answers