#ifndef _GRADIENTDISSOLVE #define _GRADIENTDISSOLVE half4 MergeColors(half4 background, half4 sample) { half4 _out = lerp(background, sample, sample.a); _out.a = 1; return _out; } void GradientedDissolve_float( UnityTexture2D NoiseTexture, UnityTexture2D BaseTexture, UnityTexture2D GUITexture, UnitySamplerState NoiseSS, half2 UV, half2 UV2, half NoisePow, half Width, half Th, out half4 _out ) { _out = SAMPLE_TEXTURE2D(BaseTexture, NoiseSS, UV); half noise = SAMPLE_TEXTURE2D(NoiseTexture, NoiseSS, UV).r; noise = pow(noise, NoisePow); noise = noise * (1-UV.x); noise += Th; bool inRange = UV2.x >= 0.0 && UV2.x <= 1.0 && UV2.y >= 0.0 && UV2.y <= 1.0; if (inRange) { half4 guiSample = SAMPLE_TEXTURE2D_LOD(GUITexture, NoiseSS, UV2, 0); half4 guiSampleLow = SAMPLE_TEXTURE2D_LOD(GUITexture, NoiseSS, UV2, 3); if (noise > 1.0) { noise = 1.0; //_out.xyz = _out.xyz * (guiSample+OffsetColor); _out.xyz = MergeColors(_out, guiSample).xyz; //_out.xyz = guiSample.rrr; } else if ((noise + Width ) > 1.0) { noise = (noise + Width - 1.0)/Width; half4 gui = lerp(guiSampleLow, guiSampleLow, noise); //float3 full = _out.xyz * gui; half4 full = MergeColors(_out, guiSample); _out.xyz = lerp(_out, full, noise).xyz; } else { noise = 0.0; } } } #endif