bcc = (v0[0]*vp[1] - vp[0]*v0[1]) * d;
bca = 1.f - bcb - bcc;
- float hit = (tri[0].co[2] * bca + tri[1].co[2] * bcb + tri[2].co[2] * bcc) +16385.f;
+ float hit = tri[0].co[2] * bca + tri[1].co[2] * bcb + tri[2].co[2] * bcc;
+ float hit_depth = hit + 16385.f;
- if( hit > depth[i] )
+ if( hit_depth > depth[i] && hit >= rt->bounds[0][2] && hit <= rt->bounds[1][2] )
{
- depth[i] = hit;
+ depth[i] = hit_depth;
rt->shader->frag( frag+i*rt->shader->stride, tri, bca, bcb, bcc );
}
}