by Spike » Sun Sep 02, 2012 8:12 am
well that is basically what its doing.
my earlier point was more that with your earlier chunk of code, trying to think of it in terms of angles is just going to confuse you - dotproducts can yield an angle when combined with normalised vectors and acos, but for this case, everything is kept purely as directions. Angles are only meaningful when you're comparing two directions (aka: 3 points), while this is a point and a plane.
But yeah, the texture vectors are two planes that state the direction in which the s+t coords increase, with the dist moving 0 away from the origin.
Of course, the texture vectors are shared between multiple surfaces, so the distance value is generally lower than abs(texturesize), so you need the mins+extents to check if the point being tested against these planes is within the quad.
if the point is outside the surface but within the triangle, you'll probably hit redundant info sticking out into space, yes. I guess the chances are that the light values in the non-existant part of the surface are more accurate than those on the ground below.
the leafs are all convex regions, so you'll not find a surface randomly jutting out of nowhere.
If you really want to constrain the samples to the region of the poly, you'll have to generate a plane from the edge lists and verify that the point is within ALL edge planes.
But really, that should be overkill as you know that you hit a solid, and that the other side of the node is solid, and that your current leaf is empty.
I suppose its possible that you get a single leaf with a diagonal v-shaped bottom, in which case yes you'll sample black from the cut surface half the time (depends on the qbsp). You can probably mitigate that by ensuring that the impact point ('mid') is within an epsilon of the surface plane, which should reject the bad plane (if they're co-planer, they should both have correct light samples).
.