- Home /
Question about reflections using reflection probes
Hey, I'm using reflection probes to create a reflective floor. For now, my floor acts much like a mirror with a texture on top. I'd like to achieve an effect such that the tiles closest to the player reflect the most clearly the surroundings, and as the tiles get farther from the player, the reflection becomes blurrier and darker. What is the best way to achieve this? Is it a setting in the reflection probe? Do I have to create a shader for the reflective floor material, and if so, do you have any pointers? I'm having a bit of difficulty finding how to do anything but the simplest reflections.
Thank you for any help or tips!
Answer by Namey5 · May 03, 2016 at 09:54 AM
It would be something along the lines of
Shader "Custom/DistanceBlur" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Dist ("Distance", Float) = 1
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
float3 viewDir;
};
half _Dist;
half _Glossiness;
half _Metallic;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutputStandard o) {
float dist = length (mul (_World2Object, float4 (IN.viewDir.xy, IN.viewDir.z + _Dist, 0)));
// Albedo comes from a texture tinted by color
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb;
// Metallic and smoothness come from slider variables
o.Metallic = _Metallic;
o.Smoothness = saturate (_Glossiness * dist);
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Just a quick test to see if this is what you are after. Only has Albedo, I can add others if you want.
That's really close, thanks! I'd need it to have emission with an emission texture, and also if there is a way, as the surface is farther away, the reflection should be darker. Thanks a lot!