Hi everyone.
I’m currently working on a game, that includes a quite a large map. To optimize the game, I therefore use a lot of LOD’s.
The game is now in a state where it runs smoothly never dipping below 60 frames per second, however there’re also quite a lot of obvious LOD popping. Therefore I want to blur, or dither the transition inbetween two LOD’s.
I’m quite new to shaders, and therefore I’m having a hard time achieving what I want.
I do have made a working version here, although I would really like to have this effect transferred to the full standard shader.
Shader "Custom/LODTest" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType" = "TransparentCutout" "Queue" = "AlphaTest" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma surface surf Standard vertex:vert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
sampler2D _MainTex;
struct Input {
float2 uv_MainTex;
UNITY_DITHER_CROSSFADE_COORDS
};
half _Glossiness;
half _Metallic;
fixed4 _Color;
void surf (Input IN, inout SurfaceOutputStandard o) {
// 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 = _Glossiness;
o.Alpha = c.a;
#ifdef LOD_FADE_CROSSFADE
UNITY_APPLY_DITHER_CROSSFADE(IN);
#endif
}
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input, o);
UNITY_TRANSFER_DITHER_CROSSFADE(o, v.vertex);
}
ENDCG
}
FallBack "Diffuse"
}
I have tried to transfer this two the full standard shader, although it, to me, seems like a giant net of worms and linked .cginc files.
If anyone have any clue how this could be achieved, and would point me in the right direction, I’d be really happy.