Passes, Material Swap, and Attaching Shaders

BlitzMax Forums/OpenGL Module/Passes, Material Swap, and Attaching Shaders

Drey(Posted 2006) [#1]
I've been using shader designer to write some lighting. My 6600gt only has 4 texture slots. With a Colormap, normal, and LightAttribute maps(shine, emission, glow). I only have one more maybe to add a detail map..which might have all those properties as well. So then..i go "i need to run another pass..ewww".

From what i understand, you have to send the geometry through the pipeline again. Im thinking this means i need to make another call to gldrawelements. Meaning a 1000 polygon model is really using 2000 to render now...is there any type of opmitization to cut this effect down?

Second, i'm going to have my engine organize by surfaces to avoid texture swap. Now i'm going to impliment shaders. I'm curious on if the cost to attach and detach shaders is smaller than swapping textures. I'm thinking it is..since you're only sending operations.

Right now the organization is by surfaces.
Any advice on sorting the most time costly to the least for iterations?


Tom(Posted 2006) [#2]
Look up Vertex Buffer Objects. With a few simple function calls you can have GL store your Vertex Arrays (be it position/color/UVs e.t.c) in video memory on the GFX card rather than system memory.

This obviously saves you having to transfer the arrays every time you want to draw geometry.

Each time you do wish to draw, you simply bind the buffer (tell GL you'll be using the data stored on the GFX card) and call your draw functions as normal but you send it a NULL pointer instead of your vertex array pointer.

This is ideal for any static data, although there are functions for changing data in the 'VBO'.

Also look up setting a priority for your textures, you can give them a value indicating how important it is for GL to keep them in GFX card memory (based on how often they're used)

I can't see there being an issue with shaders unless you're compiling them constantly, highly unlikely.


Drey(Posted 2006) [#3]
yeah, i'm using VBOs on non-animated objects. More or less this game is the core gaming audience and i'm not worried about older machines running the game. It'll be free too so i'm not beening over backwards for scalablity. I'm going to target the x300/n6100 and higher cards. I think they all have at least 4 slots. The 4th texture will be a combination of color,normal,spec by having the images in different corners. Cutting down multipassing a bit.

Thanks.


Tom(Posted 2006) [#4]
Have you attempted skinned animation yet?


Drey(Posted 2006) [#5]
Not yet, soon though. why?


Drey(Posted 2006) [#6]
I just bought the Orange Book. I'm going to use vertex shaders for it.