The light is directly behind the model but it still lights it up! I tried doing a dot to the vertex normal and the light vector but it ends up looking worse. In other words it turns black to soon and even then it’s not a smooth transition from lit to unlit.
How do you guys ensure that surfaces that don’t face the light don’t get lit?
Do you have any ambient lighting? If so, remember that this gets applied regardless of the position of the light. If you want a truly black object, you need to set your ambient lighting to zero.
It’s a common trick to actually spread the illumination term over the full object based on the dot product to provide some back side ambient(ish) illumination.
So instead of a transition to shadow when the dot product goes negative it continues to fade out into the shadows. You can do this by adding some value between zero and 1 to the L.N dot product. I haven’t looked at the code here but I’d guess something like this is going on IF as you claim, the normals used are really facing away from the light.
Nah, I’m calculating the colors myself with the tangent space stuff per vertex. I just don’t know how to force the vertex to draw black when it needs to be and make it look good at the same time.
//generate color for DOT3 bumpmap
cf[0]=(hv[0]*m[0])+(hv[1]*m[3])+(hv[2]*m[6]);
cf[1]=(hv[0]*m[1])+(hv[1]*m[4])+(hv[2]*m[7]);
cf[2]=(hv[0]*m[2])+(hv[1]*m[5])+(hv[2]*m[8]);
//convert to unsigned byte
cub[0]=(S3Duchar)(cf[0]*255.0f);
cub[1]=255-(S3Duchar)(cf[1]*255.0f);
cub[2]=(S3Duchar)(cf[2]*255.0f);
//add to color array component
//adding is here so you can use more than one light
Colors[j][0]=cub[0];
Colors[j][1]=cub[1];
Colors[j][2]=cub[2];
Colors[j][3]=255;
}
I’ve added ambient lighting since last night and I must say it looks sooooo cool! Next is specular!
I’ve converted the Spider3D GDK to a DLL . I didn’t realize how usefull DLLs were until just after converting…the user doesn’t have to recompile an exe just to utilize a newer and more optimized DLL! Heh, can you tell I’ve never made DLLs before .
I also added all the spider3d elements into one spider3d.lib/dll. It was kinda dumb to seperate the other features like I did. It takes to much time to add all the libs to your project :/.
[This message has been edited by WhatEver (edited 11-10-2002).]