lwjglgamedev / lwjglbook-leg

Source code of the chapters of the book 3D Game Development with LWJGL 3
https://ahbejarano.gitbook.io/lwjglgamedev/
Apache License 2.0
560 stars 202 forks source link

Distorted textures when using .obj from Blender #31

Closed JTAttack closed 7 years ago

JTAttack commented 7 years ago

Hi I have been having an issue with textures after importing them from Blender. The textures look good inside of blender but when they are in my game they are all distorted. I have tried multiple things to fix this issue but have had no luck. I also made sure all export settings from blender was the same as you said. My code is currently up to date with chapter 15. I have attached the .obj file for the model and a picture of the distorted texture. To test the problem I made a model in Blender (a cube) and UV mapped the grass block texture you supplied. I also compared the model I created to the block.obj model you supplied and while there were difference between some values I don't think they are causing the issue. It should be noted that when using block.obj you supplied the texture looks perfect. Thanks so much for your help and for creating this book. I greatly appreciate it!

# Blender v2.78 (sub 0) OBJ File: '' o Cube v -1.000000 -1.000000 1.000000 v -1.000000 1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v -1.000000 1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v 1.000000 1.000000 1.000000 v 1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -1.000000 vt -0.0053 0.9992 vt 0.4953 0.4986 vt -0.0053 0.4986 vt 0.4965 1.0004 vt -0.0025 0.5014 vt 0.4965 0.5014 vt -0.0044 1.0003 vt 0.4943 0.5016 vt -0.0044 0.5016 vt 0.4976 1.0015 vt -0.0076 0.4963 vt 0.4976 0.4963 vt 0.9976 0.5022 vt 0.5002 0.9996 vt 0.5002 0.5022 vt 0.0001 0.5001 vt 0.4980 0.0022 vt 0.4980 0.5001 vt 0.4953 0.9992 vt -0.0025 1.0004 vt 0.4943 1.0003 vt -0.0076 1.0015 vt 0.9976 0.9996 vt 0.0001 0.0022 vn -1.0000 0.0000 0.0000 vn 0.0000 0.0000 -1.0000 vn 1.0000 0.0000 0.0000 vn 0.0000 0.0000 1.0000 vn 0.0000 -1.0000 0.0000 vn 0.0000 1.0000 0.0000 s off f 2/1/1 3/2/1 1/3/1 f 4/4/2 7/5/2 3/6/2 f 8/7/3 5/8/3 7/9/3 f 6/10/4 1/11/4 5/12/4 f 7/13/5 1/14/5 3/15/5 f 4/16/6 6/17/6 8/18/6 f 2/1/1 4/19/1 3/2/1 f 4/4/2 8/20/2 7/5/2 f 8/7/3 6/21/3 5/8/3 f 6/10/4 2/22/4 1/11/4 f 7/13/5 5/23/5 1/14/5 f 4/16/6 2/24/6 6/17/6

testblock_in_game
lwjglgamedev commented 7 years ago

I guess, that you did not split edges in blender. This is needed in order to render textures correctly. In any case, you may try chapter27 which uses assimp for model loading.

Let me know if this helps.

JTAttack commented 7 years ago

Thank you so much. I have re-read that tutorial so many times to try to find my problem but someone missed that each time. Thank you so much for taking the time to answer my question! Love the book!

lwjglgamedev commented 7 years ago

You're welcome !