Saturday, 13 November 2010

Making Things OpenGL 3/4.x compatible (Initial Design Considerations)

Have been re-reading the OpenGL quick reference card again and looking at all the elements that have been deprecated. It would seem that most of the light / material elements have been removed from the "core profile"

As a handy reminder the quick reference card highlights the elements being removed in blue and for this initial design post I'm going to concentrate on the Light / Material / Colour properties here

As you can see all of the Light / Colour elements have been deprecated as well as the materials, this means that we will no longer have any access to these elements in the shader and structures such as gl_LightSource and the colour elements such as gl_FrontMaterial.

So we need to be able to pass both light and colour information to our Fragment shader and then use this in the calculations. This sounds a bit similar to how renderman works so I decided to design the initial system around renderman's lighting model.

In renderman we have a single colour for basic plastic surfaces and access to a global variable called Cs which describes the surface colour (either set by the Color [1,0,0] command or calculated in the shader itself). A full list of these variables are shown in the table below (from the RPS_15 user guide)

The basic renderman shader execution environment is as follows

Whilst we will not have all these variables available in the GLSL shader we can imitate most of it, and make our lights behave in a similar way to the renderman ones. 

The scans below illustrate my initial sketches of a Light class system to add to the new version of ngl:: 

Writing this up more formally I've have this as the initial design of the Light classes

This is going on the back burner for a while as I have loads of other elements to sort out but at least I can bear this in mind whilst re-writing some other parts of ngl::.

No comments:

Post a comment