Skip to content

Commit e471445

Browse files
committed
2 parents 17ffbd6 + 384d7ec commit e471445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3112
-452
lines changed

.gitignore

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,25 @@ Kore.dir/*
2222
Win32/*
2323
*/obj/*
2424
demos/MainGLFW/MainGLFW.dir/*
25+
demos/VoxelConeTracing/MainGLFW.dir/*
26+
demos/VoxelConeTracing/VoxelConeTracing.dir/*
27+
demos/VoxelConeTracing/obj/*
2528
KoRE.lib
2629
lib
2730
bin
2831
ext
2932

33+
3034
# Uncomment these lines to update master and then run
3135
# git rm -r --cached . and a commit afterwards.
3236
###################################################
33-
#*.sln
34-
#*.vcxproj
35-
#*.filters
37+
*.sln
38+
*.vcxproj
39+
*.filters
3640

3741
# Comment theses lines below if you work on the voxel branch
38-
demos/VoxelConeTracing/*
39-
demos/VoxelConeTracing/src/*
40-
demos/VoxelConeTracing/*.user
41-
demos/VoxelConeTracing/*.dir
42-
Kore_Voxel.sln
42+
# demos/VoxelConeTracing/*
43+
# Kore_Voxel.sln
44+
45+
# demos/VoxelConeTracing/*.user
46+
# demos/VoxelConeTracing/*.dir

assets/meshes/triangle.dae

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<COLLADA xmlns="http://www.collada.org/2005/11/COLLADASchema" version="1.4.1">
3+
<asset>
4+
<contributor>
5+
<author>Blender User</author>
6+
<authoring_tool>Blender 2.65.0 r53189</authoring_tool>
7+
</contributor>
8+
<created>2013-04-07T16:02:42</created>
9+
<modified>2013-04-07T16:02:42</modified>
10+
<unit name="meter" meter="1"/>
11+
<up_axis>Z_UP</up_axis>
12+
</asset>
13+
<library_cameras>
14+
<camera id="Camera-camera" name="Camera">
15+
<optics>
16+
<technique_common>
17+
<perspective>
18+
<xfov sid="xfov">49.13434</xfov>
19+
<aspect_ratio>1.777778</aspect_ratio>
20+
<znear sid="znear">0.1</znear>
21+
<zfar sid="zfar">100</zfar>
22+
</perspective>
23+
</technique_common>
24+
</optics>
25+
</camera>
26+
</library_cameras>
27+
<library_lights>
28+
<light id="Lamp-light" name="Lamp">
29+
<technique_common>
30+
<point>
31+
<color sid="color">1 1 1</color>
32+
<constant_attenuation>1</constant_attenuation>
33+
<linear_attenuation>0</linear_attenuation>
34+
<quadratic_attenuation>0.00111109</quadratic_attenuation>
35+
</point>
36+
</technique_common>
37+
<extra>
38+
<technique profile="blender">
39+
<adapt_thresh>0.000999987</adapt_thresh>
40+
<area_shape>1</area_shape>
41+
<area_size>0.1</area_size>
42+
<area_sizey>0.1</area_sizey>
43+
<area_sizez>1</area_sizez>
44+
<atm_distance_factor>1</atm_distance_factor>
45+
<atm_extinction_factor>1</atm_extinction_factor>
46+
<atm_turbidity>2</atm_turbidity>
47+
<att1>0</att1>
48+
<att2>1</att2>
49+
<backscattered_light>1</backscattered_light>
50+
<bias>1</bias>
51+
<blue>1</blue>
52+
<buffers>1</buffers>
53+
<bufflag>0</bufflag>
54+
<bufsize>2880</bufsize>
55+
<buftype>2</buftype>
56+
<clipend>30.002</clipend>
57+
<clipsta>1.000799</clipsta>
58+
<compressthresh>0.04999995</compressthresh>
59+
<dist sid="blender_dist">29.99998</dist>
60+
<energy sid="blender_energy">1</energy>
61+
<falloff_type>2</falloff_type>
62+
<filtertype>0</filtertype>
63+
<flag>0</flag>
64+
<gamma sid="blender_gamma">1</gamma>
65+
<green>1</green>
66+
<halo_intensity sid="blnder_halo_intensity">1</halo_intensity>
67+
<horizon_brightness>1</horizon_brightness>
68+
<mode>8192</mode>
69+
<ray_samp>1</ray_samp>
70+
<ray_samp_method>1</ray_samp_method>
71+
<ray_samp_type>0</ray_samp_type>
72+
<ray_sampy>1</ray_sampy>
73+
<ray_sampz>1</ray_sampz>
74+
<red>1</red>
75+
<samp>3</samp>
76+
<shadhalostep>0</shadhalostep>
77+
<shadow_b sid="blender_shadow_b">0</shadow_b>
78+
<shadow_g sid="blender_shadow_g">0</shadow_g>
79+
<shadow_r sid="blender_shadow_r">0</shadow_r>
80+
<shadspotsize>45</shadspotsize>
81+
<sky_colorspace>0</sky_colorspace>
82+
<sky_exposure>1</sky_exposure>
83+
<skyblendfac>1</skyblendfac>
84+
<skyblendtype>1</skyblendtype>
85+
<soft>3</soft>
86+
<spotblend>0.15</spotblend>
87+
<spotsize>75</spotsize>
88+
<spread>1</spread>
89+
<sun_brightness>1</sun_brightness>
90+
<sun_effect_type>0</sun_effect_type>
91+
<sun_intensity>1</sun_intensity>
92+
<sun_size>1</sun_size>
93+
<type>0</type>
94+
</technique>
95+
</extra>
96+
</light>
97+
</library_lights>
98+
<library_images/>
99+
<library_geometries>
100+
<geometry id="Plane-mesh" name="Plane">
101+
<mesh>
102+
<source id="Plane-mesh-positions">
103+
<float_array id="Plane-mesh-positions-array" count="9">1 -1 0 -1 -1 0 1 1 0</float_array>
104+
<technique_common>
105+
<accessor source="#Plane-mesh-positions-array" count="3" stride="3">
106+
<param name="X" type="float"/>
107+
<param name="Y" type="float"/>
108+
<param name="Z" type="float"/>
109+
</accessor>
110+
</technique_common>
111+
</source>
112+
<source id="Plane-mesh-normals">
113+
<float_array id="Plane-mesh-normals-array" count="3">0 0 1</float_array>
114+
<technique_common>
115+
<accessor source="#Plane-mesh-normals-array" count="1" stride="3">
116+
<param name="X" type="float"/>
117+
<param name="Y" type="float"/>
118+
<param name="Z" type="float"/>
119+
</accessor>
120+
</technique_common>
121+
</source>
122+
<source id="Plane-mesh-map-0">
123+
<float_array id="Plane-mesh-map-0-array" count="6">7.07007e-5 0.5 0.5 7.07007e-5 0.9999293 0.5</float_array>
124+
<technique_common>
125+
<accessor source="#Plane-mesh-map-0-array" count="3" stride="2">
126+
<param name="S" type="float"/>
127+
<param name="T" type="float"/>
128+
</accessor>
129+
</technique_common>
130+
</source>
131+
<vertices id="Plane-mesh-vertices">
132+
<input semantic="POSITION" source="#Plane-mesh-positions"/>
133+
</vertices>
134+
<polylist count="1">
135+
<input semantic="VERTEX" source="#Plane-mesh-vertices" offset="0"/>
136+
<input semantic="NORMAL" source="#Plane-mesh-normals" offset="1"/>
137+
<input semantic="TEXCOORD" source="#Plane-mesh-map-0" offset="2" set="0"/>
138+
<vcount>3 </vcount>
139+
<p>1 0 0 0 0 1 2 0 2</p>
140+
</polylist>
141+
</mesh>
142+
<extra><technique profile="MAYA"><double_sided>1</double_sided></technique></extra>
143+
</geometry>
144+
</library_geometries>
145+
<library_visual_scenes>
146+
<visual_scene id="Scene" name="Scene">
147+
<node id="Camera" name="Camera" type="NODE">
148+
<translate sid="location">7.481132 -6.50764 5.343665</translate>
149+
<rotate sid="rotationZ">0 0 1 46.69194</rotate>
150+
<rotate sid="rotationY">0 1 0 0.619768</rotate>
151+
<rotate sid="rotationX">1 0 0 63.5593</rotate>
152+
<scale sid="scale">1 1 1</scale>
153+
<instance_camera url="#Camera-camera"/>
154+
</node>
155+
<node id="Lamp" name="Lamp" type="NODE">
156+
<translate sid="location">4.076245 1.005454 5.903862</translate>
157+
<rotate sid="rotationZ">0 0 1 106.9363</rotate>
158+
<rotate sid="rotationY">0 1 0 3.163707</rotate>
159+
<rotate sid="rotationX">1 0 0 37.26105</rotate>
160+
<scale sid="scale">1 1 1</scale>
161+
<instance_light url="#Lamp-light"/>
162+
</node>
163+
<node id="Plane" name="Plane" type="NODE">
164+
<translate sid="location">0.07701468 0.3392411 0.4132721</translate>
165+
<rotate sid="rotationZ">0 0 1 -38.07144</rotate>
166+
<rotate sid="rotationY">0 1 0 39.22731</rotate>
167+
<rotate sid="rotationX">1 0 0 -51.08411</rotate>
168+
<scale sid="scale">1 1 1</scale>
169+
<instance_geometry url="#Plane-mesh"/>
170+
</node>
171+
</visual_scene>
172+
</library_visual_scenes>
173+
<scene>
174+
<instance_visual_scene url="#Scene"/>
175+
</scene>
176+
</COLLADA>

assets/shader/VoxelConeTracing/atomicCounter.frag assets/shader/VoxelConeTracing/atomicCounterFrag.shader

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ out vec4 color;
1111

1212
void main() {
1313
uint counter = atomicCounterIncrement(atomicCounter);
14-
float r = float(counter) / (800.0 * 600.0);
14+
float r = float(counter) / (1280.0 * 720.0);
1515
color = vec4(r, 0, 0, 1);
1616
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#version 420
2+
3+
layout(location = 0) in vec3 v_position;
4+
5+
uniform mat4 modelWorld;
6+
uniform mat4 view;
7+
uniform mat4 proj;
8+
9+
smooth out vec3 posWS;
10+
flat out vec3 cubeCenter;
11+
flat out float sideLengthHalf;
12+
13+
void main() {
14+
posWS = (modelWorld * vec4(v_position, 1.0)).xyz;
15+
16+
cubeCenter = vec3(modelWorld[3][0], modelWorld[3][1], modelWorld[3][2]);
17+
sideLengthHalf = abs(v_position.x);
18+
19+
gl_Position = proj * view * vec4(posWS, 1.0);
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#version 420
2+
3+
layout(location = 0) in vec3 v_position;
4+
5+
uniform mat4 modelWorld;
6+
uniform mat4 view;
7+
uniform mat4 proj;
8+
9+
out VertexData {
10+
vec3 posWS;
11+
} Out;
12+
13+
void main() {
14+
Out.posWS = (modelWorld * vec4(v_position, 1.0)).xyz;
15+
gl_Position = proj * view * vec4(Out.posWS, 1.0);
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Awaits the inputs of a Cube-vertex shader
3+
*/
4+
5+
#version 420
6+
7+
in VertexData {
8+
vec3 posWS;
9+
} In;
10+
11+
out vec4 color;
12+
13+
layout(rgba8) uniform coherent image3D voxelTex;
14+
15+
void main() {
16+
// Apply a very small offset here so we fall into the correct voxel coordinates.
17+
ivec3 samplePos = ivec3(floor(In.posWS) - vec3(0.0001, 0.0001, 0.0001) );
18+
19+
color = imageLoad(voxelTex, samplePos);
20+
21+
/* if (color.r < 0.01) {
22+
discard;
23+
} */
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Awaits the inputs of a Cube-vertex shader
3+
*/
4+
5+
#version 420
6+
7+
smooth in vec3 posWS;
8+
flat in vec3 cubeCenter;
9+
flat in float sideLengthHalf;
10+
11+
out vec4 color;
12+
13+
void main() {
14+
float distanceFactor = length(posWS - cubeCenter);
15+
color = vec4(1.0f, 0.0f, 0.0f, 1.0f) / (distanceFactor + sideLengthHalf);
16+
}

assets/shader/VoxelConeTracing/imageStore.frag assets/shader/VoxelConeTracing/imageStoreFrag.shader

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ void main() {
1414
imageStore(image, coords, vec4(1.0f, 0.0f, 0.0f, 0.0f));
1515

1616
color = vec4(0.0, 0.0, 0.0, 0.0);
17-
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
Copyright (c) 2012 The VCT Project
3+
4+
This file is part of VoxelConeTracing and is an implementation of
5+
"Interactive Indirect Illumination Using Voxel Cone Tracing" by Crassin et al
6+
7+
VoxelConeTracing is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
VoxelConeTracing is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License
18+
along with VoxelConeTracing. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
/*!
22+
* \author Dominik Lazarek ([email protected])
23+
* \author Andreas Weinmann ([email protected])
24+
*/
25+
26+
#version 420
27+
28+
layout(rgba8) uniform coherent image3D voxelTex;
29+
30+
in VertexData {
31+
vec3 posVoxelGrid;
32+
vec3 normal;
33+
vec2 uv;
34+
} In;
35+
36+
out vec4 color;
37+
38+
void main() {
39+
40+
//imageStore(voxelTex, ivec3(5, 5, 5), vec4(1.0, 0.0, 0.0, 1.0));
41+
//memoryBarrier();
42+
43+
/*for (int z = 0; z < 12; ++z) {
44+
for(int y = 0; y < 12; ++y) {
45+
for( int x = 0; x < 12; ++x) {
46+
imageStore(voxelTex, ivec3(x, y, z), vec4(1.0, 0.0, 0.0, 1.0));
47+
memoryBarrier();
48+
}
49+
}
50+
} */
51+
52+
53+
54+
//(TODO) Determine depth range
55+
ivec3 voxelPos = ivec3(In.posVoxelGrid);
56+
imageStore(voxelTex, voxelPos, vec4(1.0, 0.0, 0.0, 1.0));
57+
memoryBarrier();
58+
//imageStore(voxelTex, ivec3(5, 5, 5), vec4(1.0, 0.0, 0.0, 1.0));
59+
}

0 commit comments

Comments
 (0)