You can't do it in a pixel shader - the projection has already been done a coupla stages in the pipeline before that and can't be modifed. You need to use a vertex shader instead.
Sorry but I disagree. It might be true that I'm not supposed to do this in a pixel shader, as it's normally part of the vertex shader's work. But that doesn't necessarily mean that it's not possible to do in a pixel shader - only the required approach would be different.
I can do all math I want in my pixel shader, so what I just need here is the correct geometric transformation formula. That's a purely mathematical issue, not one of any GPU pipeline thingy.
So are there any other ideas here? One alternate option that came into my mind was if I have the actual angle between the view direction and the location vector of the spot in question (which can simply be calculated with the dot product as I've learned), then it might be possible to calculate the horizontal distance from that spot to the screen center when its projected to screen space by some formula. However that formula is not linear, it's likely to involve some circle calculation or something, so I've not been able to figure it out so far.
Any help here?
I guess I'll need some like kind of Azimuthal Projection: See here: http://www-history.m...s/Hoyer/S3.html
For a start it would already be great to know which kind of projection needs to be done here:
- Gnomonic Projection, or
- Stereographic Projection, or
- Orthographic Projection?
Apparently what I need is perspective projection, so probably none of the above. But still this is pure math, isn't it? So there must be some formula!