GLSL Basics II

Hi there,
i got an theoretical question regarding jogl & glsl.
I’ve read:
If you use your own shader (vertex or fragment) the built in fixed pipeline functions are disabled, you you have to program your own translation, lightning, etc.
Is it possible to ‘simulate’ the fixed structures by using already programmed ‘Templates’ and only add the one effect somebody might want?
I’m not quite sure what exactly happen, maybe you can help me.
Does actually the programmed shader code overwrite the fixed methods or does the shader code disable the entire vertex or fragment pipeline, so you have to do everything from the scratch again?
My main purpose is to program Raleigh Scattering on a textured planet’s surface. On the way to that point, i’ll need some information gathering how exactly it work.
Cylab was so kind ( i think, it was you;-) ) to program a function how to load a shader from file into oyur program and use it. Thats exactly the stuff, we n00bs need to get to a simple functional jogl code to experiment with shaders.

Thanks for any hints or ideas
Best Regards,
el Normeo

Basically modern gfx cards and drivers utilize the programmable (shader-)hardware to provide the fixed function pipeline, so when you upload an own shader, the fixed function pipeline is naturally disabled, because you take over the processing power.

Since it is disabled, no fixed pipeline functionality is available from the shader, you just get the configuration parameters and have to do everything on your own. This sounds more difficult than it is, since you usually just decide on your lighting model and the amount of texture units you want to use simultaniously and hack the desired functionality in you shader. For the usual stuff, this boils down to maybe 50 lines of code.

There was a shader generator, that generates the shader equivalents of the fixed function pipeline, but I don’t know where. I fiddled around with it and decided it’s not worth it, because it generates a lot of shader code and I found it difficult to find the right places to put my enhancments into.

Over at gamedev there is a collection of useful shaders that should get you started to roll your own stuff: http://www.gamedev.net/reference/programming/features/glsllib/default.asp

In the vertex program you can do:

void main()
	{	
			
		gl_Position = ftransform();
	}

Which gets you the same vertex transformation (but not lighting) as you’d get from the fixed function pipeline. Assuming you don’t want the standard lighting then all the other bits are pretty trivial to code yourself.

JOGL2 provides utilities for all that, see:
com/sun/opengl/util/glsl
and the fixedfunction emulation (WIP)
com/sun/opengl/util/glsl

demos showing the glsl utilities
demos/es2/RedCube
for glsl fixedfunc emulation you can run
demos/es1/RedCube
with argument -GL2ES2 …

all the other es1 demos running under es2 as well with that emu …

as you see, you don’t have to start from scratch …

we only might need to fix and complete the emu …