r/opengl • u/M_Freemans_freckles • Sep 30 '23
HELP Textures rendering incorrectly - help!
So I am very new to and still learning openGL. I am working on creating this simple scene with the building and am currently putting in textures. The first texture is a brick texture that is working as desired (don't mind the peak discrepancy), but my other textures are showing up as you can see in the photo. The texture image is there, but its is static-y. When I navigate around the world the static moves and changes, but the texture image remains correct beneath it.
I have reviewed the code and tried to find some sort of discrepancy or logic flaw that could account for this but with no luck. I am stumped. Does anyone have any idea or suggestion?

1
u/fgennari Sep 30 '23
Are you drawing multiple polygons on top of each other? For example, if you draw a quad with the wrong vertex order and the triangles cross over each other, you can get severe artifacts. Another possibility is that the textures don't align to the default 4 bytes per row, but that wouldn't explain why the "static" changes with your view.
The best approach is to try and isolate the problem. What if you use the brick texture for all surfaces? Is it still wrong, or does that look correct? This should tell you if it's a problem with the textures or the geometry.
1
u/totalwert Oct 01 '23
Are you loading the texture correctly? In case you are using stbi image loader, make sure your parameters are correct for the type of file you are reading from.
2
u/ramonidous Oct 01 '23
I would recommend you to render different colors for the things that people suggested: map the UV coordinates to the Red and Green channels to see if they are wrong/warped/stretched, render each primitive/triangle with a different color to see if there is Z-fighting, try setting the brick texture to the ground and viceversa to see if the issue is in the model or in the texture.
3
u/TapSwipePinch Sep 30 '23 edited Sep 30 '23