Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Scanlines Sine Absolute Value
- An ultra light scanline shader
- RiskyJumps
- */
- #pragma parameter amp "Amplitude" 1.2500 0.000 2.000 0.05
- #pragma parameter phase "Phase" 0.5000 0.000 2.000 0.05
- #pragma parameter lines_black "Lines Blacks" 0.0000 0.000 1.000 0.05
- #pragma parameter lines_white "Lines Whites" 1.0000 0.000 2.000 0.05
- #ifdef PARAMETER_UNIFORM
- uniform float amp;
- uniform float phase;
- uniform float lines_black;
- uniform float lines_white;
- #else
- #define amp 1.250000
- #define phase 0.500000
- #define lines_black 0.000000
- #define lines_white 1.000000
- #endif
- #define freq 0.500000
- #define offset 0.000000
- #define pi 3.141592654
- struct input
- {
- float2 video_size;
- float2 texture_size;
- float2 output_size;
- float frame_count;
- float frame_direction;
- float frame_rotation;
- };
- void main_vertex
- (
- uniform input IN,
- float4 position : POSITION,
- float4 color : COLOR,
- float2 tex : TEXCOORD0,
- uniform float4x4 modelViewProj,
- out float4 oPosition : POSITION,
- out float4 oColor : COLOR,
- out float2 otexCoord : TEXCOORD0,
- out float angle : TEXCOORD2
- )
- {
- oPosition = mul(modelViewProj, position);
- oColor = color;
- otexCoord = tex;
- //float2 texsize = IN.texture_size;
- //float2 delta = 0.5 / texsize;
- //float dx = delta.x;
- //float dy = delta.y;
- float omega = 2.0 * pi * freq; // Angular frequency
- // NOTE: I can't calculate lines on vertex, because of sin()
- /*
- lines = tex.y * omega * IN.texture_size.y + phase;
- lines = sin(lines); // The use of sin() in here
- // yields a black screen...
- lines *= amp;
- lines += offset;
- lines = abs(lines);
- */
- angle = tex.y * omega * IN.texture_size.y + phase;
- }
- float4 main_fragment (
- uniform input IN,
- in float2 tex : TEXCOORD0,
- in float angle : TEXCOORD2,
- uniform sampler2D s0 : TEXUNIT0
- ) : COLOR
- {
- float3 color = tex2D(s0, tex).xyz;
- float grid;
- float lines;
- lines = sin(angle);
- lines *= amp;
- lines += offset;
- lines = abs(lines) * (lines_white - lines_black) + lines_black;
- color *= lines;
- return color.xyzz;
- }
Advertisement
Add Comment
Please, Sign In to add comment