Skip to main content
GameDev.net gamedev.net
🔒 Locked

Shaders

Started by Etus Jan 2, 2003 at 12:23 PM 19 replies 750+ views
Original Post
Etus
Etus
Enough! I''m tired of doing endless searches on Google on the subject without finding anything usefull. I decided to simply ask this in the forum. I know this are newbie questions, but, well, I simply can''t find an answer. 1. First, what are shaders? 2. What''s vertex shaders and vertex programming? Where can I find articles and tutorials on this subject? 3. What''s pixel shaders and fragment/pixel programming? Where can I find articles and tutorials on this subject? 4. What''s Per-Pixel Lighting(I''m already familiar with Per-Vertex Lighting)? Where can I find articles and tutorials on this subjects? I''m using OpenGL - I heard about the Vertex and Fragment programming extensions, but I didn''t find any information about them. Thanks in advance, Yuval
Z01
Z01
For information about shaders and PPL go to Nvidia:

http://developer.nvidia.com/view.asp?PAGE=nvsdk

This is probably the best one to read first:

http://developer.nvidia.com/view.asp?IO=Intro_Vertex_Shaders

It has a decided DX slant, but 90% of it is so general it applies to OGL also.

Toms Hardware (www.tomshardware.com) also has some general articles on shaders from people who are not interested in promoting their own shader extensions or video cards or API (ie. not Nvidia, ATI, or MS).

Also, for PPL and bumpmapping try here:

http://www.ronfrazier.net/apparition/index.asp?appmain=research/per_pixel_lighting.html

http://www.ronfrazier.net/apparition/index.asp?appmain=research/advanced_per_pixel_lighting.html

http://developer.nvidia.com/docs/IO/1329/ATT/bumpmap.pdf
Z01
Z01
For OGL shader extensions, see embedded links and discussion here (I''m trying to figure out shader/PPL stuff too ):

http://gamedev.net/community/forums/topic.asp?topic_id=130823

For information about extensions, check out the SGI OGL extension registry (search for it).
Etus
Etus
Thanks a lot
It seems from the articles you gave me that the appropriate name for Per-Pixel Lighting would be Dynamic Lightmapping. Oh well

I''ve got two more questions:

1. You didn''t give me an article about Pixel Shaders - where can I find one? In Nvidia Developer page I merely found slides which didn''t contain much information.
2. What''s a normal map and what it got to do with PPL or Pixel Shaders?

Thanks,
Yuval
sakky
sakky
I must bitch about this too. I''ve searched on Google and haven''t found shit on how to load shaders in OpenGL. I would have figured NeHe! would have a tutorial on this before any one else would. NVIDIA''s own Cg toolkit didn''t even have a tutorial on loading them in OpenGL. I''m very, very angry. How do I load shaders and run them with OpenGL.

DAMN IT!!! DAMN IT ALL TO HELL!!!! Sorry I just had to get this out of me. Do you know how fusterating it is to search for something over and over again and get nothing back for your efforts? Or maybe I''m just insane by doing the same ting over again expecting different results.
Take back the internet with the most awsome browser around, FireFox
fatgraham
fatgraham
nvidia''s cg tool kit has a few opengl examples. i recommend reading the ppt''s (yuck, powerpoint?) tutorials to get the basic idea of how use shaders

as for using them actually in your program, there is bugger all documentation. I just read/copied/pasted code from the examples on www.cgshaders.org

You wanna look in the code for pretty much any types/functions with "cgGL" at the start of their names
Z01
Z01
There are not any good articles around for pixel shaders for OpenGL. I suggest reading some DX PS stuff to get an idea of what is going on, and then start reading the OGL extension registry. You will see that there are extensions that can emulate what DX calls "pixel shaders" even though the extensions are not called that.

For examples of shaders, I think there is a lot of OpenGL examples included in the Nvidia effects browser - each effect has code for OGL and DX, I think??

A normal map is a RGB/RGBA texture where the RGB components hold a normal to the surface for each texel. It is scaled and biased to the range 0..255. The A component can be used to hold other things, like shinyness. If you have the normal at each pixel, you can image how this might be used for lighting...

zedzeek
zedzeek
www.nutty.org
www.delphi3d.net
http://humus2.campus.luth.se/~humus/
+ a couple more i cant remember offhand

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html
Null and Void
Null and Void
quote:
Original post by Anonymous Poster
Now the problem with shaders in OpenGL is that they are not unified. Meaning they vary based on which extension you are using. If you have a radeon video card you need the ATI Shader extensions which are different than the Nvidia Extensions. This makes it more difficult to deal with. OpenGL 2.0 is supposedly supposed to solve this problem when ever that arrives.

That''s not true anymore. ARB_vertex_program and ARB_fragment_program are the standard methods of accessing vertex and pixel ''shaders''. That said, ARB_fragment_program is only supported on one or two cards right now (because it demands a lot from the card), and the vendor specific pixel ''shaders'' are supported on more cards.

chronos
chronos
Take a look at the following extensions:

ARB_vertex_program (supported cards/drivers)
ARB_fragment_program (supported cards/drivers)
EXT_vertex_shader (supported cards/drivers)
NV_vertex_program (supported cards/drivers)
NV_vertex_program1_1 (supported cards/drivers)
NV_vertex_program2 * (supported cards/drivers)
NV_fragment_program * (supported cards/drivers)
ATI_vertex_shader (supported cards/drivers)
ATI_fragment_shader (supported cards/drivers)

* No link provided to NV_vertex_program2 and NV_fragment_program because they're not listed on SGI's OpenGL Extensions Registry.

NVIDIA's Cg Toolkit can produce shaders for the ARB_* and NV_* extensions listed above. The shader specs at the OpenGL registry are a little hard to read, so maybe you should start with Cg.


[edited by - chronos on January 3, 2003 3:56:23 AM]
laeuchli
laeuchli
Don''t forget to check out www.cgshaders.org..
Best resource for learning Cg.....
Jesse
www.laeuchli.com/jesse/
Yann L
Yann L
ARB_fragment_program will not run on a GF3, unless you have NV30 emulate installed (slow !). ARB_vertex_program, however, will run hardware accelerated on a GF3.

About Cg: The CG effect browser works nicely with a GeForce3. You won''t get all the shaders, but most of them work. I guess something went wrong with your installation.
Etus
Etus
Thanks again for your answers.
I just want to ask two more questions:

1. Can you explain, in short, what are Shaders(the basic shader)?
2. Regarding the Normal Map - do I need to read the values and use them as vertex normals or do I just need to blend the normal map to the current texture and the regular OpenGL lighting model will do the rest?

Thanks,
Yuval

[edited by - Etus on January 3, 2003 5:44:14 PM]
Hairybudda
Hairybudda
Ok, shaders are microsofts convention for naming fragment and vertex programs.

A vertex program(or shader), if you''re familiar with the OpenGL rendering pipeline, is a stage that you can control before the primitive assembly stage on the graphics card(IIRC). Basically, you can, on the card, do complex tranformations to individual vertices that would normally take insane amounts of CPU time up. One catch is you cannot create nor destroy a vertex on the GPU. Thats all has to be done CPU level.

Now, a fragment shader ( or pixel shader ) is more or less the same thing, only its done before the final rasterisation stages of each fragment(or pixel if you wish). This means you can do computationally expensive lighting and colouring effects on the GPU, that would also absulutely murder your CPU. This means you can do perfect per pixel lighting, high quality effects etc...

Now you can feed directly to a vertex shader from the cpu, and you can feed directly to a fragment shader directly from the CPU, but you can also feed to a fragment shader from a vertex shader, meaning you can define your own custom Transformation and Lighting pipeline.

A few ways of exploiting these shaders in OGL would be to use the ARB_vertex_program & ARB_fragment_program extensions, although i wouldn''t reccommend this without a reasonable level of experience. Another way would be to go through some high level shader language(i.e. Gl 2.0 Shader language nVidia Cg ). I would reccommend Cg.

Now, a normal map is a texture that you can feed to a fragment program, that in itself isn''t actually a texture. Its an array of normals, encoded in the texture, so that they can accurately be passed into a shader.
st0ned
Etus
Etus
Thank you vey much for your reply!
That was exactly the explanation I was looking for.

Thanks again,
Yuval

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.