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
KennethVanhoey
CGoGN
Commits
d8af79ed
Commit
d8af79ed
authored
Nov 12, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PointSprite:raytracing instead of texture
parent
c2668883
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
127 additions
and
72 deletions
+127
-72
include/Utils/Shaders/shaderColorPerVertex.h
include/Utils/Shaders/shaderColorPerVertex.h
+2
-0
include/Utils/Shaders/shaderIsoLines.h
include/Utils/Shaders/shaderIsoLines.h
+3
-2
include/Utils/pointSprite.frag
include/Utils/pointSprite.frag
+38
-12
include/Utils/pointSprite.geom
include/Utils/pointSprite.geom
+42
-44
include/Utils/pointSprite.h
include/Utils/pointSprite.h
+13
-3
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
+1
-1
src/Utils/pointSprite.cpp
src/Utils/pointSprite.cpp
+28
-5
src/Utils/text3d.cpp
src/Utils/text3d.cpp
+0
-5
No files found.
include/Utils/Shaders/shaderColorPerVertex.h
View file @
d8af79ed
...
...
@@ -67,6 +67,8 @@ public:
* set opacity (0=transparent / 1=opaque)
*/
void
setOpacity
(
float
op
);
float
getOpacity
()
const
{
return
m_opacity
;}
};
}
// namespace Utils
...
...
include/Utils/Shaders/shaderIsoLines.h
View file @
d8af79ed
...
...
@@ -36,6 +36,8 @@ namespace Utils
/**
* Shader to draw iso-lines on a triangles mesh.
* Iso-line are computed on a data vertex attribute (float)
* nb iso-lines, min/max attributes value and colors can be changed on the fly
* For better rendering result use glEnable(GL_LINE_SMOOTH)
*/
class
ShaderIsoLines
:
public
GLSLShader
{
...
...
@@ -83,11 +85,10 @@ public:
void
setColors
(
const
Geom
::
Vec4f
&
colorMin
,
const
Geom
::
Vec4f
&
colorMax
);
/**
* Set min and max value of used atribute
* Set min and max value of used atribute
.
* @param attMin minimun of attribute
* @param attMax maximun of attribute
*/
void
setDataBound
(
float
attMin
,
float
attMax
);
/**
...
...
include/Utils/pointSprite.frag
View file @
d8af79ed
// PointSprite::fragmentShaderText
uniform
sampler2D
SpriteTexture
;
uniform
mat4
ProjectionMatrix
;
uniform
vec3
lightPos
;
uniform
vec3
ambiant
;
uniform
float
size
;
#ifdef WITH_PLANE
uniform
vec3
eyePos
;
uniform
vec3
eyeY
;
VARYING_FRAG
vec3
eyePosFrag
;
#endif
#ifdef WITH_COLOR_PER_VERTEX
VARYING_FRAG
vec3
colorsprite
;
...
...
@@ -11,18 +19,36 @@ uniform float size;
VARYING_FRAG
vec2
texCoord
;
VARYING_FRAG
vec2
positionFragIn
;
VARYING_FRAG
vec4
mvpFragIn
;
VARYING_FRAG
vec3
sphereCenter
;
void
main
(
void
)
{
float
lum
=
texture2D
(
SpriteTexture
,
texCoord
).
s
;
if
(
lum
==
0
.
0
)
discard
;
vec2
v
=
texCoord
-
vec2
(
0
.
5
,
0
.
5
);
#ifndef WITH_PLANE
float
z
=
size
*
sqrt
(
1
.
0
-
dot
(
v
,
v
));
vec2
zfrag
=
positionFragIn
+
vec2
(
z
,
0
.
0
);
gl_FragDepth
=
0
.
5
+
0
.
5
*
dot
(
zfrag
,
mvpFragIn
.
xy
)
/
dot
(
zfrag
,
mvpFragIn
.
zw
);
vec3
billboard_frag_pos
=
sphereCenter
+
vec3
(
texCoord
,
0
.
0
)
*
size
;
#ifdef WITH_PLANE
vec3
ray_direction
=
normalize
(
billboard_frag_pos
-
eyePosFrag
;);
#else
vec3
ray_direction
=
normalize
(
billboard_frag_pos
);
#endif
gl_FragColor
=
vec4
(
colorsprite
,
0
.
0
)
*
lum
;
float
TD
=
-
dot
(
ray_direction
,
sphereCenter
);
float
c
=
dot
(
sphereCenter
,
sphereCenter
)
-
size
*
size
;
float
arg
=
TD
*
TD
-
c
;
if
(
arg
<
0
.
0
)
discard
;
float
t
=
-
c
/
(
TD
-
sqrt
(
arg
));
vec3
frag_position_eye
=
ray_direction
*
t
;
vec4
pos
=
ProjectionMatrix
*
vec4
(
frag_position_eye
,
1
.
0
);
gl_FragDepth
=
(
pos
.
z
/
pos
.
w
+
1
.
0
)
/
2
.
0
;
vec3
N
=
normalize
(
frag_position_eye
-
sphereCenter
);
vec3
L
=
normalize
(
lightPos
-
frag_position_eye
);
float
lambertTerm
=
dot
(
N
,
L
);
gl_FragColor
=
vec4
(
colorsprite
*
lambertTerm
+
ambiant
,
1
.
0
);
}
include/Utils/pointSprite.geom
View file @
d8af79ed
...
...
@@ -3,18 +3,35 @@
uniform
float
size
;
uniform
mat4
ModelViewMatrix
;
uniform
mat4
ProjectionMatrix
;
VARYING_OUT
vec2
texCoord
;
VARYING_OUT
vec2
positionFragIn
;
VARYING_OUT
vec4
mvpFragIn
;
#ifdef WITH_PLANE
uniform
vec3
eyePos
;
uniform
vec3
eyeY
;
VARYING_OUT
vec4
eyePosFrag
;
#endif
VARYING_OUT
vec2
texCoord
;
VARYING_OUT
vec3
sphereCenter
;
#ifdef WITH_COLOR_PER_VERTEX
VARYING_IN
vec3
color
[
1
];
VARYING_OUT
vec3
colorsprite
;
#endif
#ifdef WITH_PLANE
uniform
vec3
planeX
;
uniform
vec3
planeY
;
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
));
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
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
}
#endif
void
main
()
...
...
@@ -24,48 +41,29 @@ void main()
colorsprite
=
color
[
0
];
#endif
mvpFragIn
.
x
=
ProjectionMatrix
[
2
][
2
];
mvpFragIn
.
y
=
ProjectionMatrix
[
3
][
2
];
mvpFragIn
.
z
=
ProjectionMatrix
[
2
][
3
];
mvpFragIn
.
w
=
ProjectionMatrix
[
3
][
3
];
vec4
posCenter
=
ModelViewMatrix
*
POSITION_IN
(
0
);
positionFragIn
=
posCenter
.
zw
;
texCoord
=
vec2
(
0
.
0
,
1
.
0
);
#ifdef WITH_PLANE
vec4
pos
=
posCenter
-
size
*
vec4
(
planeX
,
0
.
0
)
+
size
*
vec4
(
planeY
,
0
.
0
)
+
size
*
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
);
#else
vec4
pos
=
posCenter
+
vec4
(
-
size
,
size
,
0
.
0
,
0
.
0
);
#endif
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
sphereCenter
=
posCenter
.
xyz
;
#ifdef WITH_PLANE
pos
=
posCenter
-
size
*
vec4
(
planeX
,
0
.
0
)
-
size
*
vec4
(
planeY
,
0
.
0
)
+
size
*
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
);
#else
pos
=
posCenter
+
vec4
(
-
size
,
-
size
,
0
.
0
,
0
.
0
);
#endif
texCoord
=
vec2
(
0
.
0
,
0
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
#ifdef WITH_PLANE
pos
=
posCenter
+
size
*
vec4
(
planeX
,
0
.
0
)
+
size
*
vec4
(
planeY
,
0
.
0
)
+
size
*
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
);
#else
pos
=
posCenter
+
vec4
(
size
,
size
,
0
.
0
,
0
.
0
);
#endif
texCoord
=
vec2
(
1
.
0
,
1
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
#ifdef WITH_PLANE
vec4
EPF
=
ModelViewMatrix
*
vec4
(
eyePos
,
1
.
0
);
eyePosFrag
=
EPF
.
xyz
;
#ifdef WITH_PLANE
pos
=
posCenter
+
size
*
vec4
(
planeX
,
0
.
0
)
-
size
*
vec4
(
planeY
,
0
.
0
)
+
size
*
vec4
(
0
.
0
,
0
.
0
,
0
.
5
,
0
.
0
);
#else
pos
=
posCenter
+
vec4
(
size
,
-
size
,
0
.
0
,
0
.
0
);
#endif
texCoord
=
vec2
(
1
.
0
,
0
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
vec3
V
=
sphereCenter
-
eyePosFrag
;
V
.
normalize
();
vec3
planeX
=
cross
(
V
,
eyeY
);
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
);
#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
);
#endif
EndPrimitive
();
}
include/Utils/pointSprite.h
View file @
d8af79ed
...
...
@@ -62,9 +62,13 @@ protected:
CGoGNGLuint
m_uniform_texture
;
CGoGNGLuint
m_uniform_
planeX
;
CGoGNGLuint
m_uniform_
EyePos
;
CGoGNGLuint
m_uniform_planeY
;
CGoGNGLuint
m_uniform_EyeY
;
CGoGNGLuint
m_uniform_ambiant
;
CGoGNGLuint
m_uniform_lightPos
;
public:
/**
...
...
@@ -105,7 +109,7 @@ public:
/**
* set the plane of rendering for VR rendering
*/
void
set
Plane
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
);
void
set
EyePosition
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
);
/**
...
...
@@ -117,6 +121,12 @@ public:
* set color attribute
*/
unsigned
int
setAttributeColor
(
VBO
*
vbo
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
pos
);
void
setAmbiantColor
(
const
Geom
::
Vec3f
&
amb
);
};
}
// namespace Utils
...
...
src/Utils/Shaders/shaderExplodeVolumesLines.cpp
View file @
d8af79ed
...
...
@@ -45,7 +45,7 @@ ShaderExplodeVolumesLines::ShaderExplodeVolumesLines()
std
::
string
glxvert
(
*
GLSLShader
::
DEFINES_GL
);
glxvert
.
append
(
vertexShaderText
);
std
::
string
glxgeom
(
GLSLShader
::
defines_Geom
(
"triangles"
,
"
triangl
e_strip"
,
4
));
std
::
string
glxgeom
(
GLSLShader
::
defines_Geom
(
"triangles"
,
"
lin
e_strip"
,
4
));
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
...
...
src/Utils/pointSprite.cpp
View file @
d8af79ed
...
...
@@ -93,11 +93,18 @@ PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane
if
(
with_plane
)
{
*
m_uniform_
planeX
=
glGetUniformLocation
(
program_handler
(),
"planeX
"
);
*
m_uniform_
planeY
=
glGetUniformLocation
(
program_handler
(),
"plan
eY"
);
*
m_uniform_
EyePos
=
glGetUniformLocation
(
program_handler
(),
"eyePos
"
);
*
m_uniform_
EyeY
=
glGetUniformLocation
(
program_handler
(),
"ey
eY"
);
}
*
m_uniform_ambiant
=
glGetUniformLocation
(
program_handler
(),
"ambiant"
);
*
m_uniform_lightPos
=
glGetUniformLocation
(
program_handler
(),
"lightPos"
);
setLightPosition
(
Geom
::
Vec3f
(
2000.0
,
2000.0
,
2000.0
));
setAmbiantColor
(
Geom
::
Vec3f
(
0.1
f
,
0.1
f
,
0.1
f
));
}
PointSprite
::~
PointSprite
()
{
if
(
m_ptrSphere
!=
NULL
)
...
...
@@ -149,11 +156,11 @@ void PointSprite::setSize(float radius)
unbind
();
}
void
PointSprite
::
set
Plane
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
)
void
PointSprite
::
set
EyePosition
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
)
{
bind
();
glUniform3fv
(
*
m_uniform_
planeX
,
1
,
ox
.
data
());
glUniform3fv
(
*
m_uniform_
plan
eY
,
1
,
oy
.
data
());
glUniform3fv
(
*
m_uniform_
EyePos
,
1
,
ox
.
data
());
glUniform3fv
(
*
m_uniform_
Ey
eY
,
1
,
oy
.
data
());
unbind
();
}
...
...
@@ -197,6 +204,22 @@ void PointSprite::computeSphere()
}
}
void
PointSprite
::
setLightPosition
(
const
Geom
::
Vec3f
&
pos
)
{
bind
();
glUniform3fv
(
*
m_uniform_lightPos
,
1
,
pos
.
data
());
unbind
();
}
void
PointSprite
::
setAmbiantColor
(
const
Geom
::
Vec3f
&
amb
)
{
bind
();
glUniform3fv
(
*
m_uniform_ambiant
,
1
,
amb
.
data
());
unbind
();
}
}
// namespace Utils
}
// namespace CGoGN
src/Utils/text3d.cpp
View file @
d8af79ed
...
...
@@ -90,11 +90,6 @@ Strings3D::Strings3D(bool withBackground, const Geom::Vec3f& bgc, bool with_plan
glxfrag
.
append
(
fragmentShaderText3
);
}
std
::
cout
<<
"===================================="
<<
std
::
endl
;
std
::
cout
<<
glxfrag
<<
std
::
endl
;
std
::
cout
<<
"===================================="
<<
std
::
endl
;
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
());
m_vbo1
=
new
Utils
::
VBO
();
...
...
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