Commit 7c02936c authored by Sylvain Thery's avatar Sylvain Thery

update pointsprite for VR

parent 0952c461
......@@ -5,8 +5,6 @@ uniform vec3 lightPos;
uniform vec3 ambiant;
uniform float size;
#ifdef WITH_PLANE
uniform vec3 eyePos;
uniform vec3 eyeY;
VARYING_FRAG vec3 eyePosFrag;
#endif
......@@ -21,18 +19,14 @@ uniform float size;
VARYING_FRAG vec2 texCoord;
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;);
#else
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;
......@@ -50,5 +44,4 @@ void main(void)
float lambertTerm = dot(N,L);
gl_FragColor = vec4(colorsprite*lambertTerm + ambiant ,1.0);
}
......@@ -5,7 +5,6 @@ uniform mat4 ModelViewMatrix;
uniform mat4 ProjectionMatrix;
#ifdef WITH_PLANE
uniform vec3 eyePos;
uniform vec3 eyeY;
VARYING_OUT vec4 eyePosFrag;
#endif
......@@ -51,7 +50,8 @@ void main()
vec3 V = sphereCenter-eyePosFrag;
V.normalize();
vec3 planeX = cross(V, eyeY);
// 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);
......
......@@ -64,7 +64,7 @@ protected:
CGoGNGLuint m_uniform_EyePos;
CGoGNGLuint m_uniform_EyeY;
// CGoGNGLuint m_uniform_EyeY;
CGoGNGLuint m_uniform_ambiant;
......@@ -109,7 +109,7 @@ public:
/**
* set the plane of rendering for VR rendering
*/
void setEyePosition(const Geom::Vec3f& ox, const Geom::Vec3f& oy);
void setEyePosition(const Geom::Vec3f& ep);
/**
......
......@@ -94,7 +94,7 @@ PointSprite::PointSprite(bool withColorPervertex, float radius, bool with_plane
if (with_plane)
{
*m_uniform_EyePos = glGetUniformLocation(program_handler(),"eyePos");
*m_uniform_EyeY = glGetUniformLocation(program_handler(),"eyeY");
// *m_uniform_EyeY = glGetUniformLocation(program_handler(),"eyeY");
}
*m_uniform_ambiant = glGetUniformLocation(program_handler(),"ambiant");
......@@ -156,11 +156,11 @@ void PointSprite::setSize(float radius)
unbind();
}
void PointSprite::setEyePosition(const Geom::Vec3f& ox, const Geom::Vec3f& oy)
void PointSprite::setEyePosition(const Geom::Vec3f& ep)
{
bind();
glUniform3fv(*m_uniform_EyePos, 1, ox.data());
glUniform3fv(*m_uniform_EyeY, 1, oy.data());
glUniform3fv(*m_uniform_EyePos, 1, ep.data());
// glUniform3fv(*m_uniform_EyeY, 1, oy.data());
unbind();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment