Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency
- Texture2D Texture;
- SamplerState TextureSampler;
- //#define SplitRGB
- #define ResX 480.0
- #define ResY 270.0
- #define Wasteful
- //#define Vignette
- #define Curved
- float2 radialDistortion(float2 coord)
- {
- float2 cc = coord - 0.5;
- float dist = dot(cc, cc) * 0.1;
- return (coord + cc * (1.0 + dist) * dist);
- }
- struct PS_INPUT
- {
- float4 p : SV_Position;
- float2 t : TEXCOORD0;
- };
- struct PS_OUTPUT
- {
- float4 c : SV_Target0;
- };
- PS_OUTPUT ps_main(PS_INPUT input)
- {
- PS_OUTPUT output;
- #ifdef Curved
- input.t = radialDistortion(input.t);
- // Again wasteful, but for some reason, I couldn't set BORDER as a samplerstate
- if( input.t.x > 1.0 || input.t.x < 0.0 || input.t.y > 1.0 || input.t.y < 0.0 )
- {
- output.c = float4(0.0,0.0,0.0,1.0);
- return output;
- }
- #endif
- float2 vPixelPos;
- vPixelPos.x = (input.t.x * ResX) + 0.5;
- vPixelPos.y = (input.t.y * ResY) + 0.5;
- float2 vPixel = round(vPixelPos);
- float2 vPixelDist = vPixelPos - vPixel;
- float fMaxDist = 1.0;
- #ifdef Wasteful
- input.t.x = vPixel.x / ResX;
- input.t.y = vPixel.y / ResY;
- #endif
- float fVignette = 1.0;
- #ifdef Vignette
- fVignette = saturate(1.3 - (pow(input.t.x-0.5,2) + pow(input.t.y-0.5,2)) );
- #endif
- float4 color = Texture.Sample(TextureSampler, input.t) * fVignette;
- // Shame this doesn't work, not entirely sure why either. Should split the RGB slightly.
- #if SplitRGB
- float fTexelPos = (vPixelDist.x + 1.0) * 0.7854;
- color.x *= 1.0 - sin(fTexelPos+0.00) * 0.25;
- color.y *= 1.0 - sin(fTexelPos+0.52) * 0.25;
- color.z *= 1.0 - sin(fTexelPos+1.04) * 0.25;
- color.xyz *= 1.5;
- #endif
- float fPixelDist = saturate( fMaxDist - sqrt(pow(abs(vPixelDist.x),2) + pow(abs(vPixelDist.y),2)) );
- color.xyz *= fPixelDist;
- output.c = color;
- return output;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement