forked from turanszkij/WickedEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShaderInterop_BVH.h
57 lines (47 loc) · 993 Bytes
/
ShaderInterop_BVH.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef WI_SHADERINTEROP_BVH_H
#define WI_SHADERINTEROP_BVH_H
#include "ShaderInterop_Renderer.h"
struct BVHPushConstants
{
uint instanceIndex;
uint subsetIndex;
uint primitiveCount;
uint primitiveOffset;
};
static const uint BVH_BUILDER_GROUPSIZE = 64;
// lower 8-bits in the flags are for instance masking
static const uint BVH_PRIMITIVE_FLAG_DOUBLE_SIDED = 1 << 8;
static const uint BVH_PRIMITIVE_FLAG_TRANSPARENT = 1 << 9;
struct BVHPrimitive
{
uint2 packed_prim;
uint flags;
float x0;
float y0;
float z0;
float x1;
float y1;
float z1;
float x2;
float y2;
float z2;
float3 v0() { return float3(x0, y0, z0); }
float3 v1() { return float3(x1, y1, z1); }
float3 v2() { return float3(x2, y2, z2); }
#ifndef __cplusplus
PrimitiveID primitiveID()
{
PrimitiveID prim;
prim.unpack2(packed_prim);
return prim;
}
#endif // __cplusplus
};
struct BVHNode
{
float3 min;
uint LeftChildIndex;
float3 max;
uint RightChildIndex;
};
#endif // WI_SHADERINTEROP_BVH_H