Jump to content

A good place to learn how to make shaders?


Recommended Posts

Yes i know about the shader manual but i don't want to have to read through the entire 20+ page thing just to find one particular shader.  Like i want to, for example, know how to make my own glass shader(s) or env (if possible) shaders.

 

My problem is that i don't like to use pre-made textures and such, i prefer to make my own content even if it means having to learn a load of stuff in order to do it.  I have tried looking at the shaders of the game for reference but i can't seem to cross reference textures to matching shaders in order to see how they work.

Link to comment

Shaders are pretty close to how graphics hardware works - or used to work 10 years ago, it learned some new tricks since then.

 

You'll basically want to learn about blending (see glBlendFunc), the depth buffer (or z-buffer) and how it doesn't support transparency very well (which explains why you see so much blendFunc GL_ONE GL_ONE in shaders and what depthWrite and depthFunc are all about and kind of plays into alphaFunc as well) and then it's just a matter of understanding that all the stages in a shader are drawn in sequence. And it helps to know about vertex colors and understand that they can be used for lighting (which is particularly used in misc_model without spawnflag 4) or blending (for alpha-blended terrain).

 

Well, and then there's surfaceparms and q3map2 specific keywords and a couple of other things, but understanding how the stages work is the most important part.

Link to comment

A good way to use the shader manual, could be to look at textures from the game, for example the textures/common glass shaders, and searching for the keywords you don't understand in the shader manual, rather than reading it all in one go.

Link to comment

I found the best way (for me anyway) was to look at other shaders I liked, messed around with them with other shaders, removed parts and try to understand what happens. After that, I looked at the shader manual to understand various parts, and try more things out.

Link to comment

A good way to use the shader manual, could be to look at textures from the game, for example the textures/common glass shaders, and searching for the keywords you don't understand in the shader manual, rather than reading it all in one go.

 

 

I tried to do a search but it's all titled and you have to click on the title to even open the page:

http://toolz.nexuizninjaz.com/shader/shader/index.html

 

As you can see it merely lists the topics, it doesn't really let you search for words unless you're talking about a different manual :unsure:   As i said before, i did try to look at various textures from the game and then look for the shaders that accompanied them but i couldn't find any or they were in some large text file.

 

Shaders are pretty close to how graphics hardware works - or used to work 10 years ago, it learned some new tricks since then.

 

You'll basically want to learn about blending (see glBlendFunc), the depth buffer (or z-buffer) and how it doesn't support transparency very well (which explains why you see so much blendFunc GL_ONE GL_ONE in shaders and what depthWrite and depthFunc are all about and kind of plays into alphaFunc as well) and then it's just a matter of understanding that all the stages in a shader are drawn in sequence. And it helps to know about vertex colors and understand that they can be used for lighting (which is particularly used in misc_model without spawnflag 4) or blending (for alpha-blended terrain).

 

Well, and then there's surfaceparms and q3map2 specific keywords and a couple of other things, but understanding how the stages work is the most important part.

 

 

When you say stages it sounds more like an animation than a visual effect lol.

Link to comment

As mrwonko said, shaders correspond to things going on at a hardware level. Each stage essentially has a map (either an image or a reserved word such as $lightmap) and a blendFunc, as well as some other things. The stages are processed in order on the texture. GL_ONE GL_ONE is the generic additive color scheme. There's also others (subtractive color, etc). So for each thing, I would recommend looking up GL_ONE GL_ONE (for e.g. on Google) to get an idea on how things work. Generally, the first keyword corresponds to source, and second corresponds to destination. GL_ZERO GL_ZERO for instance does nothing. Remember that each stage is executed in order.

 

As for other stuff in the header of the shader, generally q3map_ stuff is only meant for geometry, not for players. Other keywords like cull should be looked up in the manual for proper usage.

Link to comment

Or maybe i should just try to phrase things properly, you didn't even make a sound so how could i say "it sounds like?" :rolleyes:

 

He phrased it precisely in such a manner that one would label as, "proper"... Stop being obtuse.

 

This manual is a bit better. http://q3map2.robotrenegade.com/docs/shader_manual/contents.html. Do as wonko said. Then start looking at the various shader files that came with the game, or shader files from experienced community modders. Dissect them, use the manual as a reference.

 

I get the idea when you ask questions, you expect to be hooked to the matrix and inherit the knowledge. Some work will have to be done on your part...

Link to comment

He phrased it precisely in such a manner that one would label as, "proper"... Stop being obtuse.

 

This manual is a bit better. http://q3map2.robotrenegade.com/docs/shader_manual/contents.html. Do as wonko said. Then start looking at the various shader files that came with the game, or shader files from experienced community modders. Dissect them, use the manual as a reference.

 

I get the idea when you ask questions, you expect to be hooked to the matrix and inherit the knowledge. Some work will have to be done on your part...

 

 

I was actually making fun of myself and not being sarcastic or "obtuse...

Link to comment

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
×
×
  • Create New...