TheCodez / dynamic-occupancy-grid-map

Implementation of "A Random Finite Set Approach for Dynamic Occupancy Grid Maps with Real-Time Application"
MIT License
281 stars 39 forks source link

What's does the coordinate transformation in the texture mapping part of the fragment shader mean? #82

Closed RogerChern closed 3 years ago

RogerChern commented 3 years ago

https://github.com/TheCodez/dynamic-occupancy-grid-map/blob/84b9cbf713d8584fc9624de49c64cf373635af69/dogm/demo/simulator/mapping/opengl/shader.cpp#L22-L35

Hi Micheal, many thanks for sharing this wonderful project with the community. When I read the polar to cartesian part of codes, I found the line 32 in the fragment shader quite hard to understand.

vec2 uv = vec2(1.0 - (texCoord0.s / (texCoord0.t + 1e-10)), texCoord0.t);

What is the purpose of the 1 - s / t part, especially when the texture coords are already handled by https://github.com/TheCodez/dynamic-occupancy-grid-map/blob/84b9cbf713d8584fc9624de49c64cf373635af69/dogm/demo/simulator/mapping/opengl/renderer.cpp#L11-L31

Many thanks.

TheCodez commented 3 years ago

Hi, I got this code by asking a question on the Khronos forum. I suggest taking a look: https://community.khronos.org/t/squeeze-rectangular-texture-onto-segment-of-circle/104627 The thread got a great explanation of how it works. I just added the "1.0 -" part to flip the image.

RogerChern commented 3 years ago

I see. Thanks for the fast response.