mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
+ | Bvh and portals
This commit is contained in:
@ -19,6 +19,6 @@ Pos=1642,668
|
||||
Size=260,143
|
||||
|
||||
[Window][Debug BVH]
|
||||
Pos=60,60
|
||||
Size=159,127
|
||||
Pos=1639,663
|
||||
Size=274,205
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
CAM 1.93858 0.961594 -0.0117614 -25 180 0.05 2.1639994842342176 29.263 5
|
||||
CAM 1.82501 0.45 -0.0162945 -10 180.6 0.02 2.164 30 5
|
||||
|
||||
|
||||
MAT 255 255 255 0.0 1. 0.5 // white 0
|
||||
MAT 255 255 255 0.0 1. 0.3 // white 0
|
||||
|
||||
MAT 255 10 10 0.0 0.0 0.0 // red 1
|
||||
MAT 30 30 30 0.0 0.0 0.0 // gray 2
|
||||
@ -23,7 +23,8 @@ pl 0 -2 0 0 1 0 2 // floor
|
||||
|
||||
|
||||
qu -1 1.999 -1 2 0 0 0 0 2 6
|
||||
# sp 1 1 0 0.1 6
|
||||
|
||||
OBJ obj/Dragon_80K.obj
|
||||
|
||||
po -1.99 -0.5 -0.5 0 1 0 0 0 1 1 4
|
||||
po -0.5 -0.5 -1.99 0 1 0 1 0 0 0 4
|
||||
|
@ -31,8 +31,8 @@ hitInfo traceScene(Ray ray)
|
||||
{
|
||||
hitInfo hit;
|
||||
|
||||
for (int p = 0; p < 25; p++) //portals
|
||||
{
|
||||
// for (int p = 0; p < 25; p++) //portals
|
||||
// {
|
||||
hit.t = 1e30;
|
||||
hit.obj_index = -1;
|
||||
|
||||
@ -51,16 +51,17 @@ hitInfo traceScene(Ray ray)
|
||||
hit.normal = temp_hit.normal;
|
||||
}
|
||||
}
|
||||
if (hit.obj_index == -1 || objects[hit.obj_index].type != 5)
|
||||
break ;
|
||||
ray = portalRay(ray, hit);
|
||||
}
|
||||
// if (hit.obj_index == -1 || objects[hit.obj_index].type != 5)
|
||||
// break ;
|
||||
// ray = portalRay(ray, hit);
|
||||
// }
|
||||
|
||||
return (hit);
|
||||
}
|
||||
|
||||
hitInfo traceBVH(Ray ray)
|
||||
{
|
||||
hitInfo temp_hit;
|
||||
hitInfo hit;
|
||||
|
||||
hit.t = 1e30;
|
||||
@ -76,14 +77,12 @@ hitInfo traceBVH(Ray ray)
|
||||
|
||||
GPUBvh node = bvh[current_index];
|
||||
|
||||
hitInfo temp_hit;
|
||||
if (node.is_leaf != 0)
|
||||
{
|
||||
for (int i = 0; i < node.primitive_count; i++)
|
||||
{
|
||||
GPUTriangle obj = triangles[node.first_primitive + i];
|
||||
|
||||
hitInfo temp_hit;
|
||||
if (intersectTriangle(ray, obj, temp_hit) && temp_hit.t < hit.t)
|
||||
{
|
||||
hit.t = temp_hit.t;
|
||||
@ -127,10 +126,20 @@ hitInfo traceBVH(Ray ray)
|
||||
|
||||
hitInfo traceRay(Ray ray)
|
||||
{
|
||||
hitInfo hitBVH = traceBVH(ray);
|
||||
hitInfo hitScene = traceScene(ray);
|
||||
hitInfo hitBVH;
|
||||
hitInfo hitScene;
|
||||
hitInfo hit;
|
||||
|
||||
if (hitBVH.t < hitScene.t)
|
||||
return (hitBVH);
|
||||
return (hitScene);
|
||||
for (int i = 0; i < 10; i++) // portal ray
|
||||
{
|
||||
hitBVH = traceBVH(ray);
|
||||
hitScene = traceScene(ray);
|
||||
|
||||
hit = hitBVH.t < hitScene.t ? hitBVH : hitScene;
|
||||
if (hit.obj_index == -1 || objects[hit.obj_index].type != 5)
|
||||
break ;
|
||||
ray = portalRay(ray, hit);
|
||||
}
|
||||
|
||||
return (hit);
|
||||
}
|
Reference in New Issue
Block a user