Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CAMP
campvis-public
Commits
a96267bc
Commit
a96267bc
authored
Oct 06, 2014
by
Christian Schulte zu Berge
Browse files
Further work on ParticleFlowRenderer, now correctly rendering the demo flow field.
parent
e3f4c1fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
modules/vectorfield/glsl/particleflowrenderer.vert
View file @
a96267bc
...
...
@@ -63,6 +63,7 @@ uniform mat4 _projectionMatrix = mat4(
uniform
float
_time
;
uniform
float
_frameLength
;
uniform
float
_lifetime
;
uniform
float
_scale
;
uniform
sampler3D
_volume
;
uniform
TextureParameters3D
_volumeTextureParams
;
...
...
@@ -71,19 +72,19 @@ uniform TextureParameters3D _volumeTextureParams;
subroutine
(
RenderPassType
)
void
update
()
{
if
(
_time
>
in_StartTime
)
{
float
age
=
in_StartTime
-
_time
;
if
(
age
>
_lifetime
)
{
float
age
=
_time
-
in_StartTime
;
if
(
age
>
_lifetime
||
length
(
in_Velocity
)
<
10
.
0
)
{
// particle expired, recycle
ex_Position
=
in_InitialPosition
;
ex_Velocity
=
texture
(
_volume
,
(
_volumeTextureParams
.
_
worldToTextureMatrix
*
vec4
(
ex_Position
,
1
.
0
)
).
xyz
).
xyz
;
ex_Velocity
=
texture
(
_volume
,
(
ex_Position
/
_volumeTextureParams
.
_
size
).
xyz
).
xyz
;
ex_StartTime
=
_time
;
}
else
{
// particle alive, advance
ex_Position
=
in_Position
+
(
in_Velocity
*
_frameLength
*
0
.
1
);
ex_Position
=
in_Position
+
(
in_Velocity
*
_frameLength
*
0
.
05
*
_scale
);
// compute new velocity by mixture of old velocity and flow at current location, model some inertia
vec3
v
=
texture
(
_volume
,
(
_volumeTextureParams
.
_
worldToTextureMatrix
*
vec4
(
ex_Position
,
1
.
0
)
).
xyz
).
xyz
;
vec3
v
=
texture
(
_volume
,
(
ex_Position
/
_volumeTextureParams
.
_
size
).
xyz
).
xyz
;
ex_Velocity
=
mix
(
in_Velocity
,
v
,
0
.
5
);
//smoothstep(0.5, 2.0, v/in_Velocity));
ex_StartTime
=
in_StartTime
;
}
...
...
@@ -99,7 +100,7 @@ void update() {
subroutine
(
RenderPassType
)
void
render
()
{
float
age
=
_time
-
in_StartTime
;
ex_Transparency
=
1
.
0
;
//
- (age / _lifetime);
ex_Transparency
=
(
age
>=
0
.
0
)
?
1
.
0
-
(
age
/
_lifetime
)
:
0
.
0
;
gl_Position
=
_projectionMatrix
*
(
_viewMatrix
*
(
_modelMatrix
*
vec4
(
in_Position
,
1
.
0
)));
//ex_Position = in_Position;
...
...
modules/vectorfield/processors/particleflowrenderer.cpp
View file @
a96267bc
...
...
@@ -84,7 +84,7 @@ namespace campvis {
addProperty
(
p_lenThresholdMax
);
addProperty
(
p_camera
);
addProperty
(
p_sliceNumber
);
addProperty
(
p_Time
);
addProperty
(
p_Time
,
INVALID_RESULT
|
FIRST_FREE_TO_USE_INVALIDATION_LEVEL
);
addProperty
(
p_flowProfile1
);
addProperty
(
p_flowProfile2
);
addProperty
(
p_flowProfile3
);
...
...
@@ -156,15 +156,14 @@ namespace campvis {
glEnable
(
GL_DEPTH_TEST
);
_shader
->
activate
();
_shader
->
setIgnoreUniformLocationError
(
true
);
_shader
->
setUniform
(
"_viewportSizeRCP"
,
1.
f
/
tgt
::
vec2
(
getEffectiveViewportSize
()));
_shader
->
setUniform
(
"_projectionMatrix"
,
cam
.
getProjectionMatrix
());
_shader
->
setUniform
(
"_viewMatrix"
,
cam
.
getViewMatrix
());
_shader
->
setUniform
(
"_modelMatrix"
,
vectors
->
getParent
()
->
getMappingInformation
().
getVoxelToWorldMatrix
());
_shader
->
setUniform
(
"_scale"
,
scale
);
if
(
p_enableShading
.
getValue
()
&&
light
!=
nullptr
)
{
light
->
bind
(
_shader
,
"_lightSource"
);
}
_shader
->
setIgnoreUniformLocationError
(
false
);
if
(
getInvalidationLevel
()
&
FIRST_FREE_TO_USE_INVALIDATION_LEVEL
)
{
// stage 1: perform 1 step of particle simulation
...
...
@@ -173,6 +172,8 @@ namespace campvis {
_shader
->
setUniform
(
"_frameLength"
,
frameLength
);
_shader
->
setUniform
(
"_lifetime"
,
10.
f
);
LINFO
(
_currentTime
);
tgt
::
TextureUnit
flowUnit
;
vectors
->
bind
(
_shader
,
flowUnit
,
"_volume"
,
"_volumeTextureParams"
);
...
...
@@ -201,7 +202,7 @@ namespace campvis {
_shader
->
selectSubroutine
(
tgt
::
ShaderObject
::
VERTEX_SHADER
,
"render"
);
glBindVertexArray
((
_drawBuffer
==
1
)
?
_vaoA
->
getId
()
:
_vaoB
->
getId
());
glPointSize
(
10
.
f
);
glPointSize
(
4
.
f
);
//glDrawTransformFeedback(GL_POINTS, _feedback[1-_drawBuffer]);
glDrawArrays
(
GL_POINTS
,
0
,
_numParticles
);
glPointSize
(
1.
f
);
...
...
@@ -354,7 +355,7 @@ namespace campvis {
std
::
vector
<
float
>
startTimes
;
tgt
::
vec3
imageSize
=
vectors
->
getSize
();
_numParticles
=
100
;
_numParticles
=
2048
;
for
(
GLuint
i
=
0
;
i
<
_numParticles
;
++
i
)
{
tgt
::
vec3
position
,
velocity
;
...
...
@@ -364,9 +365,9 @@ namespace campvis {
velocity
.
x
=
vectors
->
getElementNormalizedLinear
(
position
,
0
);
velocity
.
y
=
vectors
->
getElementNormalizedLinear
(
position
,
1
);
velocity
.
z
=
vectors
->
getElementNormalizedLinear
(
position
,
2
);
}
while
(
velocity
==
tgt
::
vec3
::
zero
);
}
while
(
tgt
::
length
(
velocity
)
<
100.
f
);
float
startTime
=
generateRandomFloat
(
.
1
f
);
float
startTime
=
generateRandomFloat
(
1
0.
f
);
initialPositions
.
push_back
(
position
);
initialVelocities
.
push_back
(
velocity
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment