Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions scenes/disp_rect.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"technique": {
"type": "path",
"max_depth": 8
},
"camera": {
"type": "perspective",
"fov": 40,
"near_clip": 0.1,
"far_clip": 100,
"transform": [ -1,0,0,0, 0,1,0,0, 0,0,-1,10, 0,0,0,1 ]
},
"film": {
"size": [1000, 1000]
},
"textures": [
{
"type": "bitmap",
"name": "env",
"filename": "textures/environment/phalzer_forest_01_4k.exr"
},
{
"type": "checkerboard",
"name": "check",
"scale_x": 10,
"scale_y": 10,
"color0": [0,0,0],
"color1": [1,1,1]
},
{
"type": "bitmap",
"name": "tex",
"filename": "textures/grid_weight.png",
"filter_type": "trilinear"
}
],
"bsdfs": [
{"type":"diffuse", "name": "mat-Fallback"},
{"type":"diffuse", "name": "mat-Plane", "reflectance":"tex"}
],
"shapes": [
{"type":"rectangle", "name":"Plane", "width": 4, "height": 4}
],
"entities": [
{"name":"Plane","shape":"Plane", "bsdf":"mat-Plane", "transform": {"rotate": [0,0,45], "translate": [0,0,0]}}
],
"lights": [
{"type":"sky", "name":"Sky"}
]
}
50 changes: 50 additions & 0 deletions scenes/disp_rect_color.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"technique": {
"type": "path",
"max_depth": 8
},
"camera": {
"type": "perspective",
"fov": 40,
"near_clip": 0.1,
"far_clip": 100,
"transform": [ -1,0,0,0, 0,1,0,0, 0,0,-1,10, 0,0,0,1 ]
},
"film": {
"size": [1000, 1000]
},
"textures": [
{
"type": "bitmap",
"name": "env",
"filename": "textures/environment/phalzer_forest_01_4k.exr"
},
{
"type": "checkerboard",
"name": "check",
"scale_x": 10,
"scale_y": 10,
"color0": [0,0,0],
"color1": [1,1,1]
},
{
"type": "bitmap",
"name": "tex",
"filename": "textures/colorgrid.png",
"filter_type": "trilinear"
}
],
"bsdfs": [
{"type":"diffuse", "name": "mat-Fallback"},
{"type":"diffuse", "name": "mat-Plane", "reflectance":"tex"}
],
"shapes": [
{"type":"rectangle", "name":"Plane", "width": 4, "height": 4}
],
"entities": [
{"name":"Plane","shape":"Plane", "bsdf":"mat-Plane", "transform": {"rotate": [0,0,45], "translate": [0,0,0]}}
],
"lights": [
{"type":"sky", "name":"Sky"}
]
}
50 changes: 50 additions & 0 deletions scenes/disp_rect_light.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"technique": {
"type": "path",
"max_depth": 8
},
"camera": {
"type": "perspective",
"fov": 40,
"near_clip": 0.1,
"far_clip": 100,
"transform": [ -1,0,0,0, 0,1,0,0, 0,0,-1,10, 0,0,0,1 ]
},
"film": {
"size": [1000, 1000]
},
"textures": [
{
"type": "bitmap",
"name": "env",
"filename": "textures/environment/phalzer_forest_01_4k.exr"
},
{
"type": "checkerboard",
"name": "check",
"scale_x": 10,
"scale_y": 10,
"color0": [0,0,0],
"color1": [1,1,1]
},
{
"type": "bitmap",
"name": "tex",
"filename": "textures/grid_weight.png",
"filter_type": "trilinear"
}
],
"bsdfs": [
{"type":"diffuse", "name": "mat-Fallback"},
{"type":"diffuse", "name": "mat-Plane", "reflectance":"tex"}
],
"shapes": [
{"type":"rectangle", "name":"Plane", "width": 4, "height": 4}
],
"entities": [
{"name":"Plane","shape":"Plane", "bsdf":"mat-Plane", "transform": {"rotate": [0,0,45], "translate": [0,0,0]}}
],
"lights": [
{"type":"point", "name":"L1", "intensity": [3.0, 3.0, 3.0], "position": [1, 1, 1]}
]
}
37 changes: 37 additions & 0 deletions scenes/disp_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"technique": {
"type": "path",
"max_depth": 64
},
"camera": {
"type": "perspective",
"fov": 39.597755,
"near_clip": 0.1,
"far_clip": 100,
"transform": [ -1,0,0,0, 0,1,0,0, 0,0,-1,3.849529, 0,0,0,1 ]
},
"film": {
"size": [1000, 1000]
},
"textures": [
{
"type": "bitmap",
"name": "tex",
"filename": "textures/bumpmap.png",
"filter_type": "trilinear"
}
],
"bsdfs": [
{"type":"diffuse", "name": "mat-Sphere", "reflectance":"tex"}
],
"shapes": [
{"type":"uvsphere", "name":"Sphere"}
],
"entities": [
{"name":"Sphere","shape":"Sphere", "bsdf":"mat-Sphere"}
],
"lights": [
{"type":"sky", "name":"Sky"},
{"type":"sun", "name":"Sun", "sun_direction":[0.4082482904638631,0.4082482904638631,0.8164965809277261]}
]
}
Binary file added scenes/textures/bumpmap.bmp
Binary file not shown.
Binary file added scenes/textures/bumpmap2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scenes/textures/colorgrid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scenes/textures/rect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added scenes/textures/smooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
2 changes: 1 addition & 1 deletion src/artic/render/device.art
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct Device {
load_custom_dyntable: fn (&[u8] /* Filename */) -> DynTable,

// [Internal] Load the whole shape bvh table from a dynamic table
load_bvh_table: fn (DynTable) -> BVHTable,
load_bvh_table: fn (DynTable, Image) -> BVHTable,

// [Internal] Will load the rays given in 'tracing' mode
load_rays: fn () -> &[StreamRay],
Expand Down
2 changes: 1 addition & 1 deletion src/artic/render/mapping_cpu.art
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ fn @make_cpu_device(vector_compact: bool, single: bool, min_max: MinMax, vector_
ignis_load_custom_dyntable(0, name, &mut table);
table
},
load_bvh_table = @ |dtb| -> BVHTable {
load_bvh_table = @ |dtb, _| -> BVHTable {
@ |id| {
let entry = get_lookup_entry(id as u64, dtb, @|ptr| make_cpu_buffer(ptr, 0));
let header = get_table_entry(entry.offset, dtb, @|ptr| make_cpu_buffer(ptr, 0));
Expand Down
13 changes: 7 additions & 6 deletions src/artic/render/mapping_gpu.art
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,16 @@ fn @make_gpu_device( dev_id: i32
ignis_load_custom_dyntable(dev_id, name, &mut table);
table
},
load_bvh_table = @ |dtb| -> BVHTable {
load_bvh_table = @ |bvhs, disp_map| -> BVHTable {
@ |id| {
let entry = get_lookup_entry(id as u64, dtb, accb);
let header = get_table_entry(entry.offset, dtb, accb);
let entry = get_lookup_entry(id as u64, bvhs, accb);
let header = get_table_entry(entry.offset, bvhs, accb);
let leaf_offset = header.load_i32(0) as u64;

let nodes = get_table_ptr(entry.offset + 16, dtb) as &[Node2];
let tris = get_table_ptr(entry.offset + 16 + leaf_offset * (sizeof[Node2]() as u64), dtb) as &[Tri1];
make_gpu_bvh2_tri1(nodes, tris, is_nvvm)
let nodes = get_table_ptr(entry.offset + 16, bvhs) as &[Node2];
let tris = get_table_ptr(entry.offset + 16 + leaf_offset * (sizeof[Node2]() as u64), bvhs) as &[Tri1];

make_gpu_bvh2_tri1(nodes, tris, is_nvvm, min_max, disp_map)
}
},
load_image = @ |filename| {
Expand Down
39 changes: 39 additions & 0 deletions src/artic/traversal/intersection.art
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ struct Tri {
n: Vec3 // Geometric normal (= cross(e1, e2))
}

struct UVTri {
v0: Vec3, // First vertex
v1: Vec3, // Second vertex
v2: Vec3, // Third vertex
e1: Vec3, // First edge (= v0 - v1)
e2: Vec3, // Second edge (= v2 - v0)
n: Vec3, // Geometric normal (= cross(e1, e2))
c0: Vec2,
c1: Vec2,
c2: Vec2,
wc0: Vec2,
wc1: Vec2,
wc2: Vec2
}

// Min/max functions required to perform the ray-box test
struct MinMax {
fmaxmaxf: fn (f32, f32, f32) -> f32,
Expand Down Expand Up @@ -63,6 +78,30 @@ fn @make_tri(v0: Vec3, e1: Vec3, e2: Vec3, n: Vec3) = Tri {
n = n
};

fn @make_uv_tri(v0: Vec3, e1: Vec3, e2: Vec3, n: Vec3, c0: Vec2, c1: Vec2, c2: Vec2, wc0: Vec2, wc1: Vec2, wc2: Vec2) = UVTri {
v0 = v0,
v1 = vec3_sub(v0, e1),
v2 = vec3_add(v0, e2),
e1 = e1,
e2 = e2,
n = n,
c0 = c0,
c1 = c1,
c2 = c2,
wc0 = wc0,
wc1 = wc1,
wc2 = wc2
};

fn @uvtri2tri(uvtri : UVTri) -> Tri {
make_tri(
uvtri.v0,
uvtri.e1,
uvtri.e2,
uvtri.n
)
}

fn @empty_hit(tmax: f32) = make_hit(-1, -1, tmax, undef[Vec2]());

fn @intersect_ray_tri_mt(backface_culling: bool, ray: Ray, tri: Tri) -> Option[(f32, f32, f32)] {
Expand Down
13 changes: 10 additions & 3 deletions src/artic/traversal/mapping_cpu.art
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ struct Tri4 {
e1: [[f32 * 4] * 3],
e2: [[f32 * 4] * 3],
n: [[f32 * 4] * 3],
prim_id: [i32 * 4]
prim_id: [i32 * 4],
c0: [[f32 * 4] * 2],
c1: [[f32 * 4] * 2],
c2: [[f32 * 4] * 2],
}

struct Node4 {
Expand Down Expand Up @@ -86,6 +89,7 @@ fn @make_cpu_node8(j: i32, nodes: &[Node8]) = Node {
};

fn @make_cpu_tri4(tris: &[Tri4]) -> fn (i32) -> Prim {

@ |j| Prim {
intersect = @ |i, ray| -> Option[Hit] {
let tri_ptr = rv_align(&tris(j) as &i8, 32) as &Tri4;
Expand Down Expand Up @@ -189,6 +193,7 @@ fn @cpu_traverse_single_helper_prim( mut ray: Ray
, bvh: PrimBvh
, any_hit: bool
, root: i32
, _shape : Shape
) -> Hit {
let sorting_network = match bvh.arity {
8 => batcher_sort,
Expand Down Expand Up @@ -313,6 +318,7 @@ fn @cpu_traverse_helper_prim( mut ray: Ray
, single: bool
, any_hit: bool
, root: i32
, shape : Shape
) -> Hit {

let switch_threshold = match vector_width {
Expand Down Expand Up @@ -360,7 +366,7 @@ fn @cpu_traverse_helper_prim( mut ray: Ray
for lane in cpu_one_bits(mask) {
let lane_ray = load_ray(&ray, lane);
let lane_octant = bitcast[RayOctant](rv_extract(bitcast[f32](octant), lane));
let lane_hit = cpu_traverse_single_helper_prim(lane_ray, lane_octant, min_max, bvh, any_hit, stack.top().node);
let lane_hit = cpu_traverse_single_helper_prim(lane_ray, lane_octant, min_max, bvh, any_hit, stack.top().node, shape);
if lane_hit.prim_id >= 0 {
store_hit(&mut hit, lane, lane_hit);
if !any_hit { rv_store(&mut ray.tmax, lane, lane_hit.distance); }
Expand Down Expand Up @@ -504,7 +510,8 @@ fn @cpu_traverse_helper( mut ray: Ray
if tmin <= hit.distance {
let local_ray = transform_ray(ray, leaf.local);
let shape_bvh = @prim_bvhs(leaf.shape_id);
let local_hit = cpu_traverse_helper_prim(local_ray, vector_width, min_max, shape_bvh, single, any_hit, 1/*root*/);
let shape = scene.database.shapes(leaf.shape_id);
let local_hit = cpu_traverse_helper_prim(local_ray, vector_width, min_max, shape_bvh, single, any_hit, 1/*root*/, shape);

if active {
if local_hit.prim_id != -1 {
Expand Down
Loading