What are shaders? What do they do? Uses?

Posted By: ulillillia

What are shaders? What do they do? Uses? - 05/26/05 04:58

Can someone explain, in more depth, what shaders are, what do they do, what their uses are, and other stuff? I looked at some of the screenshots in the shader index and some of it appears to be a regular skin image. It seems just like a model with a complex skin arrangement which makes more more confused on what shaders are. Is that what a shader is? A skin image? Some of you can make extremely high-quality art work, there's no apparent need for shaders if shaders aren't just a skin image. Also, what is an HLSL shader? What does my graphics card support (I have Radeon 9600 XT)? I'm very confused about shaders and what they are, what they do, what they're for, etc..

Edit: also, what are vertex and pixel shaders? What's the pros and cons between the 2?
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 06:12

If you havent allready seen whats on the WIKIU/P acknex/acknex might help explain a little more. I know nothing really of shaders myself and am deffinately interested in what some of the others have to say. However I know they can be used for things like bump mapping,toon shaders, fur shaders and a few other things. It can really help to add atmosphere and quality to your levels,models ect if done right. Im about to attempt bump mapping yet again so wish me luck
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 06:24

Yeah, you can make fur with a skin image too and do toon shading (the black lines I believe) with a skin. I still don't understand. Also, what's bump mapping? Will this increase the poly count drastically? When I think of bumps, I think of small humps and things in the view, but to do that, for the size of my worlds, I'd need a graphics card a billion times faster than the one I've got as I don't think video cards nowadays can even support 50 terapolys per second....
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 06:33

I don't really like the way WIKI is designed, so I never look at it. Designed as in having to enter username and password. It bothers me so I'm not going to look at it. I looked at it before (don't remember when), but ran into this same thing and it bothered me so I just turned away. I looked at that "shader index" thread at the top of this forum and it seems so much that it's just a skin image that someone who's more talented in art than I am, accomplished.

Here's an analogy:

true newbie to computers : very frustrating to use them :: me to shaders : very confused about them

Hopefully you know what analogies are (no, you don't need to fill in the blank as from in school, it's already done).
Posted By: WHURL

Re: What are shaders? What do they do? Uses? - 05/26/05 07:01

what are shaders?

Quote:


A shader is basically the set of rules on how an object looks. The rules can be almost anything but there are are a lot of established routines to make this task a lot more simple for us. There are rules that can describe how objects react to lighting, functions to read texturemaps, fetch reflections and refractions and so on. Shaders can be formulated to look like real physical materials or shaders can be written to look like cartoon surfaces or even output technical data, such as distance from camera.

Shaders are also not limited to surface colour only - there are different type of of shaders: shaders can manipulate the shape of an object (displacement shaders), describe the atmosphere (fog shaders) and how light and shadow is cast (light shaders and shadow shaders).




The basic concepts behind shaders

Quote:


Basic surface shaders usually can be split up into a few concepts. The resulant colour of a surface is a mathematical combination of the following properties.

* illumination- ambient, diffuse, specular, sub-surface and indirect
* raytracing- reflections, refractions and related phenomena like fresnel
* texturemapping- procedural and map-based colourisation of a surface
* bump mapping- this is how we can affect how the lighting affects a surface by "fooling" the renderer into thinking that your object has parts of it facing in different directions. this give the illusion of more modeled detail in your geometry.





Here's an intro to High Level Shading Language (HLSL).
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 07:25

Ok took a couple of the pics from the wiki to show you. These are the toon and fur shaders.Both would be very difficult if not impossible without shaders. You could as you said use black outlines for your chacter but only if it would be seen from on angle at a time in a 3d enviroment chances are your chacter will be changing positions all the time so you would have to have multiple skins in order to acheive something similliar.The fur shader would be very very difficult to achieve with a skin in my opinion.


You have to think that each angle your chacter can be viewed from would change the way the chacter would look and change the way the shading needs to be applied so would take a lot of skins not to mention coding to get something to look decent.

and bumpmapping to my knowledge and expeirence with it in other programs will basically give more depth to you other wise flat walls. Say you have a brick wall texture. With bumpmapping you could acctually make it look as tho the bricks stand further out then the mortar. which could probally be achieved with a good texture. but im sure theres many other reason why a shader would be a better way to go.

these are just my opinions and thoughts on it tho
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 07:27

Okay, then, what does my video card support then, if it supports shaders at all? I have Radeon 9600 XT. It seems, though, that a lot of stuff from shaders can simply be done with a skin image so what's the point in having a shader in this case? A lot of my textures have black with random amounts of alpha which gives a bump-like feel. My platforms are an example of this as well as the buildings, sandy shore on the beach, etc.. I don't have shaders, I'm using a skin image for the bump effects. Basically, all I do is use the add noise feature, use color reduction to get 2 channels per color (allowing for 8 different colors), then, in the GIMP, import this image as a layer, turn a color into black, set the first alpha to 0, do the next color, turn it to black, make the alpha at 32, do the next at 64 and so on. Then I do a mass-color erase at either 75 or, sometimes, 87.5 to simulate the roughness. However, this technique has limits, easily noticed with my beach. I could almost just use a 2x2 skin for the platforms (except the goal and start platforms) and, if it's possible, apply the roughness effect to it.

If there was another way to apply the roughness at the 1:1 resolution (I'd prefer 2 pixels per quant myself), I could have smaller skin sizes (not the huge 1024x1024 textures I use very often) which could, in turn, allow for a lot more options.
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 07:32

Code:

gpu | v.s. | p.s. | t&l | tex | Max. texture size
Radeon 9600 Series | 2.0 | 2.0 | yes | 8 | 2048x2048x1024


Pretty sure that card would fall in to this category ... Nice card wanna trade

I wish i could find or show you some examples but my card doesnt support too much and i havent successfully used bump mapping so not sure it even supports that
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 07:35

@ FeiHongJr: I have a brick texture for the walls in my restaurant (if I were to use something else, it'll mean having to use a skin size of 2048x1024 (to keep the 1 pixel per quant resolution). Take out the roughness, I could stick with a 256x256 texture without too much trouble (though it'll get stretched to 4x the size meaning 4 quants per pixel). But, without the roughness, it'll become extremely difficult to judge distances. The bricks are 256 quants wide by 128 quants tall (6 inches by 3 inches). Yet, even with the roughness, it's still difficult to tell where one wall ends when another one is in the background (the same goes for my city's buildings)....
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 07:51

Quote:

Code:

gpu | v.s. | p.s. | t&l | tex | Max. texture size
Radeon 9600 Series | 2.0 | 2.0 | yes | 8 | 2048x2048x1024


Pretty sure that card would fall in to this category ... Nice card wanna trade

I wish i could find or show you some examples but my card doesnt support too much and i havent successfully used bump mapping so not sure it even supports that




Huh!? a 1024-bit texture!? No way! Also, what's with the v.x., p.s., t&l, and the tex stuff?

I paid $140 for that card and it doesn't seem as good as I was hoping for. The output I'm getting from the card isn't anywhere near what the specs on ATI's website say:

Code:

ATI Product Comparison
Product Name RADEON 9600 XT
ASIC RADEON 9600

Technology Features
SMARTSHADER™ 2
SMOOTHVISION™ 2.1
FULLSTREAM™ Real, DivX
Adaptive De-Interlace VIDEOSHADER™
HYDRAVISION™ Yes
Hardware MPEG Encode Assist -

Specifications
Bus Type AGP 4X, 8X
Memory Amount (MB) 128
Memory Type DDR1
Memory Interface 128-bit
Memory Clock Speed (MHz) 300
Engine Clock Speed (MHz) 500
Pipelines 4
Pixel Fillrate 2.0 Gpixels/sec
Geometry Rate 250 MTriangles

Display Support
VGA Yes
DVI Yes
Dual Monitor Display Yes
YPrPb Out for HDTV w/adapter optional
S-Video Out Yes
Composite Out w/adapter optional

Multimedia Support
S-Video In -
Composite In -
TV Tuner -
FM Tuner No
DTV Tuner
Remote Control Included -
EAZYLOOK -
Audio Out -
S/PDIF Out -



The site says that I should be getting 250 million triangles per second, but I'm only getting a tenth of that. Also, the box has a memory clock speed of 600 MHz, and here it says 300 MHz. I don't know what the memory interface thing is nor what pipelines are.

I don't know what the pixel fill rate thing is, but, in my game, I've got way more than 2 gigapixels even on the screen and I'm getting 30 fps....
Posted By: WHURL

Re: What are shaders? What do they do? Uses? - 05/26/05 07:57

Quote:

It seems, though, that a lot of stuff from shaders can simply be done with a skin image so what's the point in having a shader in this case?




If you can get the effect you are after by simply using a skin, then you should do so. Look to shaders to provide effects that just cannot be achieved that way. Obvious examples would include things like glass with refraction and reflection, objects with specular highlights etc.

There are some popular shader example pics at the NVidia site that might spark your imagination and show you some effects that would require a shader.
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 08:05

if i understood correctly i have the same problem where its difficult to tell where one wall starts and the other ends. Only thing ive found to help is to move the texture on the x or y axis a lil bit to throw off the seemless apearance. Heres a couple examples of bumpmapping in gimp.. not really the same but might help

with out bump mapping


with bumpmapping


without bumpmapping


with bumpmapping and color adjustments


Now since this is only 2d its not really the same but notice how the grout appears more imbedded into the tiles with the bumpmapping. In a 3d world this would be dependant on the way light reflects from the object and make it appear as tho its higher detail then just a flat block with a texture on it hope this helps
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 08:15

I still have some unanswered questions:

What are vertex and pixel shaders? What's the pros and cons between the 2?

Explain what the specs mean in the specs for my Radeon 9600 XT card?

One final thing, my beach has a very low-res texture and I can't think of any way to make it look better without the possibility of using a 16384x16384 texture for a resolution of 2 quants per pixel.... Right now, I'm using a 2048x2048 texture and the resolution is a horrible 18 quants per pixel, even with the entire mapping filling the entire space (only a top mapping is needed) . If I can apply bump mapping, I could use a 1024x1024 texture or even 512x512. There isn't any other way that I can think of to make it look at least halfway decent. Bump mapping may seem to be a useful option....
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 08:44

Sorry not really sure what pixel and vertex shaders are. My guess is shaders which can be applied to pixels or vertexs Shrugs no clue.

the specs mean.

V.S. version of vertex shader which could be used
P.S. version of pixel shader which could be used
T&L T&L is available with your card
tex number of textures supported

last is pretty self explanatory

for your beach not really sure prehaps look into detail mapping as well hopefully one of the shader gurus can step in and clear things up further since i dont know much if anything about them
Posted By: ulillillia

Re: What are shaders? What do they do? Uses? - 05/26/05 09:18

Actually, the last isn't so self-explanatory. 2048x2048x1024 - a texture size of 2048x2048 at a maximum bit depth of 1024 bits. I've never seen anything above 32-bit color, so how can it support 1024-bit color. Is there some hidden feature on that video card that I don't know about? I checked my settings and I have 8-bit color (yuck!), 16-bit color (fair, but don't like as it causes problems in MSPaint (inaccurate colors)), and 32-bit color (I'm using this). I don't see anything for anything higher than 32, so how can it support 1024-bit color!?

Detail mapping, as far as I've heard, only applies to terrain. This is a model and it cannot be converted to a terrain.
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 10:14

hmmm honestly didnt pay attention to that.. No clue what the last numbers mean, Like you said i highly doubt its bits ...

Im pretty sure not positive that detail maps could be used for models as well. I think a terrain is basically a model minus some data so dont see why it wouldnt work.
Posted By: Matt_Aufderheide

Re: What are shaders? What do they do? Uses? - 05/26/05 10:36

Quote:


What are vertex and pixel shaders?




Ok, here goes:

So this makes sense, i have to start at the beginning...A few years ago, all graphics cards implemeted a fixed set of vertex and texture instructions, determined by the API(s) they chose to support. the main API has been Direct3D and that's the one i kow something about, so I'll restrict my comments to that.

Therfore, Microsoft wrote direct3d to give developers access to hardware functions. So basically, Microsoft decided that among other things, 3D primitves should be triangular polygons, and nothing else. Also, they decided on a few fixed texturing methods and blending options.

In any case, the cards that supported early versions of Drect3d(to d3x7) all worked essentially the same way, giving graphics developers a limited number of thing they could do. For instance, if you wanted to do environment mapping, there was only one or so ways it could be done.. so you in your app you write somehting like ENVIRONMENTMAP, and D3D takes care of everything else (I'm simplifying this a lot) This worked well beaause it was easy for developers to use and easy for card manufacteures to write their drivers. The main problem with this was becasue you only had a limited number of functions you could do, all games sort of looked alike, and there was no way to implement your own texture/vertex effects. if you wanted to use a non-standard lighitng model, you had to do it all in software, which was too slow.

This fixed-function approach was fittingly called the Fixed-Function Pipeline.
With DirectX8, Microsoft made the biggest leap so far in realtim 3d, they developed the concept of the programmable pipeline, in which vertex and pixel operations could be determined programatically. this of course required a a graphics CPU to process, now called a GPU..and Nvidia had already made such a thing, called the GeForce.

So with the stars aligned, now can say a few things about what shaders actually are and how they work.

First, the term 'shader' is probably unfortunate, because not all shaders have anythign to do with actually shading anything. Vertex shaders, for instance, only determine properties of, what else, vertices. A vertex shader, like a pixel shader, is a little program that can be run, in hardware, on every vertex that it is assigned to. To do this is software is of course extrmely slow, but its fast when the hardware does it. So you can do all sorts of neato things to a model on a per-vertex level. The most obvious is moving it around in novel ways. However, the most powerfull application of vertex shader is not manipulationg the positions of a vertex, indeed not to change the vertex at all, but to pass information to a pixel shader. Now a pixel shader program is run for every single pixel in the model texture. However, each pixel has only a few parent vertices on the uv map, so you can caluculate things on the vertices, and pass that to the pixels, so data is linearly interpolated. this means you can speed up caluculations. it is this relationship bewteen the vertex shader and the pixel shader which allows us to actually find the pixel's position in the 3D world, something that would be impossible without shaders. and once you know the pixel's position, you can treat it almost as a 3d object. In other words, pixels can be assigned a normal(a normal as you may know, is defined as the direction vector of a plane)..so a pixel can be interpreted as a polygon in 3d space, which can then be lit according to the world lighting model. Needless to say, this can improve the appearance of objects tremendously.

This sort of procedure is called per-pixel lighting/normalmapping,and just scratches the surface of what you can do with shaders. remember, the science and math here is nothing new, its all basic stuff developed years ago, but the big thing is that you make it all happen in hardware.

The possibilities are literaly endless. The developer can do pretty much any effects he can think of in video hardware now, because the hardware is just another CPU.

Another important thing pixel shadrs allow you do are graphics post-processing in realtime. You can implement photoshop style filters that can manipulate your textures on the fly.

Bascically, shaders are the most important tool the graphics developer has now, becaus eif you can think of a visual effect, it can probably be done in a shader. Name it, and there is a way.. even realtime raytracing and global illumination, hair, clothing, water,etc. Everyything you always wanted in 3d graphics are now possible, its just a matter of incremental improvements in performance.

I hope this helps a bit. Please excuse any typos or conceptual errors.
Posted By: FeiHongJr

Re: What are shaders? What do they do? Uses? - 05/26/05 11:01

Thank you matt. Thats explained alot and was rather interesting
Posted By: Andreas C

Re: What are shaders? What do they do? Uses? - 05/26/05 11:14

Matt,

thanks for this clear and understandable explanation.

Cheers,
Andreas
© 2024 lite-C Forums