[Solved] Custom shader on assimp .obj model won't work


#1

Hey,

So I have this .obj model on which I want to run a custom shader, but it simply display the gray 3D model like if the shader wasn’t loaded at all.
I have no error, and it’s working fine with any other 3D primitive.
Also if I simply use texture.bind() and texture.unbind(), the texture is correctly applied (the .obj have its v, vt, and vn properties).

// setup
  shader.load("shader.vert", "shader.frag");
  model.loadModel("mymodel.obj", false);

// draw
  shader.begin();
  model.draw(OF_MESH_FILL); // boring gray model
  plane.draw(); // shader works as expected
  shader.end();

Somebody have any insight on this ?
Thanks !


#2

What happens if you try your shader with another model? it it works with the primitives, and it works with another model, then it is a problem in the way the model is created.
btw, draw(OF_MESH_FILL) and drawFaces() are the same thing


#3

Yeah, I’ve tried with a whole batch of models with the same result.
Using getMesh() seems to work but the meshes are very small.

Nonetheless it is still weird that I can use texture.bind() or setColor() on a model but not a shader (even a basic red color shader produces the same output) … :thinking:


#4

Ok so I got it !

I went and look into the ofxAssimpModelLoader source and found this that was presumably overriding my shader :

I added model.disableMaterials(); and it works now :ok_hand: