#### Archived

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

# Textures and the famous shader system

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

## 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 on other sites
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 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 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 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

1. 1
2. 2
Rutin
20
3. 3
4. 4
frob
14
5. 5

• 12
• 9
• 17
• 18
• 9
• ### Forum Statistics

• Total Topics
632597
• Total Posts
3007329

×