• Advertisement

Archived

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

Starting out with shader system...

This topic is 5022 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'm getting to the point in my 3D engine/level editor where I need to implement texturing/surfaces/shaders. In the past I have implemented simple surface texturing, but that's old hat, and in this new incarnation, I would like to have a shader system. I know, from experience with Quake III, that a shader has stages (even if it only has one), and that stages have certain attributes. These can be texture maps, bumpmaps, vertex and fragment programs, etc. Quake III implements it's shaders as scripts. I'm not if this is the current method or not, as Quake III is obviously getting on a bit. I've heard talk of *.fx files, and I think that might be what I'm describing. The system I'm thinking about is like this: I write a little visual program. This program creates shaders, and each shader has stages, as described above. The program saves each shader to a \base\shaders\ directory. Each shader is a file, and each stage is saved to that file. The stage's attributes are saved as filenames. That way, I can have all the texture maps in one place (base\textures), all the bump maps in one place (base\bumpmaps), etc. My level editor would load each shader file, parse it, and load just the first stage's texture map, or something. When I apply a shader to a brush face or a model, it saves only the filename of the shader file it uses (all the other stuff, like offsets and rotation and scaling is saved in a CSurface structure inside the face or model or whatever). The engine then loads compiled maps, along with all the shaders in the shaders directory. All the geometry will be sorted by shader. The first shader stage is loaded, it's textures and programs bound, etc. and the the geometry is drawn. Then the second stage is loaded and drawn, and so on. Perhaps instead of just having the filenames of the texture maps and stuff saved in the shader files, I could save the files themselves? I just thought that if I was going to be using a texture map more than once, it would be inefficent to have it saved twice in two shader files. Any comments on the system above are much appreciated, and I'll do some more searches around this forum to pick up some more info... [edited by - iNsAn1tY on April 16, 2004 9:37:59 AM]

Share this post


Link to post
Share on other sites
Advertisement
Seriously, even if someone can just say yes or no to the above method, and give a few reasons, I''d be happy...

Share this post


Link to post
Share on other sites
Two methods have I see formulated on this forum, either a plugabble DLL approach ( aka Yann, Darkwing too I think ), or a script-based approach ( what I''m using ).

Firstly though, I wouldn''t worry about how to represent the shaders outside the engine, but how to design the construction of it. For this, read the links provided above, they''re great.

You have to remember that you''re unique, just like everybody else.

Share this post


Link to post
Share on other sites
The first thing to do is learn and play with shaders themselves, and notably the D3DX effects system. Once you learn how things work, you can design around it relatively easily. Hit the links above, and the DX docs (if you''re using DX), and play with it.

I like pie.

Share this post


Link to post
Share on other sites
quote:
Original post by python_regious
or a script-based approach ( what I''m using ).



how does your script based shader-system work? like the Q3A shaders?

Share this post


Link to post
Share on other sites
quote:
Original post by McZ
quote:
Original post by python_regious
or a script-based approach ( what I''m using ).



how does your script based shader-system work? like the Q3A shaders?




In the sense that they are scripts and are compiled into datastructures at loadtime, yes.

In syntax, or features? No.


You have to remember that you''re unique, just like everybody else.

Share this post


Link to post
Share on other sites

  • Advertisement