Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
KennethVanhoey
CGoGN
Commits
2433e28a
Commit
2433e28a
authored
Oct 08, 2012
by
Sylvain Thery
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug Sprite Rendering on VRjuggler
parent
0fe57133
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
13 deletions
+35
-13
include/Utils/Shaders/shaderPhong.h
include/Utils/Shaders/shaderPhong.h
+2
-2
include/Utils/pointSprite.frag
include/Utils/pointSprite.frag
+2
-0
include/Utils/pointSprite.geom
include/Utils/pointSprite.geom
+8
-8
src/Utils/Shaders/shaderPhong.cpp
src/Utils/Shaders/shaderPhong.cpp
+3
-3
src/Utils/pointSprite.cpp
src/Utils/pointSprite.cpp
+20
-0
No files found.
include/Utils/Shaders/shaderPhong.h
View file @
2433e28a
...
...
@@ -87,10 +87,10 @@ public:
void
setShininess
(
float
shininess
);
void
setLightPosition
(
Geom
::
Vec3f
lp
);
void
setLightPosition
(
const
Geom
::
Vec3f
&
lp
);
/// set eye position for VR environement
void
setEyePosition
(
Geom
::
Vec3f
ep
);
void
setEyePosition
(
const
Geom
::
Vec3f
&
ep
);
const
Geom
::
Vec4f
&
getAmbiant
()
const
{
return
m_ambiant
;
}
...
...
include/Utils/pointSprite.frag
View file @
2433e28a
...
...
@@ -19,8 +19,10 @@ void main(void)
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
);
#endif
gl_FragColor
=
vec4
(
colorsprite
,
0
.
0
)
*
lum
;
}
include/Utils/pointSprite.geom
View file @
2433e28a
...
...
@@ -34,35 +34,35 @@ void main()
texCoord
=
vec2
(
0
.
0
,
1
.
0
);
#ifdef WITH_PLANE
vec4
pos
=
posCenter
+
vec4
(
-
size
,
size
,
0
.
0
,
0
.
0
);
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
(
planeX
,
0
.
0
)
+
vec4
(
planeY
,
0
.
0
)
vec4
pos
=
posCenter
+
vec4
(
-
size
,
size
,
0
.
0
,
0
.
0
)
;
#endif
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
#ifdef WITH_PLANE
pos
=
posCenter
+
vec4
(
-
size
,
-
size
,
0
.
0
,
0
.
0
);
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
(
planeX
,
0
.
0
)
-
vec4
(
planeY
,
0
.
0
)
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
+
vec4
(
size
,
size
,
0
.
0
,
0
.
0
);
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
(
planeX
,
0
.
0
)
+
vec4
(
planeY
,
0
.
0
)
pos
=
posCenter
+
vec4
(
size
,
size
,
0
.
0
,
0
.
0
)
;
#endif
texCoord
=
vec2
(
1
.
0
,
1
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
EmitVertex
();
#ifdef WITH_PLANE
pos
=
posCenter
+
vec4
(
size
,
-
size
,
0
.
0
,
0
.
0
);
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
(
planeX
,
0
.
0
)
-
vec4
(
planeY
,
0
.
0
)
pos
=
posCenter
+
vec4
(
size
,
-
size
,
0
.
0
,
0
.
0
)
;
#endif
texCoord
=
vec2
(
1
.
0
,
0
.
0
);
gl_Position
=
ProjectionMatrix
*
pos
;
...
...
src/Utils/Shaders/shaderPhong.cpp
View file @
2433e28a
...
...
@@ -36,7 +36,7 @@ namespace Utils
ShaderPhong
::
ShaderPhong
(
bool
doubleSided
,
bool
withEyePosition
)
:
m_with_color
(
false
),
m_with_eyepos
(
false
),
m_with_eyepos
(
withEyePosition
),
m_ambiant
(
Geom
::
Vec4f
(
0.05
f
,
0.05
f
,
0.1
f
,
0.0
f
)),
m_diffuse
(
Geom
::
Vec4f
(
0.1
f
,
1.0
f
,
0.1
f
,
0.0
f
)),
m_specular
(
Geom
::
Vec4f
(
1.0
f
,
1.0
f
,
1.0
f
,
0.0
f
)),
...
...
@@ -121,14 +121,14 @@ void ShaderPhong::setShininess(float shininess)
m_shininess
=
shininess
;
}
void
ShaderPhong
::
setLightPosition
(
Geom
::
Vec3f
lightPos
)
void
ShaderPhong
::
setLightPosition
(
const
Geom
::
Vec3f
&
lightPos
)
{
this
->
bind
();
glUniform3fv
(
*
m_unif_lightPos
,
1
,
lightPos
.
data
());
m_lightPos
=
lightPos
;
}
void
ShaderPhong
::
setEyePosition
(
Geom
::
Vec3f
eyePos
)
void
ShaderPhong
::
setEyePosition
(
const
Geom
::
Vec3f
&
eyePos
)
{
if
(
m_with_eyepos
)
{
...
...
src/Utils/pointSprite.cpp
View file @
2433e28a
...
...
@@ -53,11 +53,16 @@ PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane
std
::
string
glxgeom
=
GLSLShader
::
defines_Geom
(
"points"
,
"triangle_strip"
,
4
);
if
(
withColorPervertex
)
glxgeom
.
append
(
defineColor
);
if
(
with_plane
)
glxgeom
.
append
(
"#define WITH_PLANE 1
\n
"
);
glxgeom
.
append
(
geometryShaderText
);
std
::
string
glxfrag
(
*
GLSLShader
::
DEFINES_GL
);
if
(
withColorPervertex
)
glxfrag
.
append
(
defineColor
);
if
(
with_plane
)
glxfrag
.
append
(
"#define WITH_PLANE 1
\n
"
);
glxfrag
.
append
(
fragmentShaderText
);
loadShadersFromMemory
(
glxvert
.
c_str
(),
glxfrag
.
c_str
(),
glxgeom
.
c_str
(),
GL_POINTS
,
GL_TRIANGLE_STRIP
,
4
);
...
...
@@ -85,6 +90,12 @@ PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane
}
*
m_uniform_texture
=
glGetUniformLocation
(
program_handler
(),
"SpriteTexture"
);
if
(
with_plane
)
{
*
m_uniform_planeX
=
glGetUniformLocation
(
program_handler
(),
"planeX"
);
*
m_uniform_planeY
=
glGetUniformLocation
(
program_handler
(),
"planeY"
);
}
}
PointSprite
::~
PointSprite
()
...
...
@@ -138,6 +149,15 @@ void PointSprite::setSize(float radius)
unbind
();
}
void
PointSprite
::
setPlane
(
const
Geom
::
Vec3f
&
ox
,
const
Geom
::
Vec3f
&
oy
)
{
bind
();
glUniform3fv
(
*
m_uniform_planeX
,
1
,
ox
.
data
());
glUniform3fv
(
*
m_uniform_planeY
,
1
,
oy
.
data
());
unbind
();
}
void
PointSprite
::
computeSphere
()
{
if
(
m_ptrSphere
==
NULL
)
// normally useless
...
...
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