diff --git a/libraries/render-utils/src/DeferredBufferWrite.slh b/libraries/render-utils/src/DeferredBufferWrite.slh index 7b4ca7ba3b..066e0198b1 100755 --- a/libraries/render-utils/src/DeferredBufferWrite.slh +++ b/libraries/render-utils/src/DeferredBufferWrite.slh @@ -34,4 +34,10 @@ void packDeferredFragmentLightmap(vec3 normal, float alpha, vec3 diffuse, vec3 s gl_FragData[2] = vec4(emissive, shininess / 128.0); } +void packDeferredFragmentTranslucent(vec3 normal, float alpha, vec3 diffuse, vec3 specular, float shininess) { + gl_FragData[0] = vec4(diffuse.rgb, alpha); + // gl_FragData[1] = vec4(normal, 0.0) * 0.5 + vec4(0.5, 0.5, 0.5, 1.0); + // gl_FragData[2] = vec4(specular, shininess / 128.0); +} + <@endif@> diff --git a/libraries/render-utils/src/DeferredLightingEffect.cpp b/libraries/render-utils/src/DeferredLightingEffect.cpp index fc84489a2f..8200595ec2 100644 --- a/libraries/render-utils/src/DeferredLightingEffect.cpp +++ b/libraries/render-utils/src/DeferredLightingEffect.cpp @@ -169,7 +169,8 @@ void DeferredLightingEffect::render() { QOpenGLFramebufferObject* freeFBO = DependencyManager::get()->getFreeFramebufferObject(); freeFBO->bind(); glClear(GL_COLOR_BUFFER_BIT); - + glEnable(GL_FRAMEBUFFER_SRGB); + glBindTexture(GL_TEXTURE_2D, primaryFBO->texture()); glActiveTexture(GL_TEXTURE1); @@ -371,6 +372,7 @@ void DeferredLightingEffect::render() { glBindTexture(GL_TEXTURE_2D, 0); freeFBO->release(); + glDisable(GL_FRAMEBUFFER_SRGB); glDisable(GL_CULL_FACE); diff --git a/libraries/render-utils/src/Material.slh b/libraries/render-utils/src/Material.slh index e77b664ee1..923158af19 100755 --- a/libraries/render-utils/src/Material.slh +++ b/libraries/render-utils/src/Material.slh @@ -23,6 +23,7 @@ vec3 getMaterialSpecular(Material m) { return m._specular.rgb; } float getMaterialShininess(Material m) { return m._specular.a; } + <@if GLPROFILE == PC_GL@> uniform materialBuffer { Material mat; diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv index 496667a062..1c3b03a304 100755 --- a/libraries/render-utils/src/model.slv +++ b/libraries/render-utils/src/model.slv @@ -23,7 +23,7 @@ void main(void) { normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0)); // pass along the diffuse color - gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + gl_FrontColor = gl_Color; // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); diff --git a/libraries/render-utils/src/model_lightmap.slv b/libraries/render-utils/src/model_lightmap.slv index 9f19ae8de2..23d99b399a 100755 --- a/libraries/render-utils/src/model_lightmap.slv +++ b/libraries/render-utils/src/model_lightmap.slv @@ -29,7 +29,7 @@ void main(void) { normal = normalize(gl_ModelViewMatrix * vec4(gl_Normal, 0.0)); // pass along the diffuse color - gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + gl_FrontColor = gl_Color; // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slv b/libraries/render-utils/src/model_lightmap_normal_map.slv index c19336ddae..14e1d52779 100755 --- a/libraries/render-utils/src/model_lightmap_normal_map.slv +++ b/libraries/render-utils/src/model_lightmap_normal_map.slv @@ -36,7 +36,7 @@ void main(void) { interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); // pass along the diffuse color - gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + gl_FrontColor = gl_Color; // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); diff --git a/libraries/render-utils/src/model_normal_map.slv b/libraries/render-utils/src/model_normal_map.slv index 0eb974912f..a27cd49171 100755 --- a/libraries/render-utils/src/model_normal_map.slv +++ b/libraries/render-utils/src/model_normal_map.slv @@ -31,7 +31,7 @@ void main(void) { interpolatedTangent = gl_ModelViewMatrix * vec4(tangent, 0.0); // pass along the diffuse color - gl_FrontColor = gl_Color * gl_FrontMaterial.diffuse; + gl_FrontColor = gl_Color; // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf index 497f5962bc..4d1bf7bdec 100755 --- a/libraries/render-utils/src/model_translucent.slf +++ b/libraries/render-utils/src/model_translucent.slf @@ -12,10 +12,29 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +<@include DeferredBufferWrite.slh@> + +<@include Material.slh@> + // the diffuse texture uniform sampler2D diffuseMap; +varying vec4 normal; + void main(void) { + + // Fetch diffuse map + vec4 diffuse = texture2D(diffuseMap, gl_TexCoord[0].st); + + Material mat = getMaterial(); + + packDeferredFragmentTranslucent( + normalize(normal.xyz), + getMaterialOpacity(mat) * diffuse.a, + getMaterialDiffuse(mat) * diffuse.rgb, + getMaterialSpecular(mat), + getMaterialShininess(mat)); + // set the diffuse data - gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].st); + // gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].st); } diff --git a/libraries/render-utils/src/skin_model.slv b/libraries/render-utils/src/skin_model.slv index 4144198969..4cef8fddab 100755 --- a/libraries/render-utils/src/skin_model.slv +++ b/libraries/render-utils/src/skin_model.slv @@ -38,8 +38,8 @@ void main(void) { normal = normalize(gl_ModelViewMatrix * normal); // pass along the diffuse color - gl_FrontColor = gl_FrontMaterial.diffuse; - + gl_FrontColor = gl_Color; + // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0); diff --git a/libraries/render-utils/src/skin_model_normal_map.slv b/libraries/render-utils/src/skin_model_normal_map.slv index b021184591..c39f9cc0dd 100755 --- a/libraries/render-utils/src/skin_model_normal_map.slv +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -46,8 +46,8 @@ void main(void) { interpolatedTangent = gl_ModelViewMatrix * interpolatedTangent; // pass along the diffuse color - gl_FrontColor = gl_FrontMaterial.diffuse; - + gl_FrontColor = gl_Color; + // and the texture coordinates gl_TexCoord[0] = texcoordMatrices[0] * vec4(gl_MultiTexCoord0.xy, 0.0, 1.0);