Single Pass!!!
Daily 09/25/03
More ship woes and then...the "Ah Ha!" moment.
Have you ever read "Illusions" by Richard Bach? I had one of those moments this morning. That was the break through moment for my day. I was putting away my books from yesterday when I decided to open up "Advanced 3D Game Programming". It opened to Pg.438 and my eyes immediately caught D3DTA_SPECULAR. Booom!!!
That's the answers to all my problems. That's how you can map to COLOR1 in a vertex shader. Whoo hoo! Now we're down to one pass!!!! Here's what I mean.
| struct Output { float4 position : POSITION; float4 diffuse : COLOR0; float4 specular : COLOR1; // This is the cool guy float2 uv0 : TEXCOORD0; float2 uv2 : TEXCOORD2; // This is for the third stage (light map) }; Output vs(float4 Position : POSITION, float3 Normal : NORMAL, float2 TexCoord : TEXCOORD0) { Output out = (Output)0; // Light direction (view space) float3 L = LightDir; // Directional light. // Position (view space) float3 P = mul(Position, WorldView); // Normal (view space) float3 N = normalize(mul(Normal, (float3x3)WorldView)); out.position = mul(float4(P, 1), Projection); out.diffuse = max(0, dot(-N, L)); out.specular = DecalColor; // Decal color passed in. out.uv = TexCoord; out.uv2 = TexCoord; return out; } technique tech0 |
Wow! I don't think my day can get any better

I got into a discussion with Paul about texture memory usage. Does a 24bit texture take up roughly the same amount of memory as 3 8bit textures? It seems right. There may be a little overhead from the texture headers and other supporting data, but the bits should be roughly equivalent.
The rest of the day was spent in a long meeting. More tasks to do....