• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualMeltac

Posted 17 July 2012 - 06:38 AM

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?

EDIT:
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?

EDIT 2:
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!

### #4Meltac

Posted 17 July 2012 - 06:38 AM

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?

EDIT:
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?
EDIT 2:
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!

### #3Meltac

Posted 17 July 2012 - 03:14 AM

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?

EDIT:
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?

### #2Meltac

Posted 17 July 2012 - 03:14 AM

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?

EDIT:
I guess I'll somehting like kind of Azimuthal Projection: See here: http://www-history.mcs.st-and.ac.uk/Projects/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?

### #1Meltac

Posted 17 July 2012 - 01:28 AM

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?

PARTNERS