纳金网

标题: 游戏性和画面特效——创建一个老电影式的画面特效(3) [打印本页]

作者: tianhett    时间: 2015-2-24 00:54
标题: 游戏性和画面特效——创建一个老电影式的画面特效(3)

// 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







欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5