Closed flibitijibibo closed 4 years ago
One other detail is that vpos in OpenGL is floating-point and often misaligned with the integer coordinates from D3D9, as a result I have to floor() it after flipping it vertically.
Totally forgot about that, will add it to the OP.
Also as a follow-up here is my solution for both: https://github.com/sq/Fracture/blob/master/Squared/RenderLib/Shaders/TargetInfo.fxh
First draft has been written to a vpos
branch:
This is now in upstream.
A comment multiplatform graphics engineers love to see:
https://github.com/FNA-XNA/MojoShader/blob/fna/profiles/mojoshader_profile_glsl.c#L1041
Basically we have to add some data to the MOJOSHADER_glContext to do the correct flipping. For VPOS the proper line would look like this:
With vposFlip being
Naiively, we could simply add a
MOJOSHADER_glViewportInfo(MOJOSHADER_glContext *ctx, float vpHeight, int renderTargetBound);
, but if we're going to the effort of barfing up viewport/target information (as we actually already have in the past with glProgramViewportFlip), perhaps this would be an appropriate time to just make one big function that takes in all the viewport information at once. With this we get full support for VPOS, viewport flipping, and so on, and it also lets us start looking into optional support for half-pixel offset compensation as well, since MonoGame still uses a half-pixel hack and wine-mono would need something like this for D3D9 data as well.So, it seems like the smartest thing to do would be to add something like this:
At the moment I'm mostly looking for feedback; MojoShader is pretty scary so I can be the one to ultimately write it (well, everything except for the half-pixel offset stuff maybe, blech). This will matter to @kg (uses VPOS), @TheSpydog (possibly fighting this in Metal?), and potentially the MG team if they want to update their MojoShader branch at all for the new GLSL emitter (the API call above wouldn't be useful since they do that in MG's GraphicsDevice instead).