Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Nirklas

Textures and the famous shader system

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

I, like many other here, have put some thought into an own implementation of the shader system first discussed in the all famous material/shader thread. There is one big issue though that I haven''t been able to figure out. As far as I understand parameters like texture IDs and such are stored together with vertexstreams on a per "GeometryChunk" basis. This is where I''m hoping someone would jump in and correct me, because I can think of several scenarios where you would want to to define textureIDs on a per instance basis. (ie. diferent clothing on characters etc.) Hmm, I just realize that i MUST have missed something, because there is a lot more that you would want on a per instance basis, translation-matrix and animation-parameters to just mention the obvious ones. Could someone please enlighten me. How do I send these to the shader in a way that doesn''t break the neat, loose dependency between the shaders and the object to be rendered? One more thing while I''m on the subject. Have anyone come up with a (relatively) fast way to let the user disable certain "effects" (reflections, bump, etc). ...ingame preferably. I''m loking forward to acctually begin implementing this stuff when these last pieces fall in place

Share this post


Link to post
Share on other sites
Advertisement
You simply keep a structure within the geometry chunk which holds the parameters you wish to pass. Then you simply create a new Geometry chunk which points to the same vertex streams, but a different parameter structure.

Simple!

James

Share this post


Link to post
Share on other sites
Right, but then that structure of parameters have to be all-inclusive so to speak, no? Since it''s not connected to the effect?

When you say a "geometry chunk" you mean a renderable entity in the scenegraph right?

thanks for the quick reply btw =)

Share this post


Link to post
Share on other sites
I think i just came up with something.

the effect-class provides access to the vertex-streams, with offsets to each specific stream, and stride (or size).

Why not keep an effect-allocated piece of data in each geometrychunk (renderable entity) and have a similar mechanism to provide access to the specific parameters. Eg. when a new entity is created a piece of data is allocated, size determined by the attached effect. That way I just need enough memory to hold the parameters required by the effect. and access it like this

gc->pEffectData[effect->getParamOffset(EPO_TEXTUREID_DIFFUSE1)];


how does that sound?

[edited by - nirklas on June 7, 2004 5:31:03 PM]

Share this post


Link to post
Share on other sites
Yes when I say geometry chunk I do mean a renderable entity. So what I mean is that the data can be instanced by multiple geometry chunks, allowing different parameters.

Well since the parameters required are dependant upon the effect then you can lay out the parameters however you want. Obviously you may find that some parameters are used in pretty much all cases, here you could provide a specific variable, but the rest can be placed into a stream of data in the same way, as the vertex data.

Note that you can ''abuse'' the system for stuff like GUI rendering. I simply put the text string into the ''vertex data'' and then generate the output in the shader(currently indexs into display lists but this could be changed to textured quads, or any other implementation you care to come up with).

James

Share this post


Link to post
Share on other sites

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