Devsh-Graphics-Programming / Nabla

Vulkan, OptiX and CUDA Interoperation Modular Rendering Library and Framework for PC/Linux/Android
http://devsh.eu
Apache License 2.0
463 stars 58 forks source link

Vulkan and OpenGL Coordinate System mismatch and Y-flipped renders #309

Closed Erfan-Ahmadi closed 2 years ago

Erfan-Ahmadi commented 2 years ago

Describe the bug

OpenGL and Vulkan different coordinate systems for framebuffers and clip coordinates cause y-flipped images and inconsistenty in swapchains.

NOTE: We do glClipControl(GL_UPPER_LEFT, GL_ZERO_TO_ONE) in GL

Steps to Reproduce

Example 09 run on both gl and vk and you'll see y is inverted

Expected vs observed behavior

Both APIs for examples should be consistent

devshgraphicsprogramming commented 2 years ago

Idea for a test.

1

Write some sort of a clear mathematical gradient/image defined as a function f(x,y) (the toy path tracer in compute is actually good enough).

2

imageStore(swapchainImage,ivec2(x,y),vec4(f(x,y),1.f))

3

Should yield identical images in Renderdoc debug (if not, find out why).

4

Then find out if presenting the swapchain on Vulkan flips the image compared to Renderdoc debug.

5

Then come up with a way to make OpenGL present behave same way as Vulkan.