Commit 5b985c92 authored by Johannes Braun's avatar Johannes Braun
Browse files

Added a few byte size descriptions

parent 1fb0d0b1
......@@ -11,14 +11,6 @@ const float FLT_MIN = -1.0f/0.0f;
const float PI = 3.1415926535897932384626433832795;
const float ONE_OVER_PI = 1/PI;
const uint MFLAG_HAS_DIFFUSE = 1 << 0;
const uint MFLAG_HAS_SPECULAR = 1 << 1;
const uint MFLAG_HAS_AMBIENT = 1 << 2;
const uint MFLAG_HAS_NORMAL = 1 << 3;
const uint MFLAG_HAS_DISPLACEMENT = 1 << 4;
const uint MFLAG_HAS_TRANSPARENT = 1 << 5;
const uint MFLAG_HAS_EMISSIVE = 1 << 6;
/*
@brief A material parameter containing a 3-component color value, a texture sampler and a boolean which determines whether the texture is available.
@bytesize 32
......@@ -33,7 +25,7 @@ struct ParameterColor
/*
@brief A material parameter containing a float value (usually 0..1), a texture sampler and a boolean which determines whether the texture is available.
@bytesize 32
@bytesize 16
*/
struct ParameterFloat
{
......@@ -42,6 +34,9 @@ struct ParameterFloat
sampler2D texture;
};
/*
@bytesize 160
*/
struct Material
{
ParameterColor emission;
......@@ -57,6 +52,9 @@ struct Material
uint p[3];
};
/*
@bytesize 80
*/
struct Light
{
vec4 position;
......@@ -71,12 +69,18 @@ struct Light
float p2;
};
/*
@bytesize 16
*/
struct Triangle
{
uint indices[3];
uint material_id;
};
/*
@bytesize 80
*/
struct Vertex
{
vec4 position;
......@@ -87,12 +91,18 @@ struct Vertex
vec4 bitangent;
};
/*
@bytesize 32
*/
struct Bounds
{
vec4 min;
vec4 max;
};
/*
@bytesize 48
*/
struct BVHNode
{
Bounds bounds;
......@@ -102,6 +112,9 @@ struct BVHNode
uint parent;
};
/*
@bytesize 32
*/
struct Ray
{
vec3 direction;
......@@ -110,6 +123,9 @@ struct Ray
float py;
};
/*
@bytesize 16
*/
struct Hit
{
vec2 barycentric;
......@@ -117,21 +133,22 @@ struct Hit
uint mesh;
};
struct line_hit
{
int triangle;
};
/*
@bytesize 4 or 8
*/
struct Line
{
#ifdef USE_ANGULAR_LS
int triangle;
#else
line_hit nearest;
line_hit farthest;
int nearest;
int farthest;
#endif
};
/*
@bytesize 64
*/
struct Linespace
{
Line* lines;
......@@ -142,6 +159,9 @@ struct Linespace
float patch_size;
};
/*
@bytesize 288
*/
struct Mesh
{
Vertex* vertices;
......@@ -158,6 +178,9 @@ struct Mesh
mat4 normal_matrix;
};
/*
@bytesize 16
*/
struct TraceProperties
{
float accuracy_importance;
......@@ -167,6 +190,9 @@ struct TraceProperties
float travelled_distance;
};
/*
@bytesize 64
*/
struct Trace
{
Ray ray;
......
......@@ -176,15 +176,15 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
uint line_id = ls__lineIndex(offset_ray, mesh, tmin, tmax, face_tmin, face_tmax, swapped);
Line line = mesh.linespace.lines[line_id];
line_hit near_data = swapped ? line.farthest : line.nearest;
int near_data = swapped ? line.farthest : line.nearest;
Hit nearer;
float t;
if(near_data.triangle != -1)
if(near_data != -1)
{
nearer.triangle = near_data.triangle;
nearer.triangle = near_data;
nearer.mesh = mesh.id;
if(local_ray.intersectsTrianglePlane(near_data.triangle, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
if(local_ray.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
{
float nearest_distance = t-offset;
//float nearest_distance = getDistance(offset_ray, nearer, dir_sign)-offset;
......@@ -199,11 +199,11 @@ bool traverseLineSpace(const in Mesh mesh, const in Ray local_ray, const in bool
}
near_data = swapped ? line.nearest : line.farthest;
if(near_data.triangle != -1)
if(near_data != -1)
{
nearer.triangle = near_data.triangle;
nearer.triangle = near_data;
nearer.mesh = mesh.id;
if(local_ray.intersectsTrianglePlane(near_data.triangle, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
if(local_ray.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
{
//float farthest_distance = getDistance(offset_ray, nearer, dir_sign)-offset;
float farthest_distance = t-offset;
......
......@@ -188,20 +188,20 @@ void generate(uint gid)
nearest.barycentric = vec2(-1);
farthest.barycentric = vec2(-1);
line.nearest.triangle = -1;
line.farthest.triangle = -1;
line.nearest = -1;
line.farthest = -1;
float t_min = FLT_MAX;
u_mesh.traverseBVH(ray, false, FLT_MAX, true, nearest, farthest, t_min);
if(nearest.valid())
{
line.nearest.triangle = int(nearest.triangle);
line.nearest = int(nearest.triangle);
}
if(farthest.valid())
{
line.farthest.triangle = int(farthest.triangle);
line.farthest = int(farthest.triangle);
}
b_lines[line_index] = line;
......
......@@ -51,6 +51,10 @@ vec3 reflectedDirection(vec3 local_hemi_sample, vec3 normal, vec3 reflected, flo
return normalize(localToWorld(local_hemi_sample, normal, reflected));
}
/**
@brief Samples the material at the given vertex. In the process, all available textures will be sampled at the according texture coordinate.
So you will not only get the raw base colors, but also the textured ones.
*/
SampledMaterial getMaterialParameters(const in Material material, const in Vertex vertex)
{
SampledMaterial sampled_material;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment