Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

UponTheEnd

Vertex Shaders

This topic is 5500 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

EveryWhere i look these days at demos or games, or whatever. They are talking about this new thing called Vertex Shaders. When i look at the name, it tells me something but not near as much as its popularity. So, the point is, what are they and what do you use them for? Are they an extension? Thanks

Share this post


Link to post
Share on other sites
Advertisement
They are an extension. What they do is store a list of verticies on the video ram, so you don''t waste time resending them to the video card. This is usually used for static objects, because frequent changes nullifies the advantages.

Share this post


Link to post
Share on other sites
quote:
What they do is store a list of verticies on the video ram, so you don't waste time resending them to the video card. This is usually used for static objects, because frequent changes nullifies the advantages.

You obviously don't know what you're talking about.
There are extensions that store vertices in video memory, but they're not vertex shaders.

Shaders (either vertex or fragment) allow one to reimplement part of the rendering pipeline. So you can replace the standard algorithms with your own, and they'll execute in the GPU.

Edit:

The OpenGL extension names from ARB are ARB_vertex_program and ARB_fragment_program, if I'm not mistaken...

[edited by - HellRaider on June 4, 2003 8:02:09 PM]

Share this post


Link to post
Share on other sites
HellRaider''s right.
Vertex shaders (known as vertex programs in OpenGL, since the word "shading" has no real meaning for vertices) override computations in the pipeline.

Usually, computations are fixed by a certain state, like lighting, fog, automatic texture coordinate generation, and such. Vertex programming allows the user to perform his own computations instead of the fixed function pipeline.

There are many, many cases when vertex programming comes handy : Volumetric fog and volumetric lights, keyframe interpolation, bump mapping, and much more. Vertex programs are often combined with fragment programs (also known as pixel shaders in DirectX).

Share this post


Link to post
Share on other sites
How do you use the ARB_fragment_program ?
I get it it`s an extension..I could initialize it but...how do I USE it ?

Share this post


Link to post
Share on other sites
The ARB_fragment_program extension is pretty easy to use in fact.
First of all, you have to create a program and load it.
glGenProgramsARB(1, &program);
glBindProgramARB(GL_FRAGMENT_PROGRM_ARB, program);
glProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(fragment_program_string), fragment_program_string);
where "fragment_program_string" is the program, represented by a string. It looks like :

!!ARBfp1.0
# Simple fragment program sample
ATTRIB texCoord = fragment.texcoord[0];
ATTRIB col = fragment.color.primary;
OUTPUT outColor = result.color;
TEMP texel2D;
# Sample the 2D texture and modulate it with the primary color
TXP texel2D, texCoord, texture, 2D;
MUL outColor, texel2D, col;
END

Then, every time you want to render primitives with that shader, enable fragment programs and bind it :
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program);
// render the model here.
glDisable(GL_FRAGMENT_PROGRAM_ARB);

And before exiting the program, it is recommended to delete the program :
glDeleteProgramsARB(1, &program);

As you will have guessed, the hardest part is defining the program string that matches the shader of your dreams.

Share this post


Link to post
Share on other sites
What cards support vertex and fragment programs? (can a radeon 7000?)
I wanted to comment and say that UT2K3 uses vertex and fragment programs quite extensively, although UT2k3 I dont think has any GL support

Share this post


Link to post
Share on other sites
Vertex programs are supported in hardware for GeForce3 and up (but not GeForce4MX) and for Radeon8500 and up.
Nvidia also supports vertex programs for ALL the GeForce series but with a software fallback for cards like GF2 and GF4MX. Even in software it runs pretty good.

Fragment programs are supported in hardware for all the GeForceFX series and for Radeon9500 and up (Radeon9000 does NOT support fragment programs).
Nvidia also provides a software fallback (known as the "NV30 emulation tool") for other GeForce cards but it is just for testing purposes because fragment programs are really too damn slow in software.

As for UT2K3 in fact it does not use pixel and vertex shaders intensively, despite the very neat effects in the game. That allows the game to run on old cards (afair UT2K3 does only need a DirectX6 compliant card) with still good graphics.

UT2K3 does have a GL support. A GL renderer have been written for linux (the game was released for windows and linux simultaneously) and is now used for a (recent) Macintosh version of the game. Also, I''ve heard that there is an OpenGL support for windows users which is recommended for systems that do have problems with Direct3D.

Share this post


Link to post
Share on other sites
Thanks! This post was very helpful for me, too, since I was looking for a detailed description of how to Implement Vertex/Pixel Shaders in OpenGL. And it would be really really great if anyone of you would have a link to a homepage showing how to code those Shader programs! So any link or book title, giving a good start into the world of Vertex/Pixel Shaders (with OpenGL) would be great

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!