summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2020-09-11 08:34:00 +0300
committerAntti Määttä <antti.maatta@qt.io>2020-09-14 08:44:57 +0300
commitd581c1664e635d21650a6300dc63ec84d112fcc5 (patch)
treef2aa36f02926b70a23ace9010c0e9dc84debc701
parent1319a683ad5f325a504967170971502149793533 (diff)
Fix RGBE specular map shader
When RGBE map is set into the specular reflection map, it needs to be read in shader as RGBE instead of RGBA. Task-number: QT3DS-4160 Change-Id: Ib4baf0cf775d779a5b679ff131f89b9c893bbec7 Reviewed-by: Tony Leinonen <tony.leinonen@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
-rw-r--r--src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
index 41446e3..157434d 100644
--- a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
+++ b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
@@ -1460,17 +1460,28 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
fragmentShader.Append(" global_diffuse_light *= texture_color;");
break;
case ImageMapTypes::Specular:
-
fragmentShader.AddUniform("material_specular", "vec4");
- if (fragmentHasSpecularAmount) {
- fragmentShader.Append(" global_specular_light.xyz += specularAmount * "
- "specularColor * texture_color.xyz * "
- "material_specular.xyz;");
+ if (image->m_Image.m_TextureData.m_Texture->GetTextureDetails().m_Format != NVRenderTextureFormats::RGBE8) {
+ if (fragmentHasSpecularAmount) {
+ fragmentShader.Append(" global_specular_light.xyz += specularAmount * "
+ "specularColor * texture_color.xyz * "
+ "material_specular.xyz;");
+ } else {
+ fragmentShader.Append(" global_specular_light.xyz += texture_color.xyz * "
+ "material_specular.xyz;");
+ }
+ fragmentShader.Append(" global_diffuse_light.a *= texture_color.a;");
} else {
- fragmentShader.Append(" global_specular_light.xyz += texture_color.xyz * "
- "material_specular.xyz;");
+ // RGBE map
+ if (fragmentHasSpecularAmount) {
+ fragmentShader.Append(" global_specular_light.xyz += specularAmount * "
+ "specularColor * texture_color.xyz * pow(2.0, texture_color.a * 255.0 - 128.0);"
+ "material_specular.xyz;");
+ } else {
+ fragmentShader.Append(" global_specular_light.xyz += texture_color.xyz * "
+ "material_specular.xyz * pow(2.0, texture_color.a * 255.0 - 128.0);");
+ }
}
- fragmentShader.Append(" global_diffuse_light.a *= texture_color.a;");
break;
case ImageMapTypes::Opacity:
fragmentShader.Append(" global_diffuse_light.a *= texture_color.a;");