Game Development Community

Shaders

by Martin Wedvich · in Technical Issues · 01/20/2003 (5:00 am) · 37 replies

How do I code in pixel shaders into my game? The models will have a quite high polygon count, but I've seen doom which is without shaders, and it looks great, but the lighting are quite weird on some of the models. So I want to use pixel shaders. Again, how do I code this? Do I have to get the DirectX 8.1 or 9.0 SDK or...?

About the author

Recent Threads

Page«First 1 2 Next»
#21
02/09/2003 (9:32 am)
Martin, Doom 3 is using shaders. John C. has said as much in his .plan and in several interviews.

You can turn them off for increased performance, but doom 3 _definately_ uses them.
#22
02/09/2003 (9:51 am)
Doom 3 is using several versions of shader implimentation. OpenGL ARB2, NV, EXT. Which are GL2, NVidia Extensions, ATI Extensions. I do not understand what the confusion is when people think, "Oh Doom 3 isn't using shaders," have you seen the screenshots? That is not out-of-the-box GL stuff. Now pipe down about shaders before I get my big-foam-nerf-bat out
#23
02/09/2003 (5:01 pm)
Ok now that this group has decided that DOOM III is using shaders, what about answering the guys question about learning how to use shaders that made this post in the first place.

First of all the concept of shaders is very simple to understand if you already understand how basic 3D graphis work, which I am assuming you do if you plan on creating shaders. I am going to talk about this subject from a DirectX 9 point of view, because that is the API I am most comfortable with, but you can use OpenGL.

A shader is just a small program that executes for every vertex(Vertex Shaders) or every pixel(Pixel Shaders or Fragment Shader) in a stream. Now what is a stream you say.

[b]"Microsoft
#24
07/25/2003 (3:25 pm)
This thread is a bit old but as no-one did answer the question about how to integrate shaders with torque (we hope he meant torque anyway!) Here is the brief rundown.

First off you need to modify the wingl files to support ARB_fragment_program and ARB_vertex_program. Because GL fragment programs effectively use all of the functions for the vertex programs you can't have one without the other so simply grab all the relevant function prototypes and #defines from the 1.4 glext.h file and place them into the wingl file. You may need to modify them slightly to turn them into typedef'ed function pointers an example would be

typedef void (GLAPIENTRY * glVertexAttrib1dARB_t) (GLuint, GLdouble);
glVertexAttribute1dARB_t glVertexAttribute1dARB;

to map the glVertexAttribute1dARB procedure. You will then need to do a test for the extention at startup. You would need to place your test in the QGL_Init function in the wingl file and disable your fragment programs if this test fails.

Once this is done (should take you no more than a few hours). You can start to add shaders to replace the materials that are normally used by torque shapes. As shaders are effectively effects that are used on textures (materials) or for skinning models. Replacing the textures used in torque with shaders seems a good use for them.

Hope this helps (if anyone reads it :p)
#25
07/26/2003 (12:21 am)
Forgot to add that if you want to add vertex shaders you need to do this at the mesh level.
#26
08/16/2003 (1:01 pm)
Yeah, I don't think I will add Pixel Shaders. To complex... But I think I'll use Vertex Shaders. The game I'm currently making, Terra Incognita, will have a quite high poly count so taking away some of the processor's weight and give it to the 3d card would help on the overall performance, I think.
#27
08/16/2003 (6:36 pm)
You don't have to use a vertex shader to get vertex processing done on the GPU. Use vertex buffers and you're golden.
#28
11/08/2003 (3:05 pm)
Can I have cel shading in Torque? and can I have control over outline weight? and shader type i.e. Cross hatching, pointalism, and halftone dotting? I want to make a comic book inspired game, and it is important to apply these 2d effects. I have seen a great shader called toonshade http://www.toonshade.com/index.htm Can this be done in Torque? What would I need to learn. or who would I hve to hire to apply these features to my Torque game?

It's a Maya Pugin, so does that mean if I use Maya for model creation, that I can "import" these into my Torque game? I would want the entire game to have this effect... all the models, the sky even...
#29
12/11/2003 (2:06 pm)
Gareth: When you say that there is no set way of doing shaders in OpenGL do you mean that there is no shading language? OpenGL Shadinge Language (or OGLSlang) has been out for a while (even though I just found out about it). I haven't thoroughly looked into it yet. However, it comes with the language definitions and how to write shaders in OGLSlang. It is a very C like syntax and thus should be similar to HLSL and CG. I'm sure that in order to use this with Torque one would have to modifiy or even rewrite the OGL renderer that Torque uses. Well, I have been looking into this, and I don't know if anyone else has (I'm sure someone is). I do know that someone has done shaders in Torque via Cg. They haven't released it as a resource, but I have seen the pics and movies somewhere on this site.
#30
12/11/2003 (5:24 pm)
Trane,
None of these effects are in Torque. It would be technically possible to add them, but some of those are rather complicated programming tasks. It would take a great deal of work to get it going. The maya exporter would not support such things at current, either. So that would have to be custom programmed.
#31
12/12/2003 (9:52 am)
Ok,
I appreciate the help. As much as I love Torque and it's generous licensing, I require cel-shading. I have found it with quest3D, and though it's not a game engine persay... it does what I need. Networking, cel-shading, ODE physics, zero royalties, etc...

I have recently played XIII, and it's the closest to what I want to do, but I can't afford the UT commercial license.
#32
12/12/2003 (9:55 am)
Didnt the developers of the "DogsOfPrey" game release cel-shading? Dont have the url right now, but i think they have it on their site.
#33
12/12/2003 (3:18 pm)
For what it's worth, I don't believe that the base UT engine supports cel shading or even shaders at the moment. Teams like Splinter Cell, Deus Ex II, and XIII modified the engine to support what they needed.
#34
01/29/2004 (5:55 pm)
Would that particular "tweak" of the UT engine be something that they would license? I really like the look of XIII! It's EXACTLY what I want to accomplish.
#35
01/30/2004 (11:21 am)
XIII has super cool sytle, they really did a great job of bringing the comic book feel to a game, especially with the framed cutscenes. I really doubt they would license their look for many reasons. There are lots of ways to do toon shading, even without using the latest shader pipelines. I don't think the Torque would be especially difficult to change to take advantage of it. If you want to do your own research, check out the developer areas on the nVIDIA and ATI sites as well as the many academic papers on non-photorealistic rendering available from a google search.
#36
01/30/2004 (12:37 pm)
Phil Said:
Quote:
Guys, shaders are more of an architectural change than necassarily a platform issue. When I say shaders i mean using a description file of some sort (normally termed a shader) to determine surface attributes (textures, combiners etc).

Its quite possible, and possibly quite likely, that shaders CAN be implemented in a cross platform manner. Essentially taking a high level description (lets say HLSL) and either

a: parsing it yourself on mac/linux
b: passing it to DX under DX9
c: parsing it and emitting fragment programs under GL on PC.

Most of the parsing could actually be done at install time (essentially the install program detects the shader library to install, which can read its own intermediate format, lets say its like a bytecode version of a shader file).

If you write a shader library that can take in a high level description, write out HLSL, GL vertex fragment programs AND fixed function pipeline calls please let me know! :))

Phil.

If nay one is interested they can download the compiler front end code for the GL shading Language from 3D Labs...

http://www.3dlabs.com/support/developer/ogl2/downloads/index.htm

so you can use GL Shading Language as the common language and write different backends for retargettable shaders
#37
02/22/2004 (1:36 pm)
If someone wishes to make shaders check out http://www.shaderworks.com/ it makes shaders FUN!
Page«First 1 2 Next»