// Get teh pixed from the Vignette Texture
fixed4 vignetteTex = tex2D(_VignetteTex, i.uv);
// Process the Scratches UV and pixels
half2 scratchesUV = half2(i.uv.x + (_RandomValue * _SinTime.z * _ScratchesXSpeed),
i.uv.y + (_Time.x * _ScratchesYSpeed));
fixed4 scratchesTex = tex2D(_ScratchesTex, scratchesUV);
// Process the Dust UV and pixels
half2 dustUV = half2(i.uv.x + (_RandomValue * _SinTime.z * _DustXSpeed),
i.uv.y + (_Time.x * _DustYSpeed));
fixed4 dustTex = tex2D(_DustTex, dustUV);
// Get the luminosity values from the render texture using the YIQ values
fixed lum = dot(fixed3(0.299, 0.587, 0.114), renderTex.rgb);
// Add the constant calor to the lum values
fixed4 finalColor = lum + lerp(_SepiaColor, _SepiaColor + fixed4(0.1f, 0.1f, 0.1f, 0.1f), _RandomValue);
// Create a constant white color we can use to adjust opacity of effects
fixed3 constantWhite = fixed3(1, 1, 1);
// Composite together the different layers to create final Screen Effect
finalColor = lerp(finalColor, finalColor * vignetteTex, _VignetteAmount);
finalColor.rgb *= lerp(scratchesTex, constantWhite, _RandomValue);
finalColor.rgb *= lerp(dustTex, constantWhite, (_RandomValue * _SinTime.z));
finalColor = lerp(renderTex, finalColor, _EffectAmount);
return finalColor;
}
ENDCG
}
}
FallBack “Diffuse”
}
保存后返回Unity。我们需要在面板中设置对应的图片和属性,像下面这样:
扩展链接
关于YIQ:
http://en.wikipedia.org/wiki/YIQ
http://www.blackice.com/colorspaceYIQ.htm
http://dcssrv1.oit.uci.edu/~wiedeman/cspace/me/infoyiq.html
|