Backside should be black right?

http://www.spider3d.com/img/badbump.jpg

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?

Just to be sure…

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.

dorbie, the link is a picture

I will think about what you said and try to impliment it.

Here’s the typical code:

memset(Objects[i].Colors, 0, sizeof(S3Dcolor4ub)*Objects[i].nColors);
Colors=Objects[i].Colors;

vertex_buffer=Objects[i].Meshes[CurFrame].Vertices;
normal_buffer=Objects[i].Meshes[CurFrame].Normals;
tangent=Objects[i].Meshes[CurFrame].Tangent;
binormal=Objects[i].Meshes[CurFrame].Binormal;

for(S3Duint j=0; j<Objects[i].Meshes[CurFrame].nVertices; j++)
{
//lv = light vector
//vv = view vector
//hv = half vector
//lp = light point
//vp = view point

s3dVecSubtract3f(lv, lp, vertex_buffer[j]);
s3dVecNormalize3f(lv);

s3dVecSubtract3f(vv, vp, vertex_buffer[j]);
s3dVecNormalize3f(vv);

s3dVecAdd3f(hv, vv, lv);
s3dVecNormalize3f(hv);

//shaded bumpmap
m[0]=tangent[j][0];
m[1]=binormal[j][0];
m[2]=normal_buffer[j][0];
m[3]=tangent[j][1];
m[4]=binormal[j][1];
m[5]=normal_buffer[j][1];
m[6]=tangent[j][2];
m[7]=binormal[j][2];
m[8]=normal_buffer[j][2];

//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]);

cf[0]=(cf[0]*0.5f)+0.5f;
cf[1]=(cf[1]*0.5f)+0.5f;
cf[2]=(cf[2]*0.5f)+0.5f;

//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;
}

Wooohooo! You go dorbie! Your suggestion fixed it . Thanks!

Whoop! There’s still a bug…I’m gonna keep experimenting…

[edit]I take that back, it’s working perfectly![/edit]

Here ya go. This is what it’s suppose to look like:
http://www.spider3d.com/img/goodbump.jpg

[This message has been edited by WhatEver (edited 11-08-2002).]

[This message has been edited by WhatEver (edited 11-08-2002).]

Cool, congrats, I DID look at your picture before responding :slight_smile:

Thx

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).]

You can ever re draw the surfaces with back face culling enabled and Clockwise setting, with light disabled and using colr = black.

Less efficient…but more simple.