Sign in to follow this  
dhm

CgFX Material System

Recommended Posts

Hi All, I am in the process of designing and prototyping a material system for my simple graphics renderer(s). I have a renderer-independent scene graph which contains transform nodes, and geometry nodes etc. I want some of the geometry nodes to have material support (e.g. triangles, quads etc.). I am hoping to utilise NVidia's CgFX. This should allow me to have fixed-function and programable pipeline materials. I have read various other threads about material systems but wanted to try another approach (sorry if something similar has already been covered - any links appreciated!). Any comments about the design are gratefully appreciated. Basically I will have a Material class. This will support loading an effect from a CgFX file (containing several techniques) and then utilising the best technique for the current target hardware (e.g. I have an OpenGL 1.1 and 2.0 renderers with a DirectX 9 renderer planned). The Material class will support: 1. Binding and Unbinding the material 2. Setting CgFX parameters (if required) 3. Cg error information Managing the Material objects I will have a Material Manager. This will be responsible for creating materials and creating handles for the materials. These handles will be used to reference the material by geometry objects being renderered (e.g. triangles, quads etc. which I have already defined). I am hoping that this will give me a lot of flexibility in terms of rendering objects with various effects or just with plain textures (I already have a Texture class and associated Texture Manager which operates in the same manner). Am I correct in saying colour, texture and lighting information can be set by the usual OpenGL calls (glLight*, glBindTexture, glColor*) for the CgFX shader programs to read them as it were? My main aim is to provide effects for normal mapping, multi-texturing, post-processing effects and some image processing techniques (in the future I would like to be able to add to these by supplying new CgFX files). Is this possible with this approach? I see in Irrlicht there is an enum of different material types and that lighting information is supplied directly as part of the material class. Does this not restrict it quite a lot? I also noticed that it carries state information which I believe CgFX files support so I would hopefully not require this in my Material class. Apologies for the length of post. Any comments/suggestions/criticism welcome. Has anyone used CgFX for a similar purpose? Cheers, dhm

Share this post


Link to post
Share on other sites
Update:

After thinking a little last night I thought I should add this.

I was planning on having lights specified as nodes in the Scene Graph. This will require passing lighting information to each material. So I think I will need to add this lighting information to the Material class.

Then each piece of geometry will be rendered possibly several times depending on how many lights affect it. So I would not pass lighting information using the glLight* function - but texturing and colour information should still be ok.

Any comments?

Cheers,
dhm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this