diff --git a/libraries/gpu/src/gpu/Texture.cpp b/libraries/gpu/src/gpu/Texture.cpp index 5b0c4c876a..f6283b95e3 100755 --- a/libraries/gpu/src/gpu/Texture.cpp +++ b/libraries/gpu/src/gpu/Texture.cpp @@ -794,7 +794,16 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector< for(int face=0; face < gpu::Texture::NUM_CUBE_FACES; face++) { PROFILE_RANGE(render_gpu, "ProcessFace"); - auto numComponents = cubeTexture.accessStoredMipFace(0,face)->getFormat().getScalarCount(); + auto mipFormat = cubeTexture.accessStoredMipFace(0, face)->getFormat(); + auto numComponents = mipFormat.getScalarCount(); + int roffset { 0 }; + int goffset { 1 }; + int boffset { 2 }; + if ((mipFormat.getSemantic() == gpu::BGRA) || (mipFormat.getSemantic() == gpu::SBGRA)) { + roffset = 2; + boffset = 0; + } + auto data = cubeTexture.accessStoredMipFace(0,face)->readData(); if (data == nullptr) { continue; @@ -882,9 +891,9 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector< for (int i = 0; i < stride; ++i) { for (int j = 0; j < stride; ++j) { int k = (int)(x + i - halfStride + (y + j - halfStride) * width) * numComponents; - red += ColorUtils::sRGB8ToLinearFloat(data[k]); - green += ColorUtils::sRGB8ToLinearFloat(data[k + 1]); - blue += ColorUtils::sRGB8ToLinearFloat(data[k + 2]); + red += ColorUtils::sRGB8ToLinearFloat(data[k + roffset]); + green += ColorUtils::sRGB8ToLinearFloat(data[k + goffset]); + blue += ColorUtils::sRGB8ToLinearFloat(data[k + boffset]); } } glm::vec3 clr(red, green, blue); @@ -911,8 +920,6 @@ bool sphericalHarmonicsFromTexture(const gpu::Texture& cubeTexture, std::vector< // save result for(uint i=0; i < sqOrder; i++) { - // gamma Correct - // output[i] = linearTosRGB(glm::vec3(resultR[i], resultG[i], resultB[i])); output[i] = glm::vec3(resultR[i], resultG[i], resultB[i]); } diff --git a/libraries/render-utils/src/LightAmbient.slh b/libraries/render-utils/src/LightAmbient.slh index bd4636c1f0..e343d8c239 100644 --- a/libraries/render-utils/src/LightAmbient.slh +++ b/libraries/render-utils/src/LightAmbient.slh @@ -77,24 +77,11 @@ void evalLightingAmbient(out vec3 diffuse, out vec3 specular, LightAmbient ambie vec3 ambientFresnel = fresnelSchlickAmbient(fresnel, eyeDir, normal, 1.0 - roughness); // Diffuse from ambient - diffuse = (1.0 - metallic) * (vec3 (1.0) - ambientFresnel); - - if (gl_FragCoord.x > 600) { - float levels = getLightAmbientMapNumMips(ambient); - float lod = min(floor((roughness)* levels), levels); - diffuse *= evalSkyboxLight(normal, lod).xyz; - } else { - diffuse *= sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), normal).xyz; - } - - if (gl_FragCoord.y > 600) { - diffuse *= 1.0 / 3.14; - } + diffuse = (1.0 - metallic) * (vec3(1.0) - ambientFresnel) * sphericalHarmonics_evalSphericalLight(getLightAmbientSphere(ambient), normal).xyz; // Specular highlight from ambient specular = evalAmbientSpecularIrradiance(ambient, eyeDir, normal, roughness) * ambientFresnel; - <@if supportScattering@> float ambientOcclusion = curvatureAO(lowNormalCurvature.w * 20.0f) * 0.5f; float ambientOcclusionHF = curvatureAO(midNormalCurvature.w * 8.0f) * 0.5f;