Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "common_ps_fxc.h"
- const HALF Brightness : register (c0); //this is a variable to set how bright the NV will be.
- sampler BaseTextureSampler : register( s0 ); //a sampler to get the texture this shader will be used on (in this case it will be a frame buffer)
- sampler ColorMapSampler : register(s0);
- // A timer to animate our shader
- float fTimer;
- // the amount of distortion
- float fNoiseAmount;
- // just a random starting number
- int iSeed;
- HALF4 main(float2 iTexCoord : TEXCOORD0) : COLOR //out main function
- {
- float4 vAdd = float4(0.1,0.1,0.1,0); // just a float4 for use later
- float4 cColor = tex2D(BaseTextureSampler,iTexCoord); //this takes our sampler and turns the rgba into floats between 0 and 1
- cColor += tex2D(BaseTextureSampler, iTexCoord.xy + 0.001); // these 3 lines blur the image slightly
- cColor += tex2D(BaseTextureSampler, iTexCoord.xy + 0.002);
- cColor += tex2D(BaseTextureSampler, iTexCoord.xy + 0.003);
- if (((cColor.r + cColor.g + cColor.b)/3) < 0.9) // if the pixel is bright leave it bright
- {
- cColor = cColor / 4; //otherwise set it to an average color of the 4 images we just added together
- }
- float4 cTempColor = cColor; //a new float4 cTempColor for use later
- cFinal.g = (cTempColor.r + cTempColor.g + cTempColor.b)/3; // sets green the the average of rgb
- cFinal.r = 0; //removes red and blue colors
- cFinal.b = 0;
- // Distortion factor
- float NoiseX = iSeed * fTimer * sin(iTexCoord.x * iTexCoord.y+fTimer);
- NoiseX=fmod(NoiseX,8) * fmod(NoiseX,4);
- // Use our distortion factor to compute how much it will affect each
- // texture coordinate
- float DistortX = fmod(NoiseX,fNoiseAmount);
- float DistortY = fmod(NoiseX,fNoiseAmount+0.002);
- // Create our new texture coordinate based on our distortion factor
- float2 DistortTex = float2(DistortX,DistortY);
- // Use our new texture coordinate to look-up a pixel in BaseTextureSampler.
- float4 Color=tex2D(ColorMapSampler, Tex+DistortTex);
- // Keep our alphachannel at 1.
- Color.a = 1.0f;
- cFinal.g = (cTempColor.r + cTempColor.g + cTempColor.b)/3; // sets green the the average of rgb
- cFinal.r = 0; //removes red and blue colors
- cFinal.b = 0;
- return (cFinal * Brightness) + Color;
- }
- technique PostProcess
- {
- pass P0
- {
- // A post process shader only needs a pixel shader.
- PixelShader = compile ps_2_0 PixelShader();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement