Wasn't sure what title to put here but I have a bit of a poser that I've not been able to figure out yet.
I'm doing some non-realistic atmospheric scattering using a post processor in my [DirectX11] engine and part of my process is to compute a “halo” around the sun. I am dealing in normalised screen coordinates (X and Y between -1 and 1) for both the pixel position and the sun position. I pass the sun position into the shader by computing it using the view projection matrix in the program. That part is fine, the sun coordinates match up fine.
What I'm having a problem with is creating my halo. I'm using the distance keyword to compute the distance between the pixel position and the sun position and then I do some powering to blend it out into a nice halo. This looks great but only when the screen ratio is 1, i.e. the width of the render window is the same as the height. When I render in a screen which is wider than it is high, the halo stretches to match the ratio. I thought all I'd need to do is multiply the pixel position by the screen ratio and that does give me a circular halo whatever the screen ratio is, but it displays in the wrong position. This is obviously because I'm changing the position of the pixel regardless of how close it is to the centre of the sun position.
Been trying to figure this out for a while but haven't got very far yet, I'm finding it a bit of a brain melter to be honest. Anyone done anything similar? Thing is, I also want to draw a ‘sprite’ using this shader for some fake sun flares so I'll need to work out ratio-altered pixel coordinates.