Sign in to follow this  

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

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
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

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