Hacker News new | ask | show | jobs
by Zinu 1377 days ago
I'm also new to shaders, so I might be wrong: Camera distortion (/perspective) is done in the vertex shader, this post here presents a fragment shader. So if you take a quad, in the vertex shader then rotate it so it'll face the camera (i.e. all vertices have same z/depth value in clip space), you can then probably use this fragment shader to render the ball.

You have to rotate the quad to face the camera, since it has to cover the area where the ball may render (imagine the extreme case: if the quad is perpendicular to the camera, it looks like a line to the camera, you could only render the ball within that line, it wouldn't protrude to the left or right).

1 comments

> You have to rotate the quad to face the camera

Or you only run the center point through the camera transform, and then render the quad in screen space. Should be cheaper in terms of compute.