Replacements for gl::Material and gl::Light?

Hey all –

I needed to be able to import 3d models for a project, so I’m doing some excavation and bringing Cinder-Assimp up to date with Assimp 5.0 and Cinder v0.9.3. The updated (mostly working) code is here

It hasn’t been too complicated so far and most of the old code is still compatible with the latest versions of everything; the only tricky part for me now is figuring out how to replace the old sections that use gl::Light and gl::Material classes. I initially just ripped them out to get them working, but now my 3d models look like this:

So it looks we’re back to the drawing board and adding lighting and materials!

I can’t find anything about these in the cinder docs, in the github, or even in this forum… so it looks like they were probably removed before the migration to discourse, and most of the old samples have been lost to time.

Is there a guide anywhere for how to port the old classes to new cinder? I’m assuming that they were deprecated and you should just use straight OpenGL now, but I’m not quite sure what functionality the old classes provided.

These map to old fixed function pipeline opengl functions that have long sinc been deprecated, e.g glMaterial.

Once OpenGL and eventually cinder moved to the programmable pipeline, lighting and materials became the job of your shaders. The good news is from memory the deprecated GL materials were pretty crappy gouraud shading so they’re pretty trivial to reimplement.

The Geometry sample has a simple phong shader that will get you most of the way there, or if you just need a really quick and dirty lambertian shader just to visualise your models you can always use gl::getStockShader ( gl::ShaderDef().lambert() ) );

*edit Started thinking, surely someone else had come across this issue before when migrating to modern gl and sure enough, i found a shader implementation of the deprecated lighting and material model here. (all the way at the bottom)

1 Like

Thanks as always – you’re a lifesaver! The pointer towards the Geometry sample helped me get everything up and running!