Aggregation between the shader and the Rendermanager.

Started by
4 comments, last by DoomAngel 16 years, 9 months ago
Hi every body: I want to ask about the aggregation between the shader and the Rendermanager. i want to manage all my render opperation by using my shader pipeline. I want to use a complicated effects like lighting by multi light and bump with specular and so on.. i'v started using the following structures: SimpleMesh / \ ReflectionMesh BumpSimpleMesh so all my simple mesh has a shader file "*.fx" and each one deal with it's shader program by it's way. but when any mesh (like BumpSimpleMesh) wanted to use the refelection property so i'v to create a new simple mesh and reimplement the effect for reflection properties and so I've to write a new effect for the new simplemesh. but I want to use the shader in a more flexibility way so i haven't to implement the effect more than once so could anybody help me and give me a suggestion to make a good and flexible way to aggregate the shader with the rendermanager. any help will be appreciated. Thx. [Edited by - DoomAngel on July 17, 2007 7:33:00 AM]
Advertisement
any help..???
did I put it in the wrong position..?????
Quote:
SimpleMesh
/ ReflectionMesh BumpSimpleMesh

Are these classes? If so, this seems extremely inflexible.

I would organize the system differently. You've got your basic mesh class, which has a bunch of geometry data. You create "instance" objects (MeshInstance), which refer to that mesh and contain per-instance data (world transform, textures, the shader used and properties for that shader). With some careful though this can be generalized so that you just have RenderInstances that refer to RenderPrimitive objects, so you don't need to reinvent the entire system if you need to support basic renderables other than meshes at a later date.

What you actually feed to the rendering pipeline are your instance objects, which use the basic mesh (render primitive) object only as a place to pull the actual geometry data. All per-instance information is stored with the lighter-weight instance objects.

The render pipeline binds the shader specified by the instance, binds all properties specified by the instance to the shader, and draws the geometry specified by the render primitive.

This is signifigantly more flexible (although in truth, more up-front work to implement) than a "one class per mesh, per effect" approach you seem to be taking which will suffer from severe maintainence issues and a combinatorical explosion of classes and perhaps dependancies.
thanks jpetrie.

firstlly..
SimpleMesh
/ \
ReflectionMesh BumpSimpleMesh
of course this is classes.

i know that each object which share the same model must not load the model more than once coz that will explode the memory.

I think you mean that i've to send the render message to the RenderManager by determine the following:
1- the mesh i want to render.
2- the effects properties like (use lightmap, use bump map,.....etc).
3- pos,rotation and scale.
4- textures.
and the Renderer have to do the rest...


but i want to ask how can I implement the merging of all the effect together?

have I to implement more than one technique like:

technique lightedReflection
{
}
technique Refelection
{
}
...etc.

or I have to use multiple passes..
I'm confussed about how can I implement this.
Quote:
but i want to ask how can I implement the merging of all the effect together?

have I to implement more than one technique like:

technique lightedReflection
{
}
technique Refelection
{
}
...etc.

or I have to use multiple passes..
I'm confussed about how can I implement this.

This generally involves multiple passes, or higher level preprocessor (building the actual shader used at runtime/precompile time by selectively enabling/disabling code paths via the shader compiler's preprocessor, or manually building up the shader code). It's not a trivial operation.

Look into shader metaprogramming and the "ubershader" concept, that might help.
thank you again jpetrie.

I will read about those concepts.

This topic is closed to new replies.

Advertisement