Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Etienne Schmitt
CGoGN
Commits
7e5dc1ac
Commit
7e5dc1ac
authored
Nov 15, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug raytraced version on VRJ
parent
7c02936c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
35 deletions
+43
-35
include/Utils/pointSprite.frag
include/Utils/pointSprite.frag
+19
-10
include/Utils/pointSprite.geom
include/Utils/pointSprite.geom
+24
-25
No files found.
include/Utils/pointSprite.frag
View file @
7e5dc1ac
...
...
@@ -5,28 +5,33 @@ uniform vec3 lightPos;
uniform
vec3
ambiant
;
uniform
float
size
;
#ifdef WITH_PLANE
VARYING_FRAG
vec3
eyePosFrag
;
uniform
vec3
eyePos
;
VARYING_FRAG
vec3
shiftedEye
;
#endif
#ifdef WITH_COLOR_PER_VERTEX
VARYING_FRAG
vec3
colorsprite
;
#else
uniform
vec3
colorsprite
;
#endif
VARYING_FRAG
vec2
texCoord
;
VARYING_FRAG
vec2
spriteCoord
;
VARYING_FRAG
vec3
sphereCenter
;
void
main
(
void
)
{
vec3
billboard_frag_pos
=
sphereCenter
+
vec3
(
texCoord
,
0
.
0
)
*
size
;
#ifdef WITH_PLANE
vec3
ray_direction
=
normalize
(
billboard_frag_pos
-
eyePosFrag
;);
vec3
billboard_frag_pos
=
vec3
(
spriteCoord
,
0
.
0
)
*
size
;
vec3
ray_direction
=
normalize
(
billboard_frag_pos
-
shiftedEye
);
float
av
=
dot
(
shiftedEye
,
ray_direction
);
float
arg
=
av
*
av
-
dot
(
shiftedEye
,
shiftedEye
)
+
size
*
size
;
if
(
arg
<
0
.
0
)
discard
;
float
t
=
-
av
-
sqrt
(
arg
);
vec3
frag_position_eye
=
ray_direction
*
t
+
eyePos
;
#else
vec3
billboard_frag_pos
=
sphereCenter
+
vec3
(
spriteCoord
,
0
.
0
)
*
size
;
vec3
ray_direction
=
normalize
(
billboard_frag_pos
);
#endif
float
TD
=
-
dot
(
ray_direction
,
sphereCenter
);
float
c
=
dot
(
sphereCenter
,
sphereCenter
)
-
size
*
size
;
float
arg
=
TD
*
TD
-
c
;
...
...
@@ -35,7 +40,10 @@ void main(void)
discard
;
float
t
=
-
c
/
(
TD
-
sqrt
(
arg
));
vec3
frag_position_eye
=
ray_direction
*
t
;
vec3
frag_position_eye
=
ray_direction
*
t
;
#endif
vec4
pos
=
ProjectionMatrix
*
vec4
(
frag_position_eye
,
1
.
0
);
gl_FragDepth
=
(
pos
.
z
/
pos
.
w
+
1
.
0
)
/
2
.
0
;
...
...
@@ -44,4 +52,5 @@ void main(void)
float
lambertTerm
=
dot
(
N
,
L
);
gl_FragColor
=
vec4
(
colorsprite
*
lambertTerm
+
ambiant
,
1
.
0
);
}
include/Utils/pointSprite.geom
View file @
7e5dc1ac
...
...
@@ -5,11 +5,12 @@ uniform mat4 ModelViewMatrix;
uniform
mat4
ProjectionMatrix
;
#ifdef WITH_PLANE
uniform
vec3
eyePos
;
VARYING_OUT
vec
4
eyePosFrag
;
VARYING_OUT
vec
3
shiftedEye
;
#endif
VARYING_OUT
vec2
tex
Coord
;
VARYING_OUT
vec2
sprite
Coord
;
VARYING_OUT
vec3
sphereCenter
;
#ifdef WITH_COLOR_PER_VERTEX
VARYING_IN
vec3
color
[
1
];
VARYING_OUT
vec3
colorsprite
;
...
...
@@ -18,16 +19,16 @@ VARYING_OUT vec3 sphereCenter;
#ifdef WITH_PLANE
void
corner
(
vec4
center
,
vec3
planeX
,
vec3
planeY
,
float
x
,
float
y
)
{
texCoord
=
vec2
(
1
.
4
*
x
,
1
.
4
*
y
);
vec4
pos
=
center
+
size
(
x
*
vec4
(
planeX
,
0
.
0
)
+
y
*
vec4
(
planeY
,
0
.
0
)
+
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
));
spriteCoord
=
vec2
(
x
,
y
);
vec4
pos
=
center
+
size
*
(
x
*
vec4
(
planeX
,
0
.
0
)
+
y
*
vec4
(
planeY
,
0
.
0
)
+
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
));
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
}
#else
void
corner
(
vec4
center
,
float
x
,
float
y
)
{
texCoord
=
vec2
(
1
.
4
*
x
,
1
.
4
*
y
);
vec4
pos
=
center
+
vec4
(
size
*
x
,
size
*
y
,
0
.
0
,
0
.
0
);
spriteCoord
=
vec2
(
x
,
y
);
vec4
pos
=
center
+
vec4
(
size
*
x
,
size
*
y
,
0
.
0
,
0
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
}
...
...
@@ -41,29 +42,27 @@ void main()
#endif
vec4
posCenter
=
ModelViewMatrix
*
POSITION_IN
(
0
);
sphereCenter
=
posCenter
.
xyz
;
#ifdef WITH_PLANE
vec4
EPF
=
ModelViewMatrix
*
vec4
(
eyePos
,
1
.
0
);
eyePosFrag
=
EPF
.
xyz
;
shiftedEye
=
eyePos
-
sphereCenter
;
vec3
V
=
-
shiftedEye
;
normalize
(
V
);
vec3
planeX
=
vec3
(
-
V
[
2
],
0
.
0
,
V
[
0
]);
//cross(V, vec3(0.0,1.0,0.0));
normalize
(
planeX
);
vec3
planeY
=
cross
(
planeX
,
V
);
vec3
V
=
sphereCenter
-
eyePosFrag
;
V
.
normalize
();
// vec3 planeX = cross(V, vec3(0.0,1.0,0.0));
vec3
planeX
=
vec3
(
-
V
[
2
],
0
.
0
,
V
[
0
]);
vec3
planeY
=
cross
(
X
,
V
);
corner
(
posCenter
,
planeX
,
planeY
,
-
1
.
0
,
1
.
0
);
corner
(
posCenter
,
planeX
,
planeY
,
-
1
.
0
,
-
1
.
0
);
corner
(
posCenter
,
planeX
,
planeY
,
1
.
0
,
1
.
0
);
corner
(
posCenter
,
planeX
,
planeY
,
1
.
0
,
-
1
.
0
);
corner
(
posCenter
,
planeX
,
planeY
,
-
1
.
4
,
1
.
4
);
corner
(
posCenter
,
planeX
,
planeY
,
-
1
.
4
,
-
1
.
4
);
corner
(
posCenter
,
planeX
,
planeY
,
1
.
4
,
1
.
4
);
corner
(
posCenter
,
planeX
,
planeY
,
1
.
4
,
-
1
.
4
);
#else
corner
(
posCenter
,
-
1
.
0
,
1
.
0
);
corner
(
posCenter
,
-
1
.
0
,
-
1
.
0
);
corner
(
posCenter
,
1
.
0
,
1
.
0
);
corner
(
posCenter
,
1
.
0
,
-
1
.
0
);
corner
(
posCenter
,
-
1
.
4
,
1
.
4
);
corner
(
posCenter
,
-
1
.
4
,
-
1
.
4
);
corner
(
posCenter
,
1
.
4
,
1
.
4
);
corner
(
posCenter
,
1
.
4
,
-
1
.
4
);
#endif
EndPrimitive
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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