<p>I cannot figure out how to fix this bug elegantly. Instead, I just made it so that rectangular textures are made square by padding with black pixels before computing, and then cropping the output from square back to rectangular.</p>
<p><a href="https://i.sstatic.net/E4KywM2Z.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E4KywM2Z.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2024-08-01T20:30:49.790Z
2024-09-02T01:48:14.967Z
2024-09-02T01:48:14.967Z
shawn_halayka
<p>I'm having a bit of trouble with using rectangular textures on my nvidia 3060 GPU. Everything works well when using square textures.</p>
<p>The small GLSL compute shader code and small C++ code can be found at: <a href="https://github.com/sjhalayka/light_blocking_asymmetric" rel="nofollow noreferrer">https://github.com/sjhalayka/light_blocking_asymmetric</a></p>
<p>I've done my best to make the code as simple as possible. Is there a small bug, or a feature that I'm missing? Thanks for your time and expertise.</p>
<p>Rectangular texture (undesired, sheared lighting):</p>
<p><a href="https://i.sstatic.net/2AdED1M6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/2AdED1M6.png" alt="Rectangular texture" /></a></p>
<p>Square texture (desired lighting):</p>
<p><a href="https://i.sstatic.net/6MeeJrBM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/6MeeJrBM.png" alt="Square texture" /></a></p>

CC BY-SA 4.0
2024-10-02T09:37:26.310Z
The "rectangular" image looks like the height is being used for the width for drawing the lit area. So potentially height and width are being transposed somewhere. On a square texture if height and width are swapped it won't matter.
pmw1234
CC BY-SA 4.0
2024-10-02T16:38:20.003Z
Thank you for your guidance and time. I ended up going with square power-of-two textures so that I can do a tile-based renderer. I thank you for pointing out my error.
shawn_halayka
<opengl><c++>
Rectangular texture issue -- OpenGL C++
shawn_halayka
# Rectangular texture issue -- OpenGL C++

(Asked by: username_0 on 2024-07-31)

I'm having a bit of trouble with using rectangular textures on my nvidia 3060 GPU. Everything works well when using square textures.

The small GLSL compute shader code and small C++ code can be found at: <https://github.com/sjhalayka/light_blocking_asymmetric>

I've done my best to make the code as simple as possible. Is there a small bug, or a feature that I'm missing? Thanks for your time and expertise.

Rectangular texture (undesired, sheared lighting):

[![Rectangular texture](https://i.sstatic.net/2AdED1M6.png)](https://i.sstatic.net/2AdED1M6.png)

Square texture (desired lighting):

[![Square texture](https://i.sstatic.net/6MeeJrBM.png)](https://i.sstatic.net/6MeeJrBM.png)

**Tags:** opengl, c++

> **Comments:**
> **username_1**: The "rectangular" image looks like the height is being used for the width for drawing the lit area. So potentially height and width are being transposed somewhere. On a square texture if height and width are swapped it won't matter.  
> **username_0**: Thank you for your guidance and time. I ended up going with square power-of-two textures so that I can do a tile-based renderer. I thank you for pointing out my error.  

---

## 1 answers

### Answer by username_0 on 2024-08-01. Score: 0

I cannot figure out how to fix this bug elegantly. Instead, I just made it so that rectangular textures are made square by padding with black pixels before computing, and then cropping the output from square back to rectangular.

[![enter image description here](https://i.sstatic.net/E4KywM2Z.png)](https://i.sstatic.net/E4KywM2Z.png)


---

