TheNerd's picture

Noob Question - WHY GLSL

So, I've been trying to get shadowing and lighting to work in OpenTK for a bit, specifically using VSM. As I started to learn more and more about GLSL I found tutorials on lots of things:

Per-Pixel Lighting with GLSL
Texturing with GLSL
Materials with GLSL

My question is - OpenGL has Lighting, Texturing, and Materials all built into its core framework. Why would you want to do the same thing in a shader? Is it faster in a shader?

And I've read that Per-Pixel lighting in OpenGL is bad performance-wise, but what if you did per-Pixel lighting via a shader, would that improve performance?

Thanks!
TheNerd


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
TheNerd's picture

Well, I don't learn very well at all by reading. Generally if I am to take on a new technology, I need to learn it by "tinkering" - I take something that works, and I start screwing with it, trying to figure out what each knob and switch and button does, until I can start adding my own little knobs and buttons and switches. If I have a book (or 6) they are usually for reference.

My problem is, I have a GTX 285 with the latest nVidia drivers, which support and run GLSL 4 and opengl 4. So when I am working on a tutorial example code, I can't figure out if it's not working because what I am doing is no longer supported in this way, or if my tinkering blew it up - makes troubleshooting, and learning, hard.

I'd really like to implement some basic shaders - simple, easy shaders. So I asked some friends - "hey guys, I want to make some lights and shadows for my little simulation. What should I use to make them look good?" And what I got was "Volumetric light shaders, and PS VSM or SATVSM (read GPU Gems 3)" - so off I went. Now I get the math - that's easy. But trying to understand the little mechanics and nuances of the latest versions of OpenGL and how it implements things NOW as compared to 3 years ago is a real pain. Shaders seem to be where the real POWER comes in, and thats what I really want to learn. So, if I want to learn how to make a BASIC shader for light and shadows, what kind of shader should I look at building? LOL (VSM was like... holy crap batman - multi-texture madness!!)

iliak's picture

Have a look at this for compatible context.