Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* COMPATIBILITY
- - HLSL compilers
- - Cg compilers
- */
- /*
- Gameboy Mimic Shader
- by Sp00kyFox, 2014
- Calculates luma and rounds it to one of 4 grayscales.
- */
- #define TEX(dx,dy) tex2D(decal, VAR.texCoord+float2((dx),(dy))*VAR.t1)
- static float3 weights = float3(0.299, 0.587, 0.114);
- struct input
- {
- float2 video_size;
- float2 texture_size;
- float2 output_size;
- };
- struct out_vertex {
- float4 position : POSITION;
- float2 texCoord : TEXCOORD0;
- float2 t1;
- };
- /* VERTEX_SHADER */
- out_vertex main_vertex
- (
- float4 position : POSITION,
- float2 texCoord : TEXCOORD0,
- uniform float4x4 modelViewProj,
- uniform input IN
- )
- {
- out_vertex OUT;
- OUT.position = mul(modelViewProj, position);
- float2 ps = float2(1.0/IN.texture_size.x, 1.0/IN.texture_size.y);
- float dx = ps.x;
- float dy = ps.y;
- OUT.texCoord = texCoord;
- OUT.t1 = float2(dx, dy); // F H
- return OUT;
- }
- /* FRAGMENT SHADER */
- float3 main_fragment(in out_vertex VAR, uniform sampler2D decal : TEXUNIT0, uniform input IN) : COLOR
- {
- float3 C = TEX( 0, 0);
- float luma = (ceil(4.0 * dot(C, weights)) - 1.0) / 3.0;
- return float3(luma);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement