Materials for 3D objects?

How can you change the material for a box for example. How can I make something look like glass, or metallic, or like a prism. I’m thinking it has something to do with shaders. but how would I go about programming it? I don’t have much knowledge with shaders.

Here’s an example of what I’m trying to make (made this on my iPhone)
all it is is an image in the background and a 3D object rotating close to the camera, which bends the light and gives it this kaleidoscopic feel.

1 Like

You can apply material to a mesh using ofMaterial, you can find an example here

Or you can write your own shaders, in this case, have a look at this tutorial

1 Like

ofMaterial doesn’t really have what I’m trying to explain in my post. I’m looking for something other than what ofMaterial provides. Like refraction and reflection, or normal mapping. That shader tutorial really doesn’t even touch on the subject.

reflections, refractions… are complex and are usually done with shaders. if you don’t know much about shaders, the tutorial @edapx points out is a good introduction. from there on you can look into other shader tutorials or books on the specific topic

ofMaterial when using opengl 3 or more uses a shader to calculate the lighting but only hsa diffuse and specular lighting values inside it’s code you can find the shader that does it’s calculations wihch can be a reference to understand how lighting is done in a shader once you know a little bit more about it

Hi, @spaghetti

While this may be helpful.

there is this addons seeds compatible with 0.9
who collects a bit of shader to coat Mesh
There are also two / three examples of reflection (very rough but easy to understand).

I’m still learning a lot with OpenGL / GLSL
and all my addons that use GLSL will change soon…


Hi @kashim! I’m trying to run the examples in ofxGLSLMaterial but I’m getting a runtime error when the example tries to load the model.

model.loadModel("models/alduin.obj",true); goes to ofxAssimpModelLoader and throws an EXC_BAD_ACCESS as is the model wasn’t in the bin/data folder.

Any hint on how to make it work?
I’m running it with OF 0.9.3 in XCode 8.0

This also happens with other models?
in example/bin/date/ there are other models

change this:

with this:

I just realized that I had to add / to the path:
Now I don’t get the runtime error but none of the models are drawn. All I can see is the background color.

try to set the OpenGL version 2.1

int main()
    ofGLWindowSettings settings;
    ofRunApp(new ofApp());

Nothing, still just the background color.