Step 14: HLSL. Writing pixel shader effect.
Posted by mirosurabu
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.
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,. . .
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?