Sorry if this seems like a real basic question, or if it’s been covered before, but a quick search didn’t turn much up for me.
I’m a Blender newbie, but have had a lot of experience with OpenGL programming. I have started looking at Blender to use as a modeller and have started a Python script to export the models in my own defined format so that I can read the data into an OpenGL application I’m working on.
My question concerns the Blender material properties. There are a lot of them. Many of the properties of the materials can be achieved by various techniques in OpenGL. Right now, I’m not planning on implementing any of these. For now, I just want to have the basic OpenGL material properties exported. The problem is, there doesn’t seem to be a good 1 to 1 mapping of the Blender material properties to OpenGL material properties.
For those unfamiliar with OpenGL materials, it has the following properties:
Ambient: An RGBA value that specifies the color of the reflected ambient light
Diffuse: An RGBA value that specifies the color of the reflected diffuse light
Specular: An RGBA value that specifies the color of the reflected specular light
Emission: An RGBA value that specifies the color of the emitted light
Shininess: A value in the range [0-128] that is used to determine the amount of the specular light component.
Right now, the way I’m converting the Blender material to the OpenGL materials is something like so…
# PseudoCode
# Should this be multiplied by BMat.amb?
GLMat.Ambient = [BMat.rgbCol[0], BMat.rgbCol[1], BMat.rgbCol[2], BMat.alpha]
# These two are easy enough...
GLMat.Diffuse = [BMat.rgbCol[0], BMat.rgbCol[1], BMat.rgbCol[2], BMat.alpha]
GLMat.Specular = [BMat.specCol[0], BMat.specCol[1], BMat.specCol[2], BMat.specTransparency]
# Not sure on this one. rgbCol * emit?
GLMat.Emission = ?
# Is this one BMat.hard, BMat.spec or some combination?
GLMat.shininess = BMat.hard / 2
Also, where does the mirror color fit in? It seems like it could potentially correspond to the ambient light in OpenGL, but I’m not sure.
I’m sure my conversion method will at least get the material close, but I’d like to make sure that I’m not missing anything obvious. I’d like to have the material look as close to the same in both OpenGL and Blender as possible.