Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Vertex Shadowing Problem

Author
Message
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 11th Nov 2005 22:14
Will try and keep this short for once:

In my map editor I wanted to add light mapping, but it seemed rather complex so first I wanted to try out an idea i had for vertex shadowing using raycasting and flipping vertex normals. However I cant make it work, it seems to darken some random parts of my map object in squares and thats about it.

code for shadow mapper and my invert function (which i use to ivnert a normal value):



Having never read anything about vertex shadowing in this manner I made up the algorithm myself, so it may be flawed. But I am bothered by the fact that when stepping through in the debugger that dbGetVertexDataNormalsY(nV) often seems to return: -3.09086e-008

That cant be good >.>; Any thoughts on this routine and whats wrong?

Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 12th Nov 2005 13:33
That sounds interesting, but, shouldn't it calculate the dot product between light vector and normal vector, to determinate if it's lighted or not?
I do not get totally that distance comparison that it does actually.
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 12th Nov 2005 18:27
I suppose its really the wrong terminology - to be specific it would be more accurate to say you are calculating wether or not the vertex is shadowed, as oposed to lighted.

This code doesnt really light anything (from a certain point of view) but is intended to shade it based on a ray tracing system. The reason for me using distance is that dbIntersectObject() returns the distance to the first intersection. The model it is operating on is one big world map, the code calculates (i hope) the distance from a light in the entity structure to the world position of a vertex. It then uses dbIntersectObject to cast a line (or a ray, whatever) FROM the light TO the vertex. If intersectobject returns a distance less (or greater, cant remember not looking at the code !) than the full distance i've calculated between the vertex and the light then its safe to assume its hit some geometry on its way and thus that vertex is presumably in the shadow of that light.

Ultimatly each light would have a strength parameter or simular which if the vert was a certain distance away would cause it to ignore any influence (lit or shadowed) from the light due to its strength, but atm I just want to get the basics working then add stuff like that.

In the other if check which says if this vert is being lit by this light (or more specifically NOT shadowed) then i check if it IS being shadowed already by another light (bShadowed) and try to rotate the normal a little to decrease the blackness of the shadow to show although one light is casting a shadow over it another light is brightening this part of the shadow.. if that makes sense. Its VERY rough, again was intending to clean up when i got the basics working and it would also have to account for light strengths.

Lol, its begining to sound easier to write a light mapper

I havnt managed to get this working. I think the vertex commands are giving me rogue data though.. if anyone else wants to take a bash, be my guest

Login to post a reply

Server time is: 2024-11-19 02:40:51
Your offset time is: 2024-11-19 02:40:51