Jump to content
  • Advertisement
Sign in to follow this  
CodeBoyCjy

How to load 3d model with shader from file???

This topic is 4076 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

Hey (first , sorry for my poor English) Some complicated game applies a lot shader scripts into one mesh object.How do they do it??? Suppose there are two type of 3d object A and B , there are three A and two B in the scene, I want to get a class to load them , do I need to write two class , each for one type , or I just need to write one class to load different object.The first choice seems easy to do , but if there are two many objects ,I have to write a huge number of class , it's not going be true.I guess the second choice is the one most people choose , but each shader script has its own parameters , Always different shader have different parameters , HOW can I write a class to load all of the object with shaders???? I appreicate your help!!!!!( The problem realy confuses me for quite a long time!!!!)

Share this post


Link to post
Share on other sites
Advertisement
Back when games were graphically "easy" there were a few "kinds" of object, maybe more or less hardcoded. To a certain degree, there is still the need for different "kinds" of objects: transparent polys for example are drawn differently and need to be sorted in a different way.

With the complexity growing, you cannot have one "class" for each "kind". Then, you group all the objects in "super-kinds", allowing some degree of programmability.
For example: all terrains must have 2^n+1 samples, but you don't care what is the heightmap.
Another example: all player polys must have a POTD texture, but you can change it.

Then, it isn't considerably different to have different shaders.

There's usually an engine layer to allow the system to be "data driven". In the case of shaders, you may - say - read a file and pull out a shader bytecode to send to the runtime.

Maybe take a look at .fx files.

In other terms, you cannot simply "write a class". There could be some hard work to do depending on your system and some architectural decisions shall be made according to your app's architecture.

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!