aboutsummaryrefslogtreecommitdiff
path: root/template/opengl.mako
diff options
context:
space:
mode:
authorAdrian Kummerlaender2019-12-28 23:18:23 +0100
committerAdrian Kummerlaender2019-12-28 23:18:23 +0100
commite399841b70683013ebdc9f6bcb31a871fef33db2 (patch)
tree15e013be6ebc5f28793f5ba1a378fd8f53dfde18 /template/opengl.mako
parent342d554e2da1f80aa93d5d28d2d87573db87bbb0 (diff)
downloadsymlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar.gz
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar.bz2
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar.lz
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar.xz
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.tar.zst
symlbm_playground-e399841b70683013ebdc9f6bcb31a871fef33db2.zip
Adapt existing channel example to new SDF-based rendering and voxelization
Diffstat (limited to 'template/opengl.mako')
-rw-r--r--template/opengl.mako38
1 files changed, 8 insertions, 30 deletions
diff --git a/template/opengl.mako b/template/opengl.mako
index 181101c..47264e8 100644
--- a/template/opengl.mako
+++ b/template/opengl.mako
@@ -65,7 +65,6 @@ def neighbor_offset(c_i):
%>
__kernel void collect_gl_moments_to_texture(__global ${float_type}* f,
- __global int* material,
% if descriptor.d == 2:
__write_only image2d_t moments)
% elif descriptor.d == 3:
@@ -86,38 +85,17 @@ __kernel void collect_gl_moments_to_texture(__global ${float_type}* f,
float4 data;
- if (material[gid] != 5) {
% if descriptor.d == 2:
- data.x = ${ccode(moments_assignment[0].rhs)};
- data.y = ${ccode(moments_assignment[1].rhs)};
- data.z = ${ccode(moments_assignment[2].rhs)};
- data.w = sqrt(data.y*data.y + data.z*data.z);
+ data.x = ${ccode(moments_assignment[0].rhs)};
+ data.y = ${ccode(moments_assignment[1].rhs)};
+ data.z = ${ccode(moments_assignment[2].rhs)};
+ data.w = sqrt(data.y*data.y + data.z*data.z);
% elif descriptor.d == 3:
- data.x = ${ccode(moments_assignment[0].rhs)};
- data.y = ${ccode(moments_assignment[1].rhs)};
- data.z = ${ccode(moments_assignment[2].rhs)};
- data.w = ${ccode(moments_assignment[3].rhs)};
+ data.x = ${ccode(moments_assignment[0].rhs)};
+ data.y = ${ccode(moments_assignment[1].rhs)};
+ data.z = ${ccode(moments_assignment[2].rhs)};
+ data.w = ${ccode(moments_assignment[3].rhs)};
% endif
- } else {
- const int material_west = material[gid + ${neighbor_offset((-1,0,0))}];
- const int material_east = material[gid + ${neighbor_offset((1,0,0))}];
- const int material_north = material[gid + ${neighbor_offset((0,1,0))}];
- const int material_south = material[gid + ${neighbor_offset((0,-1,0))}];
- const int material_up = material[gid + ${neighbor_offset((0,0, 1))}];
- const int material_down = material[gid + ${neighbor_offset((0,0,-1))}];
-
- // recover surface normal approximation using surrounding materials
- float3 n;
- if (material_west != 5) { n.x = 1; }
- if (material_east != 5) { n.x = -1; }
- if (material_north != 5) { n.y = -1; }
- if (material_south != 5) { n.y = 1; }
- if (material_up != 5) { n.z = -1; }
- if (material_down != 5) { n.z = 1; }
-
- data.xyz = normalize(n);
- data.w = 1.0; // signal impermeable material to raytracer
- }
write_imagef(moments, ${moments_cell()}, data);
}