• entries
    743
  • comments
    1924
  • views
    580416

Shader madness

Sign in to follow this  

71 views

Just a quicky tonight to say that once you start with pixel shaders, it is very hard to stop.

It occurred to me at work today that rather than rendering Squishy's arms as a list of triangles, I could just render a single quad and use a shader to work out which pixels to make black, to produce a smooth curve rather than the slightly blocky current look.

So, around jujitsu tonight and drinking beer (it's a Friday), I've managed to research and write a shader that can draw a cubic bezier curve onto a render target.

I'm hoping that by finding some sweet spots with the positions of the second and third guide points scaled somehow based on the length of the arm, I can achieve a good effect that provides a smoothly curving arm instead.

We shall see. I like these "it would be cool but it doesn't really matter" ideas.

Having said that, I really need to stop pissing around with interesting graphics effects and get on with writing actual game structure but then I guess this is the benefit of being a hobbyist.

Just in case I ever lose it on my PC, this is the bezier interpolation function from my shader:


float bz(float p0,float p1,float p2,float p3,float t)
{
return (pow(1-t,3))*p0+(3*t*pow(1-t,2))*p1+(3*t*t*(1-t))*p2+pow(t,3)*p3;
}


where p0 and p3 are the end points, p1 and p2 are the guide points and t is the distance along the curve between zero and one.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now