Question on shaders.
by Jacob Dankovchik · in General Discussion · 11/13/2004 (5:32 pm) · 9 replies
I'm a real noob at shaders and i've been looking at them here and there latley and I got a bit of a question just to make sure i got it sorted out what a shader is basically. From what I've read and how i'm comming to understand it, it seems shaders are a sort of plug in for graphics. Like, if you want a new technique or effect in you can make it in a shader and use it in a specific object. Am i right in this? Because I have seen shaders for per pixel lighting and so on so it sounds like thats pretty much what they are used as, an extra sort of "plug-in" for graphics.
About the author
#2
11/13/2004 (8:37 pm)
Shaders are a language technology created to simplify and standardize control over your video card. It is a high-level abstraction layer to the card. Essentially an interface to create desired effects. Not quite a plug-in, but it has similar qualities.
#3
If you're a coder then think of them as a method of changing the rendering process your video card uses at a hardware level (hence the "programmable pipeline"). You can use shaders to modify anything about a vertex or pixel, so in effect you can do just about anything with them. They are in effect a branch of technology that gives the coder ultimate flexibility in what they end up doing. I really don't want to go into anything respembling specifics since this is a huge topic which I probably won't even explain right. If you want to get into shader coding then you'll need a firm understanding of a 3D API and a good book (or maybe several) focused on the topic.
11/13/2004 (8:45 pm)
If your an artist then yes, think of them as a plug in, or better yet, a certain kind of texture or texture enhancer. In TSE you assign shaders to your texture maps through scripts which results in a material. Shaders can do things like give your textures glowing effects, or make them spin or make them refractive or even toon shaded. So if your an artist then just think of them like that.If you're a coder then think of them as a method of changing the rendering process your video card uses at a hardware level (hence the "programmable pipeline"). You can use shaders to modify anything about a vertex or pixel, so in effect you can do just about anything with them. They are in effect a branch of technology that gives the coder ultimate flexibility in what they end up doing. I really don't want to go into anything respembling specifics since this is a huge topic which I probably won't even explain right. If you want to get into shader coding then you'll need a firm understanding of a 3D API and a good book (or maybe several) focused on the topic.
#4
The thing about shaders is that there's no effect they can do which couldn't already be done some other way. What's important about them is that they have hardware support on modern graphics cards, so the effects that they can do they do much faster than was possible before. In fact most effects that you see done with shaders simply weren't viable to do before because they would have slowed down the frame rate way too much. Shaders allow these effects to run in real time.
The people who designed the way shaders work tried to make it so they're fairly flexible. So they can do quite a large variety of visual effects. Unfortunately if you asked a difficult question like "Can they do animated RenderMan-style renderings for me in real time?" or "Can they handle caustics?" the answer would be no. So there's still a bit of a gap between what you might dream of and what's possible right now. But as the cards get faster and faster and pick up more features over time I think we'll see quite a revolution in what can be done with them.
In the meantime shaders already give us visual effects we couldn't dream of on home PCs before. They're mostly used to get more realistic lighting, reflections, refractions and surface details.
11/13/2004 (9:51 pm)
The short version - shaders give programmers the ability to create some visual effects which wouldn't have been practical before.The thing about shaders is that there's no effect they can do which couldn't already be done some other way. What's important about them is that they have hardware support on modern graphics cards, so the effects that they can do they do much faster than was possible before. In fact most effects that you see done with shaders simply weren't viable to do before because they would have slowed down the frame rate way too much. Shaders allow these effects to run in real time.
The people who designed the way shaders work tried to make it so they're fairly flexible. So they can do quite a large variety of visual effects. Unfortunately if you asked a difficult question like "Can they do animated RenderMan-style renderings for me in real time?" or "Can they handle caustics?" the answer would be no. So there's still a bit of a gap between what you might dream of and what's possible right now. But as the cards get faster and faster and pick up more features over time I think we'll see quite a revolution in what can be done with them.
In the meantime shaders already give us visual effects we couldn't dream of on home PCs before. They're mostly used to get more realistic lighting, reflections, refractions and surface details.
#5
11/13/2004 (10:04 pm)
Wow thanks for explaining this to me we could relly use some resources that explore these various graphics lingo
#6
11/14/2004 (3:34 am)
Alright. Thanks for the explanations there, helped my understanding a bit more. Prior to all this i only worked with the quake 1 engine and shaders were unheard of, so this is all a really new area for me. Unfortunatly i can't afford any good books on it either. Gotta get a job first.. :/
#7
Learning to use new shader tech is one thing, but having to upgrade your graphics card to support the new shaders every time one is released is far beyond my budget.
The obvious solution is to pick a shader version and stick with it, but when you're learning from scratch, then by the time you have gotten your head round using shaders in your game and integrated all the necessary code whatever, you are far behind the current tech.
This is just the way I see it, the investment in time and money is pretty large. When glslang becomes more widespread, it may be a better solution, as I would hope that it just utilised new tricks under the hood, while retaining the same API. Not having delved in too deep into shaders, I could be completely off the mark, so if anyone knows any better, please say.
11/14/2004 (3:57 am)
I looked into playing with hardware shaders on numerous accasions, but the problem I have with it, is the pace at which shader specifications are coming out.Learning to use new shader tech is one thing, but having to upgrade your graphics card to support the new shaders every time one is released is far beyond my budget.
The obvious solution is to pick a shader version and stick with it, but when you're learning from scratch, then by the time you have gotten your head round using shaders in your game and integrated all the necessary code whatever, you are far behind the current tech.
This is just the way I see it, the investment in time and money is pretty large. When glslang becomes more widespread, it may be a better solution, as I would hope that it just utilised new tricks under the hood, while retaining the same API. Not having delved in too deep into shaders, I could be completely off the mark, so if anyone knows any better, please say.
#8
There are two types of shaders (so far :), vertex, and pixel/fragment:
The vertex shader operates on each vertex before it is used for rendering. At the very least, the vertex shader just transforms each vertex by the World/View matricies, and output the colour/texture data from the vertex. You can also have it calculate N dot L for simple vertex lighting.
Pixel shaders operate on, well, pixels. For each pixel to be rendered, the colours and texture coordinates are interpolated and provided as inputs to the pixel shader. A simple pixel shader can just output a the colour passed from the vertex shader, and add to it a sample from a texture using the tex coords provided by the vertex shader.
Where things get really interesting, is when you start using the colour/texcoord outputs in the vertex shader to pass other data. Such as the surface normal through the diffuse colour, allowing you to do N dot L in the pixel shader, for per-pixel lighting. You can also use the texture coords and a texture as a lookup table. This is often used in per-pixel lighting to obtain normalized values (interpolation of the colour may produce a vector that isn't normalized).
11/14/2004 (9:28 am)
I find the best way to understand shaders is to actually understand what they do.There are two types of shaders (so far :), vertex, and pixel/fragment:
The vertex shader operates on each vertex before it is used for rendering. At the very least, the vertex shader just transforms each vertex by the World/View matricies, and output the colour/texture data from the vertex. You can also have it calculate N dot L for simple vertex lighting.
Pixel shaders operate on, well, pixels. For each pixel to be rendered, the colours and texture coordinates are interpolated and provided as inputs to the pixel shader. A simple pixel shader can just output a the colour passed from the vertex shader, and add to it a sample from a texture using the tex coords provided by the vertex shader.
Where things get really interesting, is when you start using the colour/texcoord outputs in the vertex shader to pass other data. Such as the surface normal through the diffuse colour, allowing you to do N dot L in the pixel shader, for per-pixel lighting. You can also use the texture coords and a texture as a lookup table. This is often used in per-pixel lighting to obtain normalized values (interpolation of the colour may produce a vector that isn't normalized).
#9
i am thinking about buying tse and i use blender for 3d modeling and photoshop for texturing.
is the shader just like an extra texture that shows how the light interacts with it???
like how would i go about creating a glow shader for a sort of glow-in-the-dark crystal?
02/14/2006 (5:16 pm)
So, what would i have to do then when i wish to create a shaper?? i am thinking about buying tse and i use blender for 3d modeling and photoshop for texturing.
is the shader just like an extra texture that shows how the light interacts with it???
like how would i go about creating a glow shader for a sort of glow-in-the-dark crystal?
Torque Owner Charlie Malbaurn