Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* COMPATIBILITY
- - HLSL compilers
- - Cg compilers
- */
- /*
- Scanlines - Autorotate
- Author: hunterk and Themaister
- License: Public domain
- */
- struct sine_coord
- {
- float2 omega;
- };
- struct input
- {
- float2 video_size;
- float2 texture_size;
- float2 output_size;
- float frame_count;
- float frame_direction;
- float frame_rotation;
- };
- void main_vertex
- (
- float4 position : POSITION,
- out float4 oPosition : POSITION,
- uniform float4x4 modelViewProj,
- float4 color : COLOR,
- out float4 oColor : COLOR,
- float2 tex : TEXCOORD,
- out float2 oTex : TEXCOORD,
- uniform input IN,
- out sine_coord coords : TEXCOORD2
- )
- {
- oPosition = mul(modelViewProj, position);
- oColor = color;
- oTex = tex;
- float2 texsize = IN.texture_size;
- float2 delta = 0.5 / texsize;
- float dx = delta.x;
- float dy = delta.y;
- coords.omega = float2(3.1415 * IN.output_size.x * IN.texture_size.x / IN.video_size.x, 2.0 * 3.1415 * IN.texture_size.y);
- }
- #pragma parameter SCANLINE_BASE_BRIGHTNESS "Scanline Base Brightness" 0.95 0.0 1.0 0.01
- #pragma parameter SCANLINE_SINE_COMP_A "Scanline Sine Comp A" 0.05 0.0 0.10 0.01
- #pragma parameter SCANLINE_SINE_COMP_B "Scanline Sine Comp B" 0.15 0.0 1.0 0.05
- #ifdef PARAMETER_UNIFORM
- uniform float SCANLINE_BASE_BRIGHTNESS;
- uniform float SCANLINE_SINE_COMP_A;
- uniform float SCANLINE_SINE_COMP_B;
- #else
- #define SCANLINE_BASE_BRIGHTNESS 0.95
- #define SCANLINE_SINE_COMP_A 0.05
- #define SCANLINE_SINE_COMP_B 0.15
- #endif
- float4 main_fragment (in sine_coord co : TEXCOORD2, float2 tex : TEXCOORD, uniform sampler2D s0 : TEXUNIT0, uniform input IN) : COLOR
- {
- float2 sine_comp = float2(0.0, 0.0);
- if (IN.video_size.x > IN.video_size.y)
- {
- sine_comp = float2(SCANLINE_SINE_COMP_A, SCANLINE_SINE_COMP_B);
- }
- else
- {
- sine_comp = float2(SCANLINE_SINE_COMP_B, SCANLINE_SINE_COMP_A);
- }
- float3 res = tex2D(s0, tex).xyz;
- float3 scanline = res * (SCANLINE_BASE_BRIGHTNESS + dot(sine_comp * sin(tex * co.omega), float2(1.0, 1.0)));
- return float4(scanline.x, scanline.y, scanline.z, 1.0);
- }
Add Comment
Please, Sign In to add comment