mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
Working on getting glow to work with deferred lighting.
This commit is contained in:
parent
0f3a020b5d
commit
580d591dc4
8 changed files with 15 additions and 13 deletions
|
@ -20,7 +20,7 @@ varying vec4 normal;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set the diffuse, normal, specular data
|
// set the diffuse, normal, specular data
|
||||||
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||||
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, step(diffuse.a, 0.5));
|
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, mix(gl_Color.a, 1.0 - gl_Color.a, step(diffuse.a, 0.5)));
|
||||||
gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0);
|
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ void main(void) {
|
||||||
|
|
||||||
// set the diffuse, normal, specular data
|
// set the diffuse, normal, specular data
|
||||||
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||||
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, step(diffuse.a, 0.5));
|
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, mix(gl_Color.a, 1.0 - gl_Color.a, step(diffuse.a, 0.5)));
|
||||||
gl_FragData[1] = viewNormal + vec4(0.5, 0.5, 0.5, 1.0);
|
gl_FragData[1] = viewNormal + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0);
|
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, gl_FrontMaterial.shininess / 128.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ void main(void) {
|
||||||
|
|
||||||
// set the diffuse, normal, specular data
|
// set the diffuse, normal, specular data
|
||||||
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||||
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, step(diffuse.a, 0.5));
|
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, mix(gl_Color.a, 1.0 - gl_Color.a, step(diffuse.a, 0.5)));
|
||||||
gl_FragData[1] = viewNormal + vec4(0.5, 0.5, 0.5, 1.0);
|
gl_FragData[1] = viewNormal + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb * texture2D(specularMap, gl_TexCoord[0].st).rgb,
|
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb * texture2D(specularMap, gl_TexCoord[0].st).rgb,
|
||||||
gl_FrontMaterial.shininess / 128.0);
|
gl_FrontMaterial.shininess / 128.0);
|
||||||
|
|
|
@ -23,7 +23,7 @@ varying vec4 normal;
|
||||||
void main(void) {
|
void main(void) {
|
||||||
// set the diffuse, normal, specular data
|
// set the diffuse, normal, specular data
|
||||||
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st);
|
||||||
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, step(diffuse.a, 0.5));
|
gl_FragData[0] = vec4(gl_Color.rgb * diffuse.rgb, mix(gl_Color.a, 1.0 - gl_Color.a, step(diffuse.a, 0.5)));
|
||||||
gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
gl_FragData[1] = normalize(normal) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0);
|
||||||
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb * texture2D(specularMap, gl_TexCoord[0].st).rgb,
|
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb * texture2D(specularMap, gl_TexCoord[0].st).rgb,
|
||||||
gl_FrontMaterial.shininess / 128.0);
|
gl_FrontMaterial.shininess / 128.0);
|
||||||
|
|
|
@ -2700,7 +2700,6 @@ void Application::updateShadowMap() {
|
||||||
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
|
const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f };
|
||||||
const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
|
const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
|
||||||
const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
|
const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
|
||||||
const GLfloat NO_SPECULAR_COLOR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
|
|
||||||
|
|
||||||
void Application::setupWorldLight() {
|
void Application::setupWorldLight() {
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,9 @@ public:
|
||||||
/// Stops using the glow effect.
|
/// Stops using the glow effect.
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
|
/// Returns the current glow intensity.
|
||||||
|
float getIntensity() const { return _intensity; }
|
||||||
|
|
||||||
/// Renders the glow effect. To be called after rendering the scene.
|
/// Renders the glow effect. To be called after rendering the scene.
|
||||||
/// \param toTexture whether to render to a texture, rather than to the frame buffer
|
/// \param toTexture whether to render to a texture, rather than to the frame buffer
|
||||||
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
|
/// \return the framebuffer object to which we rendered, or NULL if to the frame buffer
|
||||||
|
|
|
@ -430,20 +430,20 @@ bool Model::render(float alpha, RenderMode mode) {
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
glEnable(GL_ALPHA_TEST);
|
glEnable(GL_ALPHA_TEST);
|
||||||
glAlphaFunc(GL_EQUAL, 0.0f);
|
glAlphaFunc(GL_EQUAL, Application::getInstance()->getGlowEffect()->getIntensity());
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
|
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(
|
||||||
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == DIFFUSE_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
mode == DEFAULT_RENDER_MODE || mode == NORMAL_RENDER_MODE,
|
||||||
mode == DEFAULT_RENDER_MODE);
|
mode == DEFAULT_RENDER_MODE);
|
||||||
|
|
||||||
renderMeshes(alpha, mode, false);
|
renderMeshes(mode, false);
|
||||||
|
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
||||||
// render translucent meshes afterwards
|
// render translucent meshes afterwards
|
||||||
|
|
||||||
renderMeshes(alpha, mode, true);
|
renderMeshes(mode, true);
|
||||||
|
|
||||||
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
|
Application::getInstance()->getTextureCache()->setPrimaryDrawBuffers(true);
|
||||||
|
|
||||||
|
@ -1192,7 +1192,7 @@ void Model::deleteGeometry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
void Model::renderMeshes(RenderMode mode, bool translucent) {
|
||||||
updateVisibleJointStates();
|
updateVisibleJointStates();
|
||||||
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
const FBXGeometry& geometry = _geometry->getFBXGeometry();
|
||||||
const QVector<NetworkMesh>& networkMeshes = _geometry->getMeshes();
|
const QVector<NetworkMesh>& networkMeshes = _geometry->getMeshes();
|
||||||
|
@ -1298,7 +1298,7 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
if (!mesh.colors.isEmpty()) {
|
if (!mesh.colors.isEmpty()) {
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
} else {
|
} else {
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
if (!mesh.texCoords.isEmpty()) {
|
if (!mesh.texCoords.isEmpty()) {
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
@ -1317,8 +1317,8 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
glm::vec4 diffuse = glm::vec4(part.diffuseColor, alpha);
|
glm::vec4 diffuse = glm::vec4(part.diffuseColor, Application::getInstance()->getGlowEffect()->getIntensity());
|
||||||
glm::vec4 specular = glm::vec4(part.specularColor, alpha);
|
glm::vec4 specular = glm::vec4(part.specularColor, 1.0f);
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
|
glMaterialfv(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
|
||||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
|
glMaterialfv(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
|
||||||
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&specular);
|
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&specular);
|
||||||
|
|
|
@ -259,7 +259,7 @@ private:
|
||||||
|
|
||||||
void applyNextGeometry();
|
void applyNextGeometry();
|
||||||
void deleteGeometry();
|
void deleteGeometry();
|
||||||
void renderMeshes(float alpha, RenderMode mode, bool translucent);
|
void renderMeshes(RenderMode mode, bool translucent);
|
||||||
QVector<JointState> createJointStates(const FBXGeometry& geometry);
|
QVector<JointState> createJointStates(const FBXGeometry& geometry);
|
||||||
void initJointTransforms();
|
void initJointTransforms();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue