Commit 95211aba authored by Sylvain Thery's avatar Sylvain Thery

finish ExplodeSmoothVolumes

parent 3f6ed5bb
......@@ -57,18 +57,20 @@ protected:
Utils::ShaderExplodeSmoothVolumes* m_shaderS;
bool m_smooth;
bool m_cpf;
bool m_ef;
bool m_smooth;
Utils::ShaderExplodeVolumesLines* m_shaderL;
Utils::VBO* m_vboPos;
Utils::VBO* m_vboColors;
Utils::VBO* m_vboNormals;
Utils::VBO* m_vboPosLine;
/**
......@@ -80,6 +82,13 @@ protected:
Geom::Vec3f m_globalColor;
template<typename PFP>
void updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
template<typename PFP>
void updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
public:
/**
* Constructor
......@@ -109,8 +118,8 @@ public:
* @param positions attribute of position vertices
* @param good selector
*/
// template<typename PFP>
// void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const FunctorSelect& good = allDarts) ;
/**
* update all drawing buffers
......@@ -123,9 +132,6 @@ public:
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
template<typename PFP>
void updateSmooth(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, const VolumeAttribute<typename PFP::VEC3>& colorPerFace, const FunctorSelect& good = allDarts) ;
/**
* draw edges
*/
......
// ShaderExplodeSmoothVolumes::fragmentShaderText
VARYING_FRAG vec4 ColorFS;
uniform vec4 ambient;
uniform vec4 backColor;
VARYING_FRAG vec4 normalFS;
VARYING_FRAG vec4 lightFS;
VARYING_FRAG vec3 colorVert;
void main()
{
gl_FragColor = ColorFS;
float lambertTerm = dot(normalize(normalFS),normalize(lightFS));
if (lambertTerm > 0.0)
gl_FragColor = ambient + vec4(colorVert*lambertTerm, 1.0);
else
gl_FragColor = ambient - backColor*lambertTerm;
}
......@@ -6,15 +6,16 @@ uniform mat4 NormalMatrix;
uniform mat4 ModelViewMatrix;
uniform vec3 lightPosition;
uniform vec4 ambient;
uniform vec4 backColor;
uniform vec4 plane;
VARYING_IN vec3 colorVertex[4];
VARYING_IN vec3 normalVertex[4];
VARYING_OUT vec4 ColorFS;
VARYING_OUT vec3 normalFS;
VARYING_OUT vec3 lightFS;
VARYING_OUT vec3 colorVert;
void main(void)
{
float d = dot(plane,POSITION_IN(0));
......@@ -27,15 +28,17 @@ void main(void)
vec4 P = explodeF * POSITION_IN(i) + (1.0-explodeF)* vec4(colorVertex[0],1.0);
// compute vextex illum from pos & normal
vec3 L = normalize (lightPosition - P.xyz);
vec3 N = normalize (vec3(NormalMatrix*vec4(normalVertex[i],0.0)));
float lambertTerm = dot(N,L);
vec3 N = normalize (vec3(NormalMatrix*vec4(normalVertex[i],0.0)));
// explode in volume
vec4 Q = explodeV * P + (1.0-explodeV)* POSITION_IN(0);
gl_Position = ModelViewProjectionMatrix * Q;
if (lambertTerm > 0.0)
ColorFS = ambient + vec4(colorVertex[i]*lambertTerm, 1.0);
else
ColorFS = ambient - backColor*lambertTerm;
colorVert = colorVertex[i];
normalFS = N;
lightFS = L;
EmitVertex();
}
EndPrimitive();
......
......@@ -23,7 +23,7 @@ void main(void)
vec3 v1 = POSITION_IN(2).xyz - POSITION_IN(1).xyz;
vec3 v2 = POSITION_IN(3).xyz - POSITION_IN(1).xyz;
vec3 N = cross(v1,v2);
N = normalize (vec3(NormalMatrix*vec4(N,0.0)));
N = normalize (vec3(NormalMatrix*vec4(N,0.0)));
// compute face center & lighting informations
vec4 newPos = ModelViewMatrix * vec4(colorVertex[0],1.0);
......
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