Commit 86c98a1b authored by Sylvain Thery's avatar Sylvain Thery

update shader envmap

parent 987589be
//ShaderEnvMap::fragmentShaderText
PRECISON;
VARYING_FRAG vec3 EyeVector, Normal, LightDir,refl;
VARYING_FRAG vec3 EyeVector, Normal, LightDir;
#ifdef WITH_COLOR
VARYING_FRAG vec3 Color;
#endif
......@@ -35,7 +35,7 @@ void main()
#endif
vec3 R = reflect(-EyeVector,N);
finalColor += mix(col,texture(EnvMap,R),blendCoef) * lambertTerm;
finalColor += mix(col,textureCube(EnvMap,R),blendCoef) * lambertTerm;
}
gl_FragColor=finalColor;
}
......@@ -40,7 +40,11 @@ namespace CGoGN
namespace Utils
{
/**
* Class for shader environment mapping (cube mapping)
*
* @warning shader code is GL2.0 compatible for GL3.0 replace textureCube by texture in fragment shader !
*/
class ShaderEnvMap : public ClippingShader
{
protected:
......@@ -115,10 +119,22 @@ public:
unsigned int setAttributeNormal(VBO* vbo);
// optional attributes
unsigned int setAttributeColor(VBO* vbo);
void unsetAttributeColor();
/**
* need to be called just before draw
*/
void predraw();
/**
* need to be called just after draw
*/
void postdraw();
void setCubeMap(unsigned int sz, unsigned char* Xpos, unsigned char* Ypos, unsigned char* Zpos, unsigned char* Xneg, unsigned char* Yneg, unsigned char* Zneg);
/**
......@@ -135,16 +151,17 @@ public:
/**
* set colored plane for testing
*/
bool setCubeMapPipo();
bool setCubeMapColored();
/**
* set colored plane for testing
*/
bool setCubeMapCheckered();
#ifdef WITH_QT
bool setCubeMap(const std::string& filename);
#endif
void predraw();
void postdraw();
};
} // namespace Utils
......
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