PDA

View Full Version : several shaders



SergeVrt
06-13-2003, 06:12 AM
Hi

I had an idea to combine two ( or several) different shaders. Say I have several objects some have attached shaders others not. And there is ( for ex scene distortion) shader which affects entire scene.

of cause it is possible to combine shader code manually so that those objects which have specific shaders will have also code for entire scene

those which have no specific attached shaders will just be affected by global shader..

But is there way to separate shaders? and have several passes.

Sorry maybe I'm just too new to shaders. But just wonder ... if such separation was possible then programmer's life would be much easier http://www.opengl.org/discussion_boards/ubb/smile.gif

Zengar
06-13-2003, 09:02 AM
I don't quite understand your problem. You can select shader 1(the entire scene) and render all objects. Then you select shader 2 and render other objects using glBlendFunc - the classic multipass algorithm.
Maybe I got something wrong. I'm not too fast.

SergeVrt
06-13-2003, 10:59 AM
Originally posted by Zengar:
I don't quite understand your problem. You can select shader 1(the entire scene) and render all objects. Then you select shader 2 and render other objects using glBlendFunc - the classic multipass algorithm.
Maybe I got something wrong. I'm not too fast.


OK - I want to develop vertex shader to make fish eye scene like here http://developer.nvidia.com/view.asp?IO=Fisheye_Lens
( though it is for DX)

so if I follow your advice - then those object ( trees at the picture) will have for ex vertex shader shadow volumes but...they will look like as at the link picture at bottom - ie - just a 'normal' scene
so blending with the fish eye scene will give me no solution or?

http://www.opengl.org/discussion_boards/ubb/smile.gif I'm also not too fast http://www.opengl.org/discussion_boards/ubb/wink.gif

Korval
06-13-2003, 10:37 PM
if such separation was possible then programmer's life would be much easier

No such separation exists because, fundamentally, no such separation can exist. At least, not at the level of OpenGL's API. Not at the hardware level.

What you're, basically, asking for is for two vertex shaders to do different things with the same data. No such hardware exists, nor is it likely to exist in the near, or even distant, future.

Your best bet is to wait for glslang and use its compile/link facilities to build your full programs. With that, you can build 2 vertex "shaders" that you link together to form the per-vertex program that it run on the hardware. The problems there are that there can only be one main() (one entrypoint), so one of the shaders is just a bare function that another shader calls. Another problem is that linking is probably not too fast, so it's not something you should try to do mid-frame.