- Home /
Question by
Squidler · Jan 13, 2014 at 02:06 PM ·
rotationreflectioncubemap
Manual control of reflection rotation
I have a simple shader with transparency and a cubmap for reflections and need control over the rotation of the reflection manually (in the inspector) rather than just it be controlled by the camera position/object orientation - the camera and object are static while the reflection rotation needs to change.
There are a few related questions and answers I've found but none quite achieve the control I'm looking for.
The shader as it stands is:
Shader "Custom/3DGUIGlassFront" {
Properties {
_MainTint ("Diffuse Tint", Color) = (1,1,1,1)
_Cubemap ("CubeMap", CUBE) = ""{}
_ReflAmount ("Reflection Amount", Range(0.01, 1)) = 0.5
}
SubShader {
Tags { "RenderType"="Transparent" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert alpha
float4 _MainTint;
samplerCUBE _Cubemap;
float _ReflAmount;
struct Input {
float2 uv_MainTex;
float3 worldRefl;
};
void surf (Input IN, inout SurfaceOutput o) {
half4 c = _MainTint;
o.Emission = texCUBE (_Cubemap, IN.worldRefl).rgb * _ReflAmount;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Comment
Best Answer
Answer by Squidler · Jan 13, 2014 at 04:42 PM
Not the most elegant solution but perhaps the simplest; I've simply parented the reflective objects to the camera and rotate the camera - gives the same effect and controlling the camera orientation is simple.