Posted By: 3run
fade material's skin in/out - 03/05/15 10:44
I've found a postprocessing shader (I guess it was made by Emre), which blinks the view, adds noise effect and so on.
I tried to remove everything (all effects), but to leave the noise effect, and I guess I've done it correctly, here the .fx:
But now, when I've ripped it out, I wanted to know, how to make the skin (Noise_Tex) fade in and out, when I need it to. So f.e. when I walk close up to something in my game, the noise effect will increase, and when I walk away then it should decrease... I'm pretty sure, that this is a very simple task, but I would really appreciate some advice or help (maybe there is a better way to archive what I'm looking for, I'm open for suggestions, I've tried example made by Slin which uses panels, but I didn't like it, so I guess I won't go panels way).
Thanks in advance! And best regards.
I tried to remove everything (all effects), but to leave the noise effect, and I guess I've done it correctly, here the .fx:
Code:
texture TargetMap; texture mtlSkin1; float4 vecTime; float noiseSize = 0.9f; sampler View_Tex = sampler_state { texture = <TargetMap>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; sampler Noise_Tex = sampler_state { texture = <mtlSkin1>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; }; float4 Noise_Effect_PS( float2 Tex : TEXCOORD0 ) : COLOR { float4 Color = float4(1, 1, 1, 1); Tex.y = Tex.y + 0.05 * 0.01 * cos(vecTime.w); float4 CAMERA_VIEW = tex2D(View_Tex, Tex); float4 NOISE_EFFECT = tex2D(Noise_Tex, float3(2 * Tex * noiseSize + vecTime.w, 1)) + 0.5 * tex2D(Noise_Tex, float3(1.05 * Tex * noiseSize - vecTime.w, 1)) + 0.1; Color *= CAMERA_VIEW; Color *= NOISE_EFFECT; return(Color); } technique Noise_Effect { pass one { PixelShader = compile ps_2_0 Noise_Effect_PS(); } }
Thanks in advance! And best regards.