A reflective shader which takes two cube maps + alpha too control strength

Is it possible to modify, for example the “bumped unlit” shader to take 2 cube maps instead of one. And have some kind of alpha map to control the strength?
I don’t really know much about shader programming. so it would be awesome if someone more knowledgeable in writing shaders could tell me:

  1. How would you go about doing this?, is there any special place in the shader docs I should look at?

  2. Is it gonna be too complicated for someone who never wrote a shader before?, I don’t really have the time to spend several days/weeks to read up about shader programming just to get started :slight_smile:

Thanks!

Here you go I just hacked the built in shaders. I would start by reading the shaderlab documents and writing surface shaders. Shaders are not an easy concept to grasp at the start. Took me a year to learn a lot.
If you want to do a custom shader I suggest you start simpler with a 1 color shader. Bumped shaders require knowledge of tangent space matrices.

I suggest you use the built in shaders or visual shader editors to help develop them.

Shader "Reflective/Bumped Unlit 2 Cubemaps" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
	
	_MainTex ("Base (RGB), RefStrength (A)", 2D) = "white" {}
	_BumpMap ("Normalmap", 2D) = "bump" {} 
	
	_AlphaControlMap ("Blend Texture (A)", 2D) = "white" {} //<-- Controls stength using alpha channel a bit of a waste since rgb not used
	
	_CubeA ("Reflection Cubemap A", Cube) = "" { TexGen CubeReflect } //<--
	_CubeB ("Reflection Cubemap B", Cube) = "" { TexGen CubeReflect } //<--
}

Category {
	Tags { "RenderType"="Opaque" }
	LOD 250
	
	// ------------------------------------------------------------------
	// Shaders

	SubShader {
		// Always drawn reflective pass
		Pass {
			Name "BASE"
			Tags {"LightMode" = "Always"}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"

struct v2f {
	float4 pos : SV_POSITION;
	float2	uv		: TEXCOORD0;
	float2	uv2		: TEXCOORD1;
	float2	uv3		: TEXCOORD2;
	float3	I		: TEXCOORD3;
	float3	TtoW0 	: TEXCOORD4;
	float3	TtoW1	: TEXCOORD5;
	float3	TtoW2	: TEXCOORD6;
};

uniform float4 _MainTex_ST, _BumpMap_ST, _AlphaControlMap_ST;

v2f vert(appdata_tan v)
{
	v2f o;
	o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
	o.uv =  TRANSFORM_TEX(v.texcoord,_MainTex);
	o.uv2 = TRANSFORM_TEX(v.texcoord,_BumpMap);
	o.uv3 = TRANSFORM_TEX(v.texcoord,_AlphaControlMap);
	
	o.I = -WorldSpaceViewDir( v.vertex );
	
	TANGENT_SPACE_ROTATION;
	o.TtoW0 = mul(rotation, _Object2World[0].xyz * unity_Scale.w);
	o.TtoW1 = mul(rotation, _Object2World[1].xyz * unity_Scale.w);
	o.TtoW2 = mul(rotation, _Object2World[2].xyz * unity_Scale.w);
	
	return o; 
}

sampler2D _BumpMap;
sampler2D _MainTex;
sampler2D _AlphaControlMap;

samplerCUBE _CubeA;
samplerCUBE _CubeB;

fixed4 _ReflectColor;
fixed4 _Color;

fixed4 frag (v2f i) : COLOR
{
	// Sample and expand the normal map texture	
	fixed3 normal = UnpackNormal(tex2D(_BumpMap, i.uv2));
	
	fixed4 texcol = tex2D(_MainTex,i.uv);
	
	// transform normal to world space
	half3 wn;
	wn.x = dot(i.TtoW0, normal);
	wn.y = dot(i.TtoW1, normal);
	wn.z = dot(i.TtoW2, normal);
	
	// calculate reflection vector in world space
	half3 r = reflect(i.I, wn);
	
	fixed4 c = UNITY_LIGHTMODEL_AMBIENT * texcol;
	c.rgb *= 2;

	fixed4 reflcolorA = texCUBE(_CubeA, r) * _ReflectColor * texcol.a; //<-- Cube Map A
	fixed4 reflcolorB = texCUBE(_CubeB, r) * _ReflectColor * texcol.a; //<-- Cube Map B
 
 	fixed lerpValue = tex2D(_AlphaControlMap, i.uv3).a; //<-- Value in alpha channel controls strength

	return c + lerp(reflcolorA, reflcolorB, lerpValue); // <-- blend between _CubeA and _CubeB
}
ENDCG  
		} 
	}
	
	// ------------------------------------------------------------------
	//  No vertex or fragment programs
	
	SubShader {
		Pass { 
			Tags {"LightMode" = "Always"}
			Name "BASE"
			BindChannels {
				Bind "Vertex", vertex
				Bind "Normal", normal
			}
			SetTexture [_Cube] {
				constantColor [_ReflectColor]
				combine texture * constant
			}
		}
	}
}
	
FallBack "VertexLit", 1

}

Wow, thats really nice of you, thank you so much :)…Gonna try this out!