overdev / raylib-py

A Python binding for the great C library raylib.
Other
206 stars 18 forks source link

Model Texturing Bug #3

Closed Pebaz closed 1 year ago

Pebaz commented 5 years ago

Problem Statement: examples/models/models_heightmap.py shows that textures are not applied when rendering models.

Raylib-C Equivalent Example (Shows darkened edges of the model due to texture used): image

Raylib-Py Example of Issue (Shows that the model is completely red instead of using the texture): image

Pebaz commented 5 years ago

I have searched through the Raylib-Py source and as far as I can tell, all of the bindings are correctly structured. Functions that work are structured the exact same as the functions pertaining to this rendering bug. Not sure why a model using the same example code as Raylib-C would not show it's texture.

I will dig more into this. If you have thoughts on this please share them! 😄

SolarLune commented 5 years ago

Are your two builds of raylib using the same version? Maybe something was changed in the model drawing system to account for this.

Pebaz commented 5 years ago

Thanks for the idea!

I checked it out and found:

  1. Raylib-C was using v2 MingW
  2. Raylib-Py was using v2 MingW (But Python is MSVC...?)
  3. Raylib-Py cannot see exposed functions contained in MSVC raylib_shared.dll
  4. I even loaded the DLL into DllExportViewerand it cannot see any of the functions...

My best guess is that the Raylib 2.0 MSVC pre-compiled binary is somehow flawed if DllExportViewer cannot even see functions exposed within it.

I will try to compile Raylib on MSVC from source and see if I can get Python/DllExportViewer to see it.

-Sam

Pebaz commented 5 years ago

I compiled and tested the x64 MSVC version to to avail. Not sure where to go from here.

overdev commented 5 years ago

Hi, @Pebaz! Sorry for the delay, didn't have much time lately to answer.

Oh, I don't have enough knowledge on compilers, build systems and stuff like this, and I have no idea if this might be the cause but the dll shipped with raylib-py is a custom one. I built it in my computer to add a few extra draw functions, wich will be officially available in the 2.5 release.

@SolarLune Thanks for the info! It is always good to have people who know better around. :sweat_smile:

Pebaz commented 5 years ago

No worries!

Has anyone gotten this particular example (examples/models/models_heightmap.py) to texture properly?

If someone has, maybe we can go from there (find out library, Python, and system architecture, what compiler, etc.).

raysan5 commented 5 years ago

Not sure but this issue seems related to library versions mixing... latest raylib manages texturing in a different way than raylib 2.0...

flipcoder commented 5 years ago

I just did some investigating. I traced the OpenGL calls of the program with the following line both commented and uncommented.

    model.material.maps[MAP_DIFFUSE].texture = texture

I rendered it for a single frame and diffed the two traces, no difference.

So that line seems to have no effect on raylib's rendering whatsoever. Not sure how much this helps but it's more information.

electronstudio commented 5 years ago

Is there any version of raylib-py (or raylib dll) I can use that is able to texture models? I don't need the latest advanced features but not having textures is something of a showstopper to my game development.

Pebaz commented 5 years ago

@electronstudio I was not able to get any version of the DLL to work. As far as I am concerned, I cannot continue to use Raylib-Py without being able to texture a 3D model. If anyone has been able to get this example to work, it would be helpful to hear from them.

electronstudio commented 5 years ago

Good news: I got it working.

image

Bad news: I had to rewrite everything from scratch.

Will post it when I've cleaned up it.

electronstudio commented 5 years ago

Here: https://github.com/electronstudio/raylib-python-cffi

It works on my Mac and I've included the Mac binary but I don't have build systems setup for Windows and Linux.

Pebaz commented 5 years ago

Fantastic work!