Jump to content
  • Advertisement
Sign in to follow this  
AvengerDr

Engine and materials question

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello there, I'd like to ask the more knowledgeable among you which would be the best approach in the situation that I'm facing. My "mesh" class right now has an array of a generic "Material" type (it's in C#). Upon loading the .X file, it creates enough positions in the array for each subset in the mesh that it encounters. The actual pairing between subset and related material resources is done by reading an xml file which pairs the mesh and textures. The effect to use, right now, it's hard coded and depends on the class of the entity. Right now I only have one effect per mesh.. and actually the material array just only had one slot. So, from the way that you designed your engine, it is a common situation to have multiple effects per mesh? If so how would you organize your mesh class? I'm thinking for example about appying Specular Normal / Parallax Mapping and then a Shadow Map shader for example (although the latter would be applied to all the objects in the scene and just to a single one). But more complex meshes could have different effects. For example in a spaceship case there would be a shader for the surface material and one for the engine exhaust... am I right?

Share this post


Link to post
Share on other sites
Advertisement
Myself I've always favoured a central respository of resources for situations like this. Having each mesh actually own its own resources strikes me as inefficient and not conducive towards cached/optimal state changes.

Instead, having some sort of reference counted repository to store the actual effect instance and then have each mesh hold just the handle/pointer/reference.

This way you can start to hide this problem of multiple effects per mesh - this central repository knows which effect a given technique comes from and can handle any awkward mappings that become necessary. Your mesh code can then remain clean and concise, which is just A Good Thing™ [smile]

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!