Step 14: HLSL. Writing pixel shader effect.

Posted by
April 19th, 2009 12:04 pm

Construct doesn’t come with proper fade transition, so I thought about writing my own. Construct uses HLSL for effects, so I thought it’s a good chance to learn a bit about shader programming.

It was a failure (given the deadline pressure). I just gave up and decided not to use any transitions.

If by any chance anyone here is familiar with HLSL and knows or has an HLSL snippet which performs fade-away fade-in transition that would be great.

Tags: , , ,


2 Responses to “Step 14: HLSL. Writing pixel shader effect.”

  1. jph says:

    humm,. can’t you do it with a simple alpha fade,. or colour shift? I have used both to good effect,. you also could draw a big sprite to fill the screen and fade it in or fade all the rest out,. . .

  2. mathias says:

    Well, with opengl it would be something like this in the fragment shader, I guess:

    uniform sampler2D texUnit0;
    uniform int alpha;

    void main(void) {
    vec4 color;
    color = texture2D(texUnit0, gl_TexCoord[0].xy);
    if(color.a != 255) color.a = alpha; // dont fade the pixels in that are meant to be transparent?

    gl_FragColor = color;
    }

    Dunno, just typed that out of my head and it is no use for you anyways since you need a HLSL snippet.. but what the hell?

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]