summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntti Määttä <antti.maatta@qt.io>2019-12-12 14:40:21 +0200
committerAntti Määttä <antti.maatta@qt.io>2019-12-27 11:21:24 +0200
commitc4ed0d6acfc2cb444a5260cbd509a427208f7ac5 (patch)
tree6ceba81778153e8a28f0fa4ef918c2498cb40b51
parent71190e5a059eba4c911abcfdd599c2a98d674ed0 (diff)
Optimize and cleanup shaders
Change-Id: Ia27680e20f73ffe645d5a336fad7024e67a8389b Reviewed-by: Janne Kangas <janne.kangas@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
-rw-r--r--Studio/Content/Material Library/aluminium_anodized.shader2
-rw-r--r--Studio/Content/Material Library/aluminium_anodized_emissive.shader2
-rw-r--r--Studio/Content/Material Library/aluminum.shader2
-rw-r--r--Studio/Content/Material Library/aluminum_anisotropic.shader4
-rw-r--r--Studio/Content/Material Library/aluminum_brushed.shader2
-rw-r--r--Studio/Content/Material Library/aluminum_emissive.shader2
-rw-r--r--Studio/Content/Material Library/aluminum_textured_aniso.shader4
-rw-r--r--Studio/Content/Material Library/asphalt.shader4
-rw-r--r--Studio/Content/Material Library/bamboo_natural_matte.shader4
-rw-r--r--Studio/Content/Material Library/bamboo_natural_matte_emissive.shader4
-rw-r--r--Studio/Content/Material Library/carbon_fiber.shader6
-rw-r--r--Studio/Content/Material Library/carbon_fiber_emissive.shader6
-rw-r--r--Studio/Content/Material Library/carpaint_blue_standard.shader6
-rw-r--r--Studio/Content/Material Library/carpaint_color_peel_2_layer.shader8
-rw-r--r--Studio/Content/Material Library/carpaint_yellow_standard.shader6
-rw-r--r--Studio/Content/Material Library/concrete.shader4
-rw-r--r--Studio/Content/Material Library/copper.shader2
-rw-r--r--Studio/Content/Material Library/leather_smoothed_black.shader4
-rw-r--r--Studio/Content/Material Library/mesh_fence.shader4
-rw-r--r--Studio/Content/Material Library/metal_mesh_fine.shader4
-rw-r--r--Studio/Content/Material Library/paper_artistic.shader2
-rw-r--r--Studio/Content/Material Library/paper_office.shader2
-rw-r--r--Studio/Content/Material Library/plastic_structured_red.shader4
-rw-r--r--Studio/Content/Material Library/plastic_structured_red_emissive.shader4
-rw-r--r--Studio/Content/Material Library/porcelain.shader4
-rw-r--r--Studio/Content/Material Library/powder_coat.shader4
-rw-r--r--Studio/Content/Material Library/powder_coat_emissive.shader4
-rw-r--r--Studio/Content/Material Library/rubber_studded_black.shader4
-rw-r--r--Studio/Content/Material Library/rubber_studded_emissive.shader4
-rw-r--r--Studio/Content/Material Library/simple_glass.shader2
-rw-r--r--Studio/Content/Material Library/steel_milled_concentric.shader4
-rw-r--r--Studio/Content/Material Library/thin_glass_frosted.shader2
-rw-r--r--Studio/Content/Material Library/thin_glass_frosted_sp.shader2
-rw-r--r--Studio/Content/Material Library/thin_glass_refractive.shader2
-rw-r--r--Studio/Content/Material Library/walnut_matte.shader4
-rw-r--r--examples/studio3d/dynamicelement/presentation/materials/copper.shader2
-rw-r--r--res.qrc6
-rw-r--r--res/effectlib/defaultMaterialFresnel.glsllib6
-rw-r--r--res/effectlib/funcdiffuseReflectionBSDF.glsllib39
-rw-r--r--res/effectlib/funcsampleAreaGlossyDefault.glsllib29
-rw-r--r--res/effectlib/funcsampleNormalTexture.glsllib6
-rw-r--r--res/effectlib/funcspecularBSDF.glsllib40
-rw-r--r--res/effectlib/gles2/sampleProbe.glsllib324
-rw-r--r--res/effectlib/gles2/sampleProbePre.glsllib7
-rw-r--r--res/effectlib/luminance.glsllib28
-rw-r--r--res/effectlib/sampleProbe.glsllib206
-rw-r--r--res/effectlib/sampleProbePre.glsllib5
-rw-r--r--res/effectlib/specularBSDF.glsllib18
-rw-r--r--src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp341
49 files changed, 367 insertions, 818 deletions
diff --git a/Studio/Content/Material Library/aluminium_anodized.shader b/Studio/Content/Material Library/aluminium_anodized.shader
index 17da9fb..62511a6 100644
--- a/Studio/Content/Material Library/aluminium_anodized.shader
+++ b/Studio/Content/Material Library/aluminium_anodized.shader
@@ -93,7 +93,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/aluminium_anodized_emissive.shader b/Studio/Content/Material Library/aluminium_anodized_emissive.shader
index 1c3233f..ae5beba 100644
--- a/Studio/Content/Material Library/aluminium_anodized_emissive.shader
+++ b/Studio/Content/Material Library/aluminium_anodized_emissive.shader
@@ -128,7 +128,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/aluminum.shader b/Studio/Content/Material Library/aluminum.shader
index e2a5bea..a046e5f 100644
--- a/Studio/Content/Material Library/aluminum.shader
+++ b/Studio/Content/Material Library/aluminum.shader
@@ -135,7 +135,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, tmp2, tmp2 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, tmp2 );
#endif
}
diff --git a/Studio/Content/Material Library/aluminum_anisotropic.shader b/Studio/Content/Material Library/aluminum_anisotropic.shader
index b5fed9f..14a211c 100644
--- a/Studio/Content/Material Library/aluminum_anisotropic.shader
+++ b/Studio/Content/Material Library/aluminum_anisotropic.shader
@@ -135,7 +135,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
#endif
}
@@ -160,7 +160,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, ftmp0 );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/aluminum_brushed.shader b/Studio/Content/Material Library/aluminum_brushed.shader
index 594b4fa..9fefa35 100644
--- a/Studio/Content/Material Library/aluminum_brushed.shader
+++ b/Studio/Content/Material Library/aluminum_brushed.shader
@@ -135,7 +135,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp1, ftmp2 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, ftmp1 );
#endif
}
diff --git a/Studio/Content/Material Library/aluminum_emissive.shader b/Studio/Content/Material Library/aluminum_emissive.shader
index ed48012..fa5d505 100644
--- a/Studio/Content/Material Library/aluminum_emissive.shader
+++ b/Studio/Content/Material Library/aluminum_emissive.shader
@@ -141,7 +141,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, tmp3, tmp3 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, tmp3 );
#endif
}
diff --git a/Studio/Content/Material Library/aluminum_textured_aniso.shader b/Studio/Content/Material Library/aluminum_textured_aniso.shader
index ed9fb88..58679ab 100644
--- a/Studio/Content/Material Library/aluminum_textured_aniso.shader
+++ b/Studio/Content/Material Library/aluminum_textured_aniso.shader
@@ -137,7 +137,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
#endif
}
@@ -162,7 +162,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, ftmp0 );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/asphalt.shader b/Studio/Content/Material Library/asphalt.shader
index da37ed4..aa21338 100644
--- a/Studio/Content/Material Library/asphalt.shader
+++ b/Studio/Content/Material Library/asphalt.shader
@@ -115,7 +115,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -140,7 +140,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness);
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/bamboo_natural_matte.shader b/Studio/Content/Material Library/bamboo_natural_matte.shader
index 28ab611..334ab50 100644
--- a/Studio/Content/Material Library/bamboo_natural_matte.shader
+++ b/Studio/Content/Material Library/bamboo_natural_matte.shader
@@ -115,7 +115,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -140,7 +140,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader b/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader
index 7096c14..6fe274b 100644
--- a/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader
+++ b/Studio/Content/Material Library/bamboo_natural_matte_emissive.shader
@@ -120,7 +120,7 @@ void computeFrontLayerColor(in vec3 normal, in vec3 lightDir, in vec3 viewDir, i
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, lightDiffuse );
#endif
}
@@ -145,7 +145,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/carbon_fiber.shader b/Studio/Content/Material Library/carbon_fiber.shader
index fd3eca3..e4817d4 100644
--- a/Studio/Content/Material Library/carbon_fiber.shader
+++ b/Studio/Content/Material Library/carbon_fiber.shader
@@ -136,7 +136,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect );
layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, lightDiffuse );
#endif
}
@@ -165,9 +165,9 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[2].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, coat_roughness );
- layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, ftmp0, ftmp1 );
+ layers[1].layer += tmpShadowTerm * sampleGlossy( layers[1].tanFrame, viewDir, ftmp0 );
layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[2].layer += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/carbon_fiber_emissive.shader b/Studio/Content/Material Library/carbon_fiber_emissive.shader
index fae9b7b..c65f259 100644
--- a/Studio/Content/Material Library/carbon_fiber_emissive.shader
+++ b/Studio/Content/Material Library/carbon_fiber_emissive.shader
@@ -141,7 +141,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect );
layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp7, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[2].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp7, lightDir, lightDiffuse );
#endif
}
@@ -170,9 +170,9 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[2].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp7, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, coat_roughness );
- layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, ftmp0, ftmp1 );
+ layers[1].layer += tmpShadowTerm * sampleGlossy( layers[1].tanFrame, viewDir, ftmp0 );
layers[2].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[2].layer += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/carpaint_blue_standard.shader b/Studio/Content/Material Library/carpaint_blue_standard.shader
index b28a814..87f5642 100644
--- a/Studio/Content/Material Library/carpaint_blue_standard.shader
+++ b/Studio/Content/Material Library/carpaint_blue_standard.shader
@@ -110,7 +110,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect );
- layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ) );
+ layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, lightDiffuse ) );
layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.200000, 0.200000, scatter_reflect );
#endif
@@ -136,10 +136,10 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, 0.200000, 0.200000, scatter_reflect );
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, 0.000000 );
layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, sampleDiffuse( layers[1].tanFrame ) * aoFactor );
- layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, 0.200000, 0.200000 );
+ layers[1].layer += tmpShadowTerm * sampleGlossy( layers[1].tanFrame, viewDir, 0.200000 );
#endif
}
diff --git a/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader b/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader
index c435306..7bc5818 100644
--- a/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader
+++ b/Studio/Content/Material Library/carpaint_color_peel_2_layer.shader
@@ -122,7 +122,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, flake_roughness, flake_roughness, scatter_reflect );
- layers[2].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[2].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
layers[2].layer += tmpShadowTerm * microfacetBSDF( layers[2].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.300000, 0.300000, scatter_reflect );
#endif
@@ -152,12 +152,12 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[2].layer += tmpShadowTerm * microfacetSampledBSDF( layers[2].tanFrame, viewDir, 0.300000, 0.300000, scatter_reflect );
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, coat_roughness, coat_roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, coat_roughness );
- layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, flake_roughness, flake_roughness );
+ layers[1].layer += tmpShadowTerm * sampleGlossy( layers[1].tanFrame, viewDir, flake_roughness );
layers[2].base += tmpShadowTerm * sampleDiffuse( layers[2].tanFrame ) * aoFactor;
- layers[2].layer += tmpShadowTerm * sampleGlossyAniso( layers[2].tanFrame, viewDir, 0.300000, 0.300000 );
+ layers[2].layer += tmpShadowTerm * sampleGlossy( layers[2].tanFrame, viewDir, 0.300000 );
#endif
}
diff --git a/Studio/Content/Material Library/carpaint_yellow_standard.shader b/Studio/Content/Material Library/carpaint_yellow_standard.shader
index 7e79511..e6e6232 100644
--- a/Studio/Content/Material Library/carpaint_yellow_standard.shader
+++ b/Studio/Content/Material Library/carpaint_yellow_standard.shader
@@ -110,7 +110,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
#if QT3DS_ENABLE_CG_LIGHTING
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.000000, 0.000000, scatter_reflect );
- layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 ) );
+ layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, diffuseReflectionBSDF( normal, lightDir, lightDiffuse ) );
layers[1].layer += tmpShadowTerm * microfacetBSDF( layers[1].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, 0.200000, 0.200000, scatter_reflect );
#endif
@@ -136,10 +136,10 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * microfacetSampledBSDF( layers[1].tanFrame, viewDir, 0.200000, 0.200000, scatter_reflect );
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, 0.000000 );
layers[1].base += tmpShadowTerm * directionalFactor( normal, viewDir, normal_base_color.rgb, grazing_base_color.rgb, 5.000000, sampleDiffuse( layers[1].tanFrame ) * aoFactor );
- layers[1].layer += tmpShadowTerm * sampleGlossyAniso( layers[1].tanFrame, viewDir, 0.200000, 0.200000 );
+ layers[1].layer += tmpShadowTerm * sampleGlossy( layers[1].tanFrame, viewDir, 0.200000 );
#endif
}
diff --git a/Studio/Content/Material Library/concrete.shader b/Studio/Content/Material Library/concrete.shader
index 1bcdadc..cabf1d2 100644
--- a/Studio/Content/Material Library/concrete.shader
+++ b/Studio/Content/Material Library/concrete.shader
@@ -114,7 +114,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, lightDiffuse );
#endif
}
@@ -139,7 +139,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/copper.shader b/Studio/Content/Material Library/copper.shader
index cf9e1ad..24d7d32 100644
--- a/Studio/Content/Material Library/copper.shader
+++ b/Studio/Content/Material Library/copper.shader
@@ -93,7 +93,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/leather_smoothed_black.shader b/Studio/Content/Material Library/leather_smoothed_black.shader
index 8d45669..05036e4 100644
--- a/Studio/Content/Material Library/leather_smoothed_black.shader
+++ b/Studio/Content/Material Library/leather_smoothed_black.shader
@@ -115,7 +115,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -140,7 +140,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/mesh_fence.shader b/Studio/Content/Material Library/mesh_fence.shader
index df5d817..3ed0943 100644
--- a/Studio/Content/Material Library/mesh_fence.shader
+++ b/Studio/Content/Material Library/mesh_fence.shader
@@ -115,7 +115,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -140,7 +140,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/metal_mesh_fine.shader b/Studio/Content/Material Library/metal_mesh_fine.shader
index f4e2d9f..21441f0 100644
--- a/Studio/Content/Material Library/metal_mesh_fine.shader
+++ b/Studio/Content/Material Library/metal_mesh_fine.shader
@@ -114,7 +114,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp6, lightDir, lightDiffuse );
#endif
}
@@ -139,7 +139,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp6, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/paper_artistic.shader b/Studio/Content/Material Library/paper_artistic.shader
index 6c7b075..38c1548 100644
--- a/Studio/Content/Material Library/paper_artistic.shader
+++ b/Studio/Content/Material Library/paper_artistic.shader
@@ -126,7 +126,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 )) ) );
+ layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, lightDiffuse )) ) );
#endif
}
diff --git a/Studio/Content/Material Library/paper_office.shader b/Studio/Content/Material Library/paper_office.shader
index 6f183a5..5be6c7e 100644
--- a/Studio/Content/Material Library/paper_office.shader
+++ b/Studio/Content/Material Library/paper_office.shader
@@ -125,7 +125,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 )) ) );
+ layers[0].base += tmpShadowTerm * normalizedMix( bsdf_component[2]( bsdf_component(transmission_weight, diffuseTransmissionBSDF( -normal, lightDir, viewDir, lightDiffuse, vec4( ftmp0, 1.0), uTranslucentFalloff, uDiffuseLightWrap )) ,bsdf_component(reflection_weight, diffuseReflectionBSDF( normal, lightDir, lightDiffuse )) ) );
#endif
}
diff --git a/Studio/Content/Material Library/plastic_structured_red.shader b/Studio/Content/Material Library/plastic_structured_red.shader
index 1e6b798..2aab2c4 100644
--- a/Studio/Content/Material Library/plastic_structured_red.shader
+++ b/Studio/Content/Material Library/plastic_structured_red.shader
@@ -96,7 +96,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse);
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
#endif
@@ -119,7 +119,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor;
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/plastic_structured_red_emissive.shader b/Studio/Content/Material Library/plastic_structured_red_emissive.shader
index f85719e..28708b5 100644
--- a/Studio/Content/Material Library/plastic_structured_red_emissive.shader
+++ b/Studio/Content/Material Library/plastic_structured_red_emissive.shader
@@ -120,7 +120,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
#endif
@@ -143,7 +143,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor;
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/porcelain.shader b/Studio/Content/Material Library/porcelain.shader
index 8b5978e..2f97720 100644
--- a/Studio/Content/Material Library/porcelain.shader
+++ b/Studio/Content/Material Library/porcelain.shader
@@ -73,7 +73,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
#endif
@@ -96,7 +96,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor;
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/powder_coat.shader b/Studio/Content/Material Library/powder_coat.shader
index c26fa04..3456639 100644
--- a/Studio/Content/Material Library/powder_coat.shader
+++ b/Studio/Content/Material Library/powder_coat.shader
@@ -103,7 +103,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
#endif
}
@@ -128,7 +128,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/powder_coat_emissive.shader b/Studio/Content/Material Library/powder_coat_emissive.shader
index 4056079..88ccb6f 100644
--- a/Studio/Content/Material Library/powder_coat_emissive.shader
+++ b/Studio/Content/Material Library/powder_coat_emissive.shader
@@ -119,7 +119,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
#endif
}
@@ -144,7 +144,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( normal, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/rubber_studded_black.shader b/Studio/Content/Material Library/rubber_studded_black.shader
index a2af7d0..e98c5f9 100644
--- a/Studio/Content/Material Library/rubber_studded_black.shader
+++ b/Studio/Content/Material Library/rubber_studded_black.shader
@@ -101,7 +101,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp4, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp4, lightDir, lightDiffuse );
#endif
}
@@ -126,7 +126,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp4, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/rubber_studded_emissive.shader b/Studio/Content/Material Library/rubber_studded_emissive.shader
index de45c93..c031554 100644
--- a/Studio/Content/Material Library/rubber_studded_emissive.shader
+++ b/Studio/Content/Material Library/rubber_studded_emissive.shader
@@ -118,7 +118,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -143,7 +143,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/Studio/Content/Material Library/simple_glass.shader b/Studio/Content/Material Library/simple_glass.shader
index 09aa2c9..5da99ed 100644
--- a/Studio/Content/Material Library/simple_glass.shader
+++ b/Studio/Content/Material Library/simple_glass.shader
@@ -95,7 +95,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, 0.000000, 0.000000, scatter_reflect_transmit );
#else
- layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, 0.000000, 0.000000 );
+ layers[0].base += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, 0.000000 );
#endif
}
diff --git a/Studio/Content/Material Library/steel_milled_concentric.shader b/Studio/Content/Material Library/steel_milled_concentric.shader
index 3cf9585..9e73f5e 100644
--- a/Studio/Content/Material Library/steel_milled_concentric.shader
+++ b/Studio/Content/Material Library/steel_milled_concentric.shader
@@ -121,7 +121,7 @@ vec3 computeFrontMaterialEmissive()
void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir, in vec3 lightDiffuse, in vec3 lightSpecular, in float materialIOR, float aoFactor )
{
#if QT3DS_ENABLE_CG_LIGHTING
- layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[0].base += tmpShadowTerm * diffuseReflectionBSDF( normal, lightDir, lightDiffuse );
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, ftmp0, ftmp1, scatter_reflect );
#endif
@@ -144,7 +144,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * sampleDiffuse( layers[0].tanFrame ) * aoFactor;
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, ftmp0, ftmp1 );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, ftmp0 );
#endif
}
diff --git a/Studio/Content/Material Library/thin_glass_frosted.shader b/Studio/Content/Material Library/thin_glass_frosted.shader
index b66c4cd..cd140b7 100644
--- a/Studio/Content/Material Library/thin_glass_frosted.shader
+++ b/Studio/Content/Material Library/thin_glass_frosted.shader
@@ -152,7 +152,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit );
#else
- layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].base += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/thin_glass_frosted_sp.shader b/Studio/Content/Material Library/thin_glass_frosted_sp.shader
index 6619ec2..38dbac2 100644
--- a/Studio/Content/Material Library/thin_glass_frosted_sp.shader
+++ b/Studio/Content/Material Library/thin_glass_frosted_sp.shader
@@ -135,7 +135,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit );
#else
- layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].base += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/thin_glass_refractive.shader b/Studio/Content/Material Library/thin_glass_refractive.shader
index 16cf172..289b634 100644
--- a/Studio/Content/Material Library/thin_glass_refractive.shader
+++ b/Studio/Content/Material Library/thin_glass_refractive.shader
@@ -97,7 +97,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[0].base += tmpShadowTerm * microfacetSampledBSDF( layers[0].tanFrame, viewDir, roughness, roughness, scatter_reflect_transmit );
#else
- layers[0].base += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].base += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
#endif
}
diff --git a/Studio/Content/Material Library/walnut_matte.shader b/Studio/Content/Material Library/walnut_matte.shader
index 4541241..5b1c48b 100644
--- a/Studio/Content/Material Library/walnut_matte.shader
+++ b/Studio/Content/Material Library/walnut_matte.shader
@@ -115,7 +115,7 @@ void computeFrontLayerColor( in vec3 normal, in vec3 lightDir, in vec3 viewDir,
layers[0].layer += tmpShadowTerm * microfacetBSDF( layers[0].tanFrame, lightDir, viewDir, lightSpecular, materialIOR, roughness, roughness, scatter_reflect );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, viewDir, lightDiffuse, 0.000000 );
+ layers[1].layer += tmpShadowTerm * diffuseReflectionBSDF( tmp5, lightDir, lightDiffuse );
#endif
}
@@ -140,7 +140,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
layers[1].layer += tmpShadowTerm * diffuseReflectionBSDFEnvironment( tmp5, 0.000000 ) * aoFactor;
#else
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness );
layers[1].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
layers[1].layer += tmpShadowTerm * sampleDiffuse( layers[1].tanFrame ) * aoFactor;
diff --git a/examples/studio3d/dynamicelement/presentation/materials/copper.shader b/examples/studio3d/dynamicelement/presentation/materials/copper.shader
index cf9e1ad..a2ebe8b 100644
--- a/examples/studio3d/dynamicelement/presentation/materials/copper.shader
+++ b/examples/studio3d/dynamicelement/presentation/materials/copper.shader
@@ -93,7 +93,7 @@ void computeFrontLayerEnvironment( in vec3 normal, in vec3 viewDir, float aoFact
#else
layers[0].base += tmpShadowTerm * vec4( 0.0, 0.0, 0.0, 1.0 );
- layers[0].layer += tmpShadowTerm * sampleGlossyAniso( layers[0].tanFrame, viewDir, roughness, roughness );
+ layers[0].layer += tmpShadowTerm * sampleGlossy( layers[0].tanFrame, viewDir, roughness);
#endif
}
diff --git a/res.qrc b/res.qrc
index c5c59b2..cc7232f 100644
--- a/res.qrc
+++ b/res.qrc
@@ -60,7 +60,7 @@
<file>res/effectlib/sampleArea.glsllib</file>
<file>res/effectlib/funcsampleLightVars.glsllib</file>
<file>res/effectlib/sampleLight.glsllib</file>
- <file>res/effectlib/sampleProbe.glsllib</file>
+ <file>res/effectlib/sampleProbePre.glsllib</file>
<file>res/effectlib/screenSpaceAO.glsllib</file>
<file>res/effectlib/screenSpaceDO.glsllib</file>
<file>res/effectlib/shadowMapping.glsllib</file>
@@ -90,7 +90,7 @@
<file>res/effectlib/weightedLayer.glsllib</file>
<file>res/effectlib/wireframeCM.glsllib</file>
<file>res/effectlib/gles2/funcsampleLightVars.glsllib</file>
- <file>res/effectlib/gles2/sampleProbe.glsllib</file>
+ <file>res/effectlib/gles2/sampleProbePre.glsllib</file>
<file>res/effectlib/gles2/SSAOCustomMaterial.glsllib</file>
<file>res/effectlib/gles2/funcareaLightVars.glsllib</file>
<file>res/effectlib/gles2/monoChannel.glsllib</file>
@@ -113,5 +113,7 @@
<file>res/effectlib/distancefieldtext_dropshadow.vert</file>
<file>res/effectlib/distancefieldtext_dropshadow_core.frag</file>
<file>res/effectlib/distancefieldtext_dropshadow_core.vert</file>
+ <file>res/effectlib/funcsampleNormalTexture.glsllib</file>
+ <file>res/effectlib/sampleProbe.glsllib</file>
</qresource>
</RCC>
diff --git a/res/effectlib/defaultMaterialFresnel.glsllib b/res/effectlib/defaultMaterialFresnel.glsllib
index e0eff4f..7a363e9 100644
--- a/res/effectlib/defaultMaterialFresnel.glsllib
+++ b/res/effectlib/defaultMaterialFresnel.glsllib
@@ -31,13 +31,11 @@
#ifndef DEFAULT_MATERIAL_FRESNEL_GLSLLIB
#define DEFAULT_MATERIAL_FRESNEL_GLSLLIB
-float defaultMaterialSimpleFresnel( in vec3 N, in vec3 viewDir, in float ior, float fresnelPower )
+float defaultMaterialSimpleFresnel(in vec3 N, in vec3 viewDir, in float ior, float fresnelPower)
{
float F = ((1.0-ior) * (1.0-ior)) / ((1.0+ior) * (1.0+ior));
- float VdotN = dot(viewDir, N);
- VdotN = clamp( VdotN, 0.0, 1.0 );
+ float VdotN = max(dot(viewDir, N), 0.0);
float ratio = F + (1.0 - F) * pow(1.0 - VdotN, fresnelPower);
-
return ratio;
}
diff --git a/res/effectlib/funcdiffuseReflectionBSDF.glsllib b/res/effectlib/funcdiffuseReflectionBSDF.glsllib
index bda0ea6..05f54a6 100644
--- a/res/effectlib/funcdiffuseReflectionBSDF.glsllib
+++ b/res/effectlib/funcdiffuseReflectionBSDF.glsllib
@@ -3,41 +3,8 @@
#define PI_SQUARE ( PI * PI )
#endif
-vec4 diffuseReflectionBSDF(in vec3 N, in vec3 L, in vec3 viewDir,
- in vec3 lightDiffuse, in float roughness)
+vec4 diffuseReflectionBSDF(in vec3 N, in vec3 L, in vec3 lightDiffuse)
{
- float cosThetaI = max( 0.0, dot( N, L ) );
- float factor = cosThetaI;
- if ( ( 0.0 < factor ) && ( 0.0 < roughness ) )
- {
- // see http://en.wikipedia.org/wiki/Oren%E2%80%93Nayar_reflectance_model
- float sigmaSquare = 0.25 * PI_SQUARE * roughness * roughness;
- float A = 1.0 - 0.5 * sigmaSquare / ( sigmaSquare + 0.33 );
- float B = 0.45 * sigmaSquare / ( sigmaSquare + 0.09 );
-
- // project L and viewDir on surface to get the azimuthal angle between them
- // as we don't really need the projections, but the angle between them,
- // it's enough to just use the cross instead
- vec3 pl = normalize( cross( L, N ) );
- vec3 pv = normalize( cross( viewDir, N ) );
- float cosPhi = max( 0.0, dot( pl, pv ) );
-
- float sinAlpha, tanBeta;
- float cosThetaO = max( 0.0, dot( N, viewDir ) );
- float sinThetaI = sqrt( max( 0.0, 1.0 - cosThetaI * cosThetaI ) );
- float sinThetaO = sqrt( max( 0.0, 1.0 - cosThetaO * cosThetaO ) );
- if ( cosThetaI < cosThetaO )
- { // -> thetaO < thetaI
- sinAlpha = sinThetaI;
- tanBeta = sinThetaO / cosThetaO;
- }
- else
- {
- sinAlpha = sinThetaO;
- tanBeta = sinThetaI / cosThetaI;
- }
-
- factor *= A + B * cosPhi * sinAlpha * tanBeta;
- }
- return( vec4( factor * lightDiffuse, 1.0 ) );
+ float factor = max(0.0, dot(N, L));
+ return vec4(factor * lightDiffuse, 1.0);
}
diff --git a/res/effectlib/funcsampleAreaGlossyDefault.glsllib b/res/effectlib/funcsampleAreaGlossyDefault.glsllib
index cb9cba1..586c693 100644
--- a/res/effectlib/funcsampleAreaGlossyDefault.glsllib
+++ b/res/effectlib/funcsampleAreaGlossyDefault.glsllib
@@ -1,25 +1,26 @@
#include "funccomputeMicroHit.glsllib"
-vec3 sampleAreaGlossyDefault( in mat3 tanFrame, in vec3 pos, in mat3 lightFrame, in vec3 lightPos, in float width, in float height, in vec3 viewDir, in float roughU, in float roughV )
+vec3 sampleAreaGlossyDefault(in mat3 tanFrame, in vec3 pos, in mat3 lightFrame, in vec3 lightPos,
+ in float width, in float height, in vec3 viewDir, in float roughness)
{
- float sigmaU = clamp( 0.5 * roughU, 0.005, 0.5 );
- float sigmaV = clamp( 0.5 * roughV, 0.005, 0.5 );
+ float sigma = clamp(0.5 * roughness, 0.005, 0.5);
vec2 UVset[5];
- float thetaI = acos( dot(viewDir, lightFrame[2]) );
- vec2 minMaxThetaH = vec2( (thetaI - 1.5707) * 0.5,
- (thetaI + 1.5707) * 0.5 );
- vec4 sinCosThetaH = vec4( abs(sin(minMaxThetaH)), abs(cos(minMaxThetaH)) );
+ float thetaI = acos(dot(viewDir, lightFrame[2]));
+ vec2 minMaxThetaH = vec2((thetaI - 1.5707) * 0.5, (thetaI + 1.5707) * 0.5 );
+ vec4 sinCosThetaH = vec4(abs(sin(minMaxThetaH)), abs(cos(minMaxThetaH)));
// First thing we do is compute a small-scale version of the ray hit for a very tiny roughness
// then we scale that up based on the _actual_ roughness.
- float wt = computeMicroHit( pos, tanFrame, lightPos, lightFrame, width, height, viewDir, UVset );
+ float wt = computeMicroHit(pos, tanFrame, lightPos, lightFrame, width, height, viewDir, UVset);
UVset[0] -= UVset[4]; UVset[1] -= UVset[4];
UVset[2] -= UVset[4]; UVset[3] -= UVset[4];
- UVset[0] *= mix(1.0, sinCosThetaH.y / 0.005, sigmaU); UVset[1] *= mix(1.0, sinCosThetaH.x / 0.005, sigmaU);
- UVset[2] *= mix(1.0, sinCosThetaH.y / 0.005, sigmaV); UVset[3] *= mix(1.0, sinCosThetaH.x / 0.005, sigmaV);
+ UVset[0] *= mix(1.0, sinCosThetaH.y / 0.005, sigma);
+ UVset[1] *= mix(1.0, sinCosThetaH.x / 0.005, sigma);
+ UVset[2] *= mix(1.0, sinCosThetaH.y / 0.005, sigma);
+ UVset[3] *= mix(1.0, sinCosThetaH.x / 0.005, sigma);
UVset[0] += UVset[4]; UVset[1] += UVset[4];
UVset[2] += UVset[4]; UVset[3] += UVset[4];
@@ -31,12 +32,12 @@ vec3 sampleAreaGlossyDefault( in mat3 tanFrame, in vec3 pos, in mat3 lightFrame,
UVmin = min(UVmin, UVset[2]); UVmax = max(UVmax, UVset[2]);
UVmin = min(UVmin, UVset[3]); UVmax = max(UVmax, UVset[3]);
- cminUV = clamp( UVmin, vec2(0.0), vec2(1.0) );
- cmaxUV = clamp( UVmax, vec2(0.0), vec2(1.0) );
+ cminUV = clamp(UVmin, vec2(0.0), vec2(1.0));
+ cmaxUV = clamp(UVmax, vec2(0.0), vec2(1.0));
vec2 hitScale = (cmaxUV - cminUV);
vec2 fullScale = (UVmax - UVmin);
- float intensity = ( hitScale.x * hitScale.y ) / max( fullScale.x * fullScale.y, 0.0001 );
+ float intensity = (hitScale.x * hitScale.y) / max(fullScale.x * fullScale.y, 0.0001);
- return vec3( wt * intensity );
+ return vec3(wt * intensity);
}
diff --git a/res/effectlib/funcsampleNormalTexture.glsllib b/res/effectlib/funcsampleNormalTexture.glsllib
new file mode 100644
index 0000000..552112a
--- /dev/null
+++ b/res/effectlib/funcsampleNormalTexture.glsllib
@@ -0,0 +1,6 @@
+vec3 sampleNormalTexture(in sampler2D sampler, in float factor, in vec2 texCoord, in vec3 tangent,
+ in vec3 binormal, in vec3 normal)
+{
+ vec3 tsNormal = 2.0 * texture(sampler, texCoord).xyz - 1.0;
+ return mix(normal, normalize(tsNormal.x * tangent - tsNormal.y * binormal + tsNormal.z * normal), factor);
+}
diff --git a/res/effectlib/funcspecularBSDF.glsllib b/res/effectlib/funcspecularBSDF.glsllib
index e9450bf..f774b0b 100644
--- a/res/effectlib/funcspecularBSDF.glsllib
+++ b/res/effectlib/funcspecularBSDF.glsllib
@@ -6,37 +6,15 @@
#define scatter_reflect_transmit 2
#endif
-vec4 specularBSDF(in vec3 N, in vec3 L, in vec3 viewDir, in vec3 lightSpecular,
- in float ior, in float shininess, in vec3 tint, int mode)
+vec4 specularBSDF(in vec3 N, in vec3 L, in vec3 viewDir, in vec3 lightSpecular, in float shininess)
{
- vec4 rgba = vec4( 0.0, 0.0, 0.0, 1.0 );
- float cosTheta = dot( N, L );
- if ( 0.0 < cosTheta )
- {
- if ( ( mode == scatter_reflect ) || ( mode == scatter_reflect_transmit ) )
- {
- vec3 R = reflect( -L, N );
- float cosAlpha = max( 0.0, dot( R, viewDir ) );
- float shine = pow( cosAlpha, shininess );
- rgba.rgb = shine * lightSpecular;
- }
+ vec4 rgba = vec4(0.0, 0.0, 0.0, 1.0);
+ float cosTheta = dot(N, L);
+ if (0.0 < cosTheta) {
+ vec3 R = reflect(-L, N);
+ float cosAlpha = max(0.0, dot(R, viewDir));
+ float shine = pow(cosAlpha, shininess);
+ rgba.rgb = shine * lightSpecular;
}
- if ( ( mode == scatter_transmit ) || ( mode == scatter_reflect_transmit ) )
- {
- // check against total reflection
- vec3 R = refract( -viewDir, N, ior );
- if ( R == vec3( 0.0, 0.0, 0.0 ) )
- {
- rgba.a = 1.0;
- }
- else if ( mode == scatter_transmit )
- {
- rgba.a = 0.0;
- }
- else
- {
- rgba.a = 1.0 - luminance( tint );
- }
- }
- return( rgba );
+ return rgba;
}
diff --git a/res/effectlib/gles2/sampleProbe.glsllib b/res/effectlib/gles2/sampleProbe.glsllib
deleted file mode 100644
index fb202e5..0000000
--- a/res/effectlib/gles2/sampleProbe.glsllib
+++ /dev/null
@@ -1,324 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt 3D Studio.
-**
-** $QT_BEGIN_LICENSE:GPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 or (at your option) any later version
-** approved by the KDE Free Qt Foundation. The licenses are as published by
-** the Free Software Foundation and appearing in the file LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SAMPLE_PROBE_GLSLLIB
-#define SAMPLE_PROBE_GLSLLIB 1
-
-#ifndef QT3DS_ENABLE_LIGHT_PROBE_2
-#define QT3DS_ENABLE_LIGHT_PROBE_2 0
-#endif
-
-#ifndef QT3DS_ENABLE_IBL_FOV
-#define QT3DS_ENABLE_IBL_FOV 0
-#endif
-
-#define USE_RGBE
-
-uniform sampler2D light_probe;
-uniform vec4 light_probe_props;
-uniform vec4 light_probe_rotation;
-uniform vec4 light_probe_offset; // light_probe_offset.w = number of mipmaps
-uniform vec2 light_probe_size;
-
-#if QT3DS_ENABLE_LIGHT_PROBE_2
-uniform sampler2D light_probe2;
-uniform vec4 light_probe2_props;
-uniform vec2 light_probe2_size;
-#endif
-
-#if QT3DS_ENABLE_IBL_FOV
-uniform vec4 light_probe_opts;
-#endif
-
-float noise1d(vec2 n)
-{
- return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
-}
-
-mat3 orthoNormalize( in mat3 tanFrame )
-{
- mat3 outMat;
- outMat[0] = normalize( cross( tanFrame[1], tanFrame[2] ) );
- outMat[1] = normalize( cross( tanFrame[2], outMat[0] ) );
- outMat[2] = tanFrame[2];
-
- return outMat;
-}
-
-mat3 tangentFrame( vec3 N, vec3 p )
-{
- // get edge vectors of the pixel triangle
- vec3 dp1 = dFdx( p );
- vec3 dp2 = dFdy( p );
- // solve the linear system
- vec3 dp2perp = cross( dp2, N );
- vec3 dp1perp = cross( N, dp1 );
- vec3 T = normalize(dp1perp);
- vec3 B = normalize(dp2perp);
- return mat3( T , B , N );
-}
-
-vec2 transformSample( vec2 origUV, vec4 probeRot, vec2 probeOfs )
-{
- vec2 retUV;
- retUV.x = dot( vec3(origUV, 1.0), vec3(probeRot.xy, probeOfs.x) );
- retUV.y = dot( vec3(origUV, 1.0), vec3(probeRot.zw, probeOfs.y) );
- return retUV;
-}
-
-vec3 textureProbe(sampler2D lightProbe, vec2 coord, float lod)
-{
-#ifdef USE_RGBE
- vec4 ret = textureLod(lightProbe, coord, lod);
- return ret.rgb * pow(2.0, ret.a * 255.0 - 128.0);
-#else
- return textureLod(lightProbe, coord, lod).rgb;
-#endif
-}
-
-// This is broken out into its own routine so that if we get some other
-// format image than a lat-long, then we can account for that by changing
-// the code here alone.
-vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
-{
- vec2 smpUV;
-
-#if QT3DS_ENABLE_IBL_FOV
- smpUV.x = (2.0 * atan(-smpDir.z, smpDir.x) + 3.14159265358 ) / light_probe_opts.x;
- smpUV.y = (2.0 * atan(-smpDir.z, smpDir.y) + 3.14159265358 ) / light_probe_opts.x;
-#else
- smpUV.x = atan( smpDir.x, -smpDir.z) / 3.14159265359;
- smpUV.y = 1.0 - (acos(smpDir.y) / 1.57079632679);
-#endif
- smpUV = transformSample( smpUV.xy * 0.5, probeRot, probeOfs ) + vec2(0.5, 0.5);
-
- return smpUV;
-}
-
-vec4 getTopLayerSample( vec3 inDir, float lodShift, vec3 lodOffsets )
-{
-#if QT3DS_ENABLE_LIGHT_PROBE_2
- if ( light_probe2_props.w < 0.5 )
- return vec4(0.0, 0.0, 0.0, 0.0);
-
- vec2 smpUV = getProbeSampleUV( inDir, vec4(1.0, 0.0, 0.0, 1.0), light_probe_props.xy );
- smpUV.x -= 0.5;
- smpUV.x *= light_probe2_props.x;
- smpUV.x += light_probe2_props.y;
-
- vec4 retVal = 0.4 * textureLod( light_probe2, smpUV , lodShift );
- retVal += 0.2 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.x );
- retVal += 0.3 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.y );
- retVal += 0.1 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.z );
- return retVal;
-#else
- return vec4(0.0, 0.0, 0.0, 0.0);
-#endif
-}
-
-vec3 getProbeSample( vec3 smpDir, float lodShift, vec3 normal )
-{
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
- return textureProbe( light_probe, smpUV , lodShift );
-}
-
-vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3 normal )
-{
- // This gives us a weighted sum that approximates the total filter support
- // of the full-blown convolution.
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
- float wt = 1.0;
-
-#if QT3DS_ENABLE_IBL_FOV
- wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.x));
- wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.y));
- wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.x));
- wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.y));
-#endif
-
- vec3 lodOffsets;
- lodOffsets.x = mix(-2.0, -0.70710678, roughness);
- lodOffsets.y = min( 2.0 * smoothstep(0.0, 0.1, roughness), 2.0 - 1.29289 * smoothstep(0.1, 1.0, roughness) );
- lodOffsets.z = min( 6.0 * smoothstep(0.0, 0.1, roughness), 6.0 - 4.585786 * smoothstep(0.1, 1.0, roughness) );
-
- ivec2 iSize = ivec2(light_probe_size);
- vec3 ddx = dFdx( smpDir ) * float(iSize.x);
- vec3 ddy = dFdy( smpDir ) * float(iSize.y);
-// vec2 ddxUV = dFdx( smpUV ) * float(iSize.x);
-// vec2 ddyUV = dFdy( smpUV ) * float(iSize.y);
-
- vec2 deriv;
- deriv.x = max( dot(ddx, ddx), dot(ddy, ddy) );
-// deriv.y = max( dot(ddxUV, ddxUV), dot(ddyUV, ddyUV) );
- deriv = clamp( deriv, vec2(1.0), vec2(iSize.x * iSize.y) );
- vec2 lodBound = 0.5 * log2( deriv ) - vec2(1.0);
-
-// float minLod = 0.5 * (lodBound.x + lodBound.y);
- float minLod = lodBound.x;
- float maxLod = log2( max(float(iSize.x), float(iSize.y)) );
- minLod = clamp( minLod / maxLod, 0.0, 1.0 );
- minLod *= minLod * maxLod;
-
- lodShift = max( lodShift, minLod );
-
- vec3 retVal = 0.4 * textureProbe( light_probe, smpUV , lodShift );
- retVal += 0.2 * textureProbe( light_probe, smpUV , max(minLod, lodShift+lodOffsets.x) );
- retVal += 0.3 * textureProbe( light_probe, smpUV , lodShift+lodOffsets.y );
- retVal += 0.1 * textureProbe( light_probe, smpUV , lodShift+lodOffsets.z );
-
-#if QT3DS_ENABLE_LIGHT_PROBE_2
- vec4 topSmp = getTopLayerSample( smpDir, lodShift, lodOffsets );
- vec3 tempVal = mix( retVal, topSmp.xyz, topSmp.w );
- retVal = mix( retVal, tempVal, light_probe2_props.z );
-#endif
-
- if (light_probe_props.z > -1.0) {
- float ctr = 0.5 + 0.5 * light_probe_props.z;
- float vertWt = smoothstep(ctr-roughness*0.25, ctr+roughness*0.25, smpUV.y);
- float wtScaled = mix(1.0, vertWt, light_probe_props.z + 1.0);
- retVal *= wtScaled;
- }
-
- return retVal * wt;
-}
-
-vec2 textureSizeLod( vec2 size, int level )
-{
- return size / pow(2.0, float(level));
-}
-
-vec3 getProbeAnisoSample( vec3 smpDir, float roughU, float roughV, mat3 tanFrame )
-{
- float minRough = min(roughU, roughV);
- float maxRough = max(roughU, roughV);
-
- float lodMin = log2( (minRough*3.0 + maxRough)*0.25 ) + (light_probe_offset.w - 2.0);
-
- float ratio = clamp( maxRough / minRough, 1.01, 27.0);
- vec2 texSize = textureSizeLod( light_probe_size, int(floor( lodMin )) );
- texSize = mix( texSize, texSize * 0.5, fract(lodMin) );
-
- // Boundary of 1.0..9.0 is just to keep the number of samples to within a
- // reasonable number of samples in the filter. Similarly, with the clamping
- // of the ratio to a max of 27.0 is just to prevent the step size in the filter
- // to be no bigger than 3 texels (beyond which, there are some artifacts at high
- // roughness, aka low texture res).
- float stepFig = clamp(floor( ratio ), 1.0, 9.0);
-
- // numSteps is half the number of samples we need to take, which makes it
- // the number of steps to take on each side.
- int numSteps = int( floor(stepFig * 0.5) );
-
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
- vec4 result = vec4(0.0);
-
- vec3 smpDirOfs = (maxRough == roughU) ? 0.01 * tanFrame[0] : 0.01 * tanFrame[1];
- vec2 stepPos = getProbeSampleUV(normalize(smpDir + smpDirOfs), light_probe_rotation, light_probe_offset.xy);
- vec2 stepNeg = getProbeSampleUV(normalize(smpDir - smpDirOfs), light_probe_rotation, light_probe_offset.xy);
- stepPos -= smpUV; stepNeg -= smpUV;
- stepPos *= texSize; stepNeg *= texSize;
-
- // This ensures that we step along a size that makes sense even if one of the two
- // sammpling directions wraps around the edges of the IBL texture.
- smpDirOfs /= min( length(stepPos), length(stepNeg) );
- smpDirOfs *= ratio / stepFig;
-
- float sigma = mix(0.0, 2.0, ratio / 27.0);
- sigma *= sigma;
-
- float wt = (1.0 / (ratio - 1.0)) + 1.0;
- result.xyz += wt * getProbeWeightedSample( smpDir, lodMin, minRough, tanFrame[2] );
- result.w += wt;
- for (int i = 0; i < numSteps; ++i)
- {
- wt = sigma / (sigma + float(i * i));
- vec2 uv0 = getProbeSampleUV(normalize(smpDir + smpDirOfs * float(i)), light_probe_rotation, light_probe_offset.xy);
- vec2 uv1 = getProbeSampleUV(normalize(smpDir - smpDirOfs * float(i)), light_probe_rotation, light_probe_offset.xy);
- result.xyz += wt * textureProbe( light_probe, uv0 , lodMin );
- result.w += wt;
- result.xyz += wt * textureProbe( light_probe, uv1 , lodMin );
- result.w += wt;
- }
-
- result /= result.w;
- return result.xyz;
-}
-
-vec4 sampleDiffuse( mat3 tanFrame )
-{
- if ( light_probe_props.w < 0.005 )
- return vec4( 0.0 );
-
- return vec4( light_probe_props.w * getProbeWeightedSample( tanFrame[2], light_probe_offset.w - 2.65149613, 1.0, tanFrame[2] ), 1.0 );
-}
-
-vec4 sampleDiffuseCustomMaterial( vec3 normal, vec3 worldPos, float aoFactor )
-{
-
- mat3 tanFrame = tangentFrame( normal, worldPos );
- return sampleDiffuse( tanFrame );
-}
-
-vec4 sampleGlossyAniso( mat3 tanFrame, vec3 viewDir, float roughU, float roughV )
-{
- if ( light_probe_props.w < 0.005 )
- return vec4( 0.0 );
-
- float sigmaU = smoothstep( 0.0, 1.0, clamp(roughU, 0.0001, 1.0) );
- float sigmaV = smoothstep( 0.0, 1.0, clamp(roughV, 0.0001, 1.0) );
- vec3 ret = vec3(0, 0, 0);
-
- vec3 smpDir = reflect( -viewDir, tanFrame[2] );
- float sigma = sqrt(sigmaU * sigmaV);
-
- // Compute the Geometric occlusion/self-shadowing term
- float NdotL = clamp( dot( smpDir, tanFrame[2] ), 0.0, 0.999995);
- float k = sigma * 0.31830988618; // roughness / pi
- float Gl = clamp( (NdotL / (NdotL*(1.0-k) + k) + (1.0 - k*k)) * 0.5, 0.0, 1.0 );
-
- vec3 outColor;
-
- outColor = getProbeAnisoSample( smpDir, sigmaU, sigmaV, tanFrame );
-
- return vec4( light_probe_props.w * Gl * outColor, 1.0 );
-}
-
-vec4 sampleGlossy( mat3 tanFrame, vec3 viewDir, float roughness )
-{
- return sampleGlossyAniso( tanFrame, viewDir, roughness, roughness );
-}
-
-vec4 sampleGlossyCustomMaterial( vec3 normal, vec3 worldPos, vec3 viewDir, float roughness )
-{
- mat3 tanFrame = tangentFrame( normal, worldPos );
- return sampleGlossy( tanFrame, viewDir, roughness );
-}
-
-#endif
diff --git a/res/effectlib/gles2/sampleProbePre.glsllib b/res/effectlib/gles2/sampleProbePre.glsllib
new file mode 100644
index 0000000..6127566
--- /dev/null
+++ b/res/effectlib/gles2/sampleProbePre.glsllib
@@ -0,0 +1,7 @@
+
+uniform vec4 light_probe_size;
+
+ivec2 lightProbeSize(sampler2D lightProbe, int lodLevel)
+{
+ return ivec2(light_probe_size / pow(2.0, float(lodLevel)));
+}
diff --git a/res/effectlib/luminance.glsllib b/res/effectlib/luminance.glsllib
index 067dc18..e4ce386 100644
--- a/res/effectlib/luminance.glsllib
+++ b/res/effectlib/luminance.glsllib
@@ -32,31 +32,11 @@
#define LUMINANCE_GLSLLIB
// Luma coefficients according to ITU-R Recommendation BT.709 (http://en.wikipedia.org/wiki/Rec._709)
-const vec3 yCoeff_709 = vec3( 0.2126, 0.7152, 0.0722 );
+const vec3 yCoeff_709 = vec3(0.2126, 0.7152, 0.0722);
-float luminance( in vec3 v )
+float luminance(in vec3 v)
{
- return dot( v, yCoeff_709 );
+ return dot(v, yCoeff_709);
}
-vec3 RGBToYPbPr( in vec3 v )
-{
- vec3 ypp;
- ypp.x = luminance( v );
- ypp.y = 0.5 * (v.b - ypp.x) / (1.0 - yCoeff_709.b);
- ypp.z = 0.5 * (v.r - ypp.x) / (1.0 - yCoeff_709.r);
-
- return ypp;
-}
-
-vec3 YPbPrToRGB( in vec3 v )
-{
- vec3 outRGB;
- outRGB.x = dot(vec3(1.0, 0.0, 1.575), v);
- outRGB.y = dot(vec3(1.0, -0.187, -0.468), v);
- outRGB.z = dot(vec3(1.0, 1.856, 0.0), v);
-
- return outRGB;
-}
-
-#endif \ No newline at end of file
+#endif
diff --git a/res/effectlib/sampleProbe.glsllib b/res/effectlib/sampleProbe.glsllib
index 361aad5..4846ee3 100644
--- a/res/effectlib/sampleProbe.glsllib
+++ b/res/effectlib/sampleProbe.glsllib
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2014 NVIDIA Corporation.
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
@@ -31,6 +31,8 @@
#ifndef SAMPLE_PROBE_GLSLLIB
#define SAMPLE_PROBE_GLSLLIB 1
+#include "sampleProbePre.glsllib"
+
#define USE_RGBE
uniform sampler2D light_probe;
@@ -49,37 +51,37 @@ uniform vec4 light_probe_opts;
float noise1d(vec2 n)
{
- return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);
+ return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233))) * 43758.5453);
}
-mat3 orthoNormalize( in mat3 tanFrame )
+mat3 orthoNormalize(in mat3 tanFrame)
{
mat3 outMat;
- outMat[0] = normalize( cross( tanFrame[1], tanFrame[2] ) );
- outMat[1] = normalize( cross( tanFrame[2], outMat[0] ) );
+ outMat[0] = normalize(cross(tanFrame[1], tanFrame[2]));
+ outMat[1] = normalize(cross(tanFrame[2], outMat[0]));
outMat[2] = tanFrame[2];
return outMat;
}
-mat3 tangentFrame( vec3 N, vec3 p )
+mat3 tangentFrame(vec3 N, vec3 p)
{
// get edge vectors of the pixel triangle
- vec3 dp1 = dFdx( p );
- vec3 dp2 = dFdy( p );
+ vec3 dp1 = dFdx(p);
+ vec3 dp2 = dFdy(p);
// solve the linear system
- vec3 dp2perp = cross( dp2, N );
- vec3 dp1perp = cross( N, dp1 );
+ vec3 dp2perp = cross(dp2, N);
+ vec3 dp1perp = cross(N, dp1);
vec3 T = normalize(dp1perp);
vec3 B = normalize(dp2perp);
- return mat3( T , B , N );
+ return mat3(T, B, N);
}
-vec2 transformSample( vec2 origUV, vec4 probeRot, vec2 probeOfs )
+vec2 transformSample(vec2 origUV, vec4 probeRot, vec2 probeOfs)
{
vec2 retUV;
- retUV.x = dot( vec3(origUV, 1.0), vec3(probeRot.xy, probeOfs.x) );
- retUV.y = dot( vec3(origUV, 1.0), vec3(probeRot.zw, probeOfs.y) );
+ retUV.x = dot(vec3(origUV, 1.0), vec3(probeRot.xy, probeOfs.x));
+ retUV.y = dot(vec3(origUV, 1.0), vec3(probeRot.zw, probeOfs.y));
return retUV;
}
@@ -96,7 +98,7 @@ vec3 textureProbe(sampler2D lightProbe, vec2 coord, float lod)
// This is broken out into its own routine so that if we get some other
// format image than a lat-long, then we can account for that by changing
// the code here alone.
-vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
+vec2 getProbeSampleUV(vec3 smpDir, vec4 probeRot, vec2 probeOfs)
{
vec2 smpUV;
@@ -118,86 +120,83 @@ vec2 getProbeSampleUV( vec3 smpDir, vec4 probeRot, vec2 probeOfs )
return smpUV;
}
-vec4 getTopLayerSample( vec3 inDir, float lodShift, vec3 lodOffsets )
+vec4 getTopLayerSample(vec3 inDir, float lodShift, vec3 lodOffsets)
{
#if QT3DS_ENABLE_LIGHT_PROBE_2
- if ( light_probe2_props.w < 0.5 )
+ if (light_probe2_props.w < 0.5)
return vec4(0.0, 0.0, 0.0, 0.0);
- vec2 smpUV = getProbeSampleUV( inDir, vec4(1.0, 0.0, 0.0, 1.0), light_probe_props.xy );
+ vec2 smpUV = getProbeSampleUV(inDir, vec4(1.0, 0.0, 0.0, 1.0), light_probe_props.xy);
smpUV.x -= 0.5;
smpUV.x *= light_probe2_props.x;
smpUV.x += light_probe2_props.y;
- vec4 retVal = 0.4 * textureLod( light_probe2, smpUV , lodShift );
- retVal += 0.2 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.x );
- retVal += 0.3 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.y );
- retVal += 0.1 * textureLod( light_probe2, smpUV , lodShift+lodOffsets.z );
+ vec4 retVal = 0.4 * textureLod(light_probe2, smpUV , lodShift);
+ retVal += 0.2 * textureLod(light_probe2, smpUV, lodShift+lodOffsets.x);
+ retVal += 0.3 * textureLod(light_probe2, smpUV, lodShift+lodOffsets.y);
+ retVal += 0.1 * textureLod(light_probe2, smpUV, lodShift+lodOffsets.z);
return retVal;
#else
return vec4(0.0, 0.0, 0.0, 0.0);
#endif
}
-vec3 getProbeSample( vec3 smpDir, float lodShift, vec3 normal )
+vec3 getProbeSample(vec3 smpDir, float lodShift, vec3 normal)
{
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
- return textureProbe( light_probe, smpUV , lodShift );
+ vec2 smpUV = getProbeSampleUV(smpDir, light_probe_rotation, light_probe_offset.xy);
+ return textureProbe(light_probe, smpUV , lodShift);
}
-vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3 normal )
+vec3 getProbeWeightedSample(vec3 smpDir, float lodShift, float roughness, vec3 normal)
{
// This gives us a weighted sum that approximates the total filter support
// of the full-blown convolution.
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
+ vec2 smpUV = getProbeSampleUV(smpDir, light_probe_rotation, light_probe_offset.xy);
float wt = 1.0;
#if QT3DS_ENABLE_IBL_FOV
wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.x));
wt = min(wt, smoothstep(roughness * -0.25, roughness * 0.25, smpUV.y));
- wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.x));
- wt = min(wt, 1.0 - smoothstep(1.0 - roughness*0.25, 1.0 + roughness*0.25, smpUV.y));
+ wt = min(wt, 1.0 - smoothstep(1.0 - roughness * 0.25, 1.0 + roughness * 0.25, smpUV.x));
+ wt = min(wt, 1.0 - smoothstep(1.0 - roughness * 0.25, 1.0 + roughness * 0.25, smpUV.y));
#endif
vec3 lodOffsets;
lodOffsets.x = mix(-2.0, -0.70710678, roughness);
- lodOffsets.y = min( 2.0 * smoothstep(0.0, 0.1, roughness), 2.0 - 1.29289 * smoothstep(0.1, 1.0, roughness) );
- lodOffsets.z = min( 6.0 * smoothstep(0.0, 0.1, roughness), 6.0 - 4.585786 * smoothstep(0.1, 1.0, roughness) );
+ lodOffsets.y = min(2.0 * smoothstep(0.0, 0.1, roughness), 2.0 - 1.29289 * smoothstep(0.1, 1.0, roughness));
+ lodOffsets.z = min(6.0 * smoothstep(0.0, 0.1, roughness), 6.0 - 4.585786 * smoothstep(0.1, 1.0, roughness));
- ivec2 iSize = textureSize(light_probe, 0);
- vec3 ddx = dFdx( smpDir ) * float(iSize.x);
- vec3 ddy = dFdy( smpDir ) * float(iSize.y);
-// vec2 ddxUV = dFdx( smpUV ) * float(iSize.x);
-// vec2 ddyUV = dFdy( smpUV ) * float(iSize.y);
+ ivec2 iSize = lightProbeSize(light_probe, 0);
+ vec3 ddx = dFdx(smpDir) * float(iSize.x);
+ vec3 ddy = dFdy(smpDir) * float(iSize.y);
vec2 deriv;
- deriv.x = max( dot(ddx, ddx), dot(ddy, ddy) );
-// deriv.y = max( dot(ddxUV, ddxUV), dot(ddyUV, ddyUV) );
- deriv = clamp( deriv, vec2(1.0), vec2(iSize.x * iSize.y) );
- vec2 lodBound = 0.5 * log2( deriv ) - vec2(1.0);
+ deriv.x = max(dot(ddx, ddx), dot(ddy, ddy));
+
+ deriv = clamp(deriv, vec2(1.0), vec2(iSize.x * iSize.y));
+ vec2 lodBound = 0.5 * log2(deriv) - vec2(1.0);
-// float minLod = 0.5 * (lodBound.x + lodBound.y);
float minLod = lodBound.x;
- float maxLod = log2( max(float(iSize.x), float(iSize.y)) );
- minLod = clamp( minLod / maxLod, 0.0, 1.0 );
+ float maxLod = log2(max(float(iSize.x), float(iSize.y)));
+ minLod = clamp(minLod / maxLod, 0.0, 1.0);
minLod *= minLod * maxLod;
- lodShift = max( lodShift, minLod );
+ lodShift = max(lodShift, minLod);
- vec3 retVal = 0.4 * textureProbe( light_probe, smpUV , lodShift );
- retVal += 0.2 * textureProbe( light_probe, smpUV , max(minLod, lodShift+lodOffsets.x) );
- retVal += 0.3 * textureProbe( light_probe, smpUV , lodShift+lodOffsets.y );
- retVal += 0.1 * textureProbe( light_probe, smpUV , lodShift+lodOffsets.z );
+ vec3 retVal = 0.4 * textureProbe(light_probe, smpUV , lodShift);
+ retVal += 0.2 * textureProbe(light_probe, smpUV , max(minLod, lodShift+lodOffsets.x));
+ retVal += 0.3 * textureProbe(light_probe, smpUV , lodShift+lodOffsets.y);
+ retVal += 0.1 * textureProbe(light_probe, smpUV , lodShift+lodOffsets.z);
#if QT3DS_ENABLE_LIGHT_PROBE_2
- vec4 topSmp = getTopLayerSample( smpDir, lodShift, lodOffsets );
- vec3 tempVal = mix( retVal, topSmp.xyz, topSmp.w );
- retVal = mix( retVal, tempVal, light_probe2_props.z );
+ vec4 topSmp = getTopLayerSample(smpDir, lodShift, lodOffsets);
+ vec3 tempVal = mix(retVal, topSmp.xyz, topSmp.w);
+ retVal = mix(retVal, tempVal, light_probe2_props.z);
#endif
if (light_probe_props.z > -1.0) {
float ctr = 0.5 + 0.5 * light_probe_props.z;
- float vertWt = smoothstep(ctr-roughness*0.25, ctr+roughness*0.25, smpUV.y);
+ float vertWt = smoothstep(ctr-roughness * 0.25, ctr+roughness * 0.25, smpUV.y);
float wtScaled = mix(1.0, vertWt, light_probe_props.z + 1.0);
retVal *= wtScaled;
}
@@ -205,111 +204,40 @@ vec3 getProbeWeightedSample( vec3 smpDir, float lodShift, float roughness, vec3
return retVal * wt;
}
-vec3 getProbeAnisoSample( vec3 smpDir, float roughU, float roughV, mat3 tanFrame )
-{
- float minRough = min(roughU, roughV);
- float maxRough = max(roughU, roughV);
-
- float lodMin = log2( (minRough*3.0 + maxRough)*0.25 ) + (light_probe_offset.w - 2.0);
-
- float ratio = clamp( maxRough / minRough, 1.01, 27.0);
- vec2 texSize = vec2( textureSize( light_probe, int(floor( lodMin )) ) );
- texSize = mix( texSize, texSize * 0.5, fract(lodMin) );
-
- // Boundary of 1.0..9.0 is just to keep the number of samples to within a
- // reasonable number of samples in the filter. Similarly, with the clamping
- // of the ratio to a max of 27.0 is just to prevent the step size in the filter
- // to be no bigger than 3 texels (beyond which, there are some artifacts at high
- // roughness, aka low texture res).
- float stepFig = clamp(floor( ratio ), 1.0, 9.0);
-
- // numSteps is half the number of samples we need to take, which makes it
- // the number of steps to take on each side.
- int numSteps = int( floor(stepFig * 0.5) );
-
- vec2 smpUV = getProbeSampleUV( smpDir, light_probe_rotation, light_probe_offset.xy );
- vec4 result = vec4(0.0);
-
- vec3 smpDirOfs = (maxRough == roughU) ? 0.01 * tanFrame[0] : 0.01 * tanFrame[1];
- vec2 stepPos = getProbeSampleUV(normalize(smpDir + smpDirOfs), light_probe_rotation, light_probe_offset.xy);
- vec2 stepNeg = getProbeSampleUV(normalize(smpDir - smpDirOfs), light_probe_rotation, light_probe_offset.xy);
- stepPos -= smpUV; stepNeg -= smpUV;
- stepPos *= texSize; stepNeg *= texSize;
-
- // This ensures that we step along a size that makes sense even if one of the two
- // sammpling directions wraps around the edges of the IBL texture.
- smpDirOfs /= min( length(stepPos), length(stepNeg) );
- smpDirOfs *= ratio / stepFig;
-
- float sigma = mix(0.0, 2.0, ratio / 27.0);
- sigma *= sigma;
-
- float wt = (1.0 / (ratio - 1.0)) + 1.0;
- result.xyz += wt * getProbeWeightedSample( smpDir, lodMin, minRough, tanFrame[2] );
- result.w += wt;
- for (int i = 0; i < numSteps; ++i)
- {
- wt = sigma / (sigma + float(i * i));
- vec2 uv0 = getProbeSampleUV(normalize(smpDir + smpDirOfs * float(i)), light_probe_rotation, light_probe_offset.xy);
- vec2 uv1 = getProbeSampleUV(normalize(smpDir - smpDirOfs * float(i)), light_probe_rotation, light_probe_offset.xy);
- result.xyz += wt * textureProbe( light_probe, uv0 , lodMin );
- result.w += wt;
- result.xyz += wt * textureProbe( light_probe, uv1 , lodMin );
- result.w += wt;
- }
-
- result /= result.w;
- return result.xyz;
-}
-
-vec4 sampleDiffuse( mat3 tanFrame )
+vec4 sampleDiffuse(mat3 tanFrame)
{
- if ( light_probe_props.w < 0.005 )
- return vec4( 0.0 );
+ if (light_probe_props.w < 0.005)
+ return vec4(0.0);
- return vec4( light_probe_props.w * getProbeWeightedSample( tanFrame[2], light_probe_offset.w - 2.65149613, 1.0, tanFrame[2] ), 1.0 );
+ return vec4(light_probe_props.w * getProbeWeightedSample(tanFrame[2], light_probe_offset.w - 2.65149613, 1.0, tanFrame[2]), 1.0 );
}
-vec4 sampleDiffuseCustomMaterial( vec3 normal, vec3 worldPos, float aoFactor )
+vec4 sampleDiffuseCustomMaterial(vec3 normal, vec3 worldPos, float aoFactor)
{
-
- mat3 tanFrame = tangentFrame( normal, worldPos );
- return sampleDiffuse( tanFrame );
+ mat3 tanFrame = tangentFrame(normal, worldPos);
+ return sampleDiffuse(tanFrame);
}
-vec4 sampleGlossyAniso( mat3 tanFrame, vec3 viewDir, float roughU, float roughV )
+vec4 sampleGlossy(mat3 tanFrame, vec3 viewDir, float roughness)
{
- if ( light_probe_props.w < 0.005 )
- return vec4( 0.0 );
+ if (light_probe_props.w < 0.005)
+ return vec4(0.0);
- float sigmaU = smoothstep( 0.0, 1.0, clamp(roughU, 0.0001, 1.0) );
- float sigmaV = smoothstep( 0.0, 1.0, clamp(roughV, 0.0001, 1.0) );
+ float sigma = smoothstep(0.0, 1.0, clamp(roughness, 0.0001, 1.0));
vec3 ret = vec3(0, 0, 0);
- vec3 smpDir = reflect( -viewDir, tanFrame[2] );
- float sigma = sqrt(sigmaU * sigmaV);
+ vec3 smpDir = reflect(-viewDir, tanFrame[2]);
// Compute the Geometric occlusion/self-shadowing term
- float NdotL = clamp( dot( smpDir, tanFrame[2] ), 0.0, 0.999995);
+ float NdotL = clamp(dot(smpDir, tanFrame[2]), 0.0, 0.999995);
float k = sigma * 0.31830988618; // roughness / pi
- float Gl = clamp( (NdotL / (NdotL*(1.0-k) + k) + (1.0 - k*k)) * 0.5, 0.0, 1.0 );
+ float Gl = clamp((NdotL / (NdotL*(1.0-k) + k) + (1.0 - k*k)) * 0.5, 0.0, 1.0 );
vec3 outColor;
- outColor = getProbeAnisoSample( smpDir, sigmaU, sigmaV, tanFrame );
-
- return vec4( light_probe_props.w * Gl * outColor, 1.0 );
-}
+ outColor = getProbeSample(smpDir, sigma, tanFrame[2]);
-vec4 sampleGlossy( mat3 tanFrame, vec3 viewDir, float roughness )
-{
- return sampleGlossyAniso( tanFrame, viewDir, roughness, roughness );
-}
-
-vec4 sampleGlossyCustomMaterial( vec3 normal, vec3 worldPos, vec3 viewDir, float roughness )
-{
- mat3 tanFrame = tangentFrame( normal, worldPos );
- return sampleGlossy( tanFrame, viewDir, roughness );
+ return vec4(light_probe_props.w * Gl * outColor, 1.0);
}
#endif
diff --git a/res/effectlib/sampleProbePre.glsllib b/res/effectlib/sampleProbePre.glsllib
new file mode 100644
index 0000000..5fd42c9
--- /dev/null
+++ b/res/effectlib/sampleProbePre.glsllib
@@ -0,0 +1,5 @@
+
+ivec2 lightProbeSize(sampler2D lightProbe, int lodLevel)
+{
+ return ivec2(textureSize(lightProbe, lodLevel));
+}
diff --git a/res/effectlib/specularBSDF.glsllib b/res/effectlib/specularBSDF.glsllib
index 78e541a..028e6fb 100644
--- a/res/effectlib/specularBSDF.glsllib
+++ b/res/effectlib/specularBSDF.glsllib
@@ -32,16 +32,16 @@
#ifndef DEFAULT_MATERIAL_LIGHTING
-vec4 specularBSDFEnvironment( in vec3 N, in vec3 viewDir, in vec3 tint, int mode )
+vec4 specularBSDFEnvironment(in vec3 N, in vec3 viewDir, in vec3 tint, int mode)
{
- vec3 rgb = vec3( 0.0, 0.0, 0.0 );
- if ( uEnvironmentMappingEnabled )
- {
- vec3 R = reflect( -viewDir, N );
- rgb = evalEnvironmentMap( R, 0.0 );
- rgb = specularBSDF( N, R, viewDir, rgb, 1.0, 256.0, tint, scatter_reflect ).rgb;
- }
- return( vec4( rgb, 1.0 ) );
+ vec3 rgb = vec3( 0.0, 0.0, 0.0 );
+ if ( uEnvironmentMappingEnabled )
+ {
+ vec3 R = reflect(-viewDir, N);
+ rgb = evalEnvironmentMap(R, 0.0);
+ rgb = specularBSDF(N, R, viewDir, rgb, 256.0).rgb;
+ }
+ return vec4(rgb, 1.0);
}
#endif
diff --git a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
index b9215d6..f510739 100644
--- a/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
+++ b/src/runtimerender/Qt3DSRenderDefaultMaterialShaderGenerator.cpp
@@ -395,7 +395,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
void AddLocalVariable(IShaderStageGenerator &inGenerator, const char8_t *inName,
const char8_t *inType)
{
- inGenerator << "\t" << inType << " " << inName << ";" << Endl;
+ inGenerator << " " << inType << " " << inName << ";" << Endl;
}
void AddLocalVariable(IShaderStageGenerator &inGenerator, const TStrType &inName,
@@ -414,40 +414,41 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
SetupTexCoordVariableName(uvSet);
fragmentShader.AddUniform(m_ImageSampler, "sampler2D");
vertexShader.AddUniform(m_ImageOffsets, "vec3");
- fragmentShader.AddUniform(m_ImageOffsets, "vec3");
vertexShader.AddUniform(m_ImageRotations, "vec4");
- fragmentShader.AddUniform(m_ImageRotations, "vec4");
if (image.m_Image.m_MappingMode == ImageMappingModes::Normal) {
- vertexShader << "\tuTransform = vec3( " << m_ImageRotations << ".x, "
+ vertexShader << " uTransform = vec3( " << m_ImageRotations << ".x, "
<< m_ImageRotations << ".y, " << m_ImageOffsets << ".x );" << Endl;
- vertexShader << "\tvTransform = vec3( " << m_ImageRotations << ".z, "
+ vertexShader << " vTransform = vec3( " << m_ImageRotations << ".z, "
<< m_ImageRotations << ".w, " << m_ImageOffsets << ".y );" << Endl;
vertexShader.AddOutgoing(m_ImageFragCoords, "vec2");
addFunction(vertexShader, "getTransformedUVCoords");
vertexShader.GenerateUVCoords(uvSet);
m_ImageTemp = m_ImageFragCoords;
m_ImageTemp.append("temp");
- vertexShader << "\tvec2 " << m_ImageTemp << " = getTransformedUVCoords( vec3( "
+ vertexShader << " vec2 " << m_ImageTemp << " = getTransformedUVCoords( vec3( "
<< m_TexCoordTemp << ", 1.0), uTransform, vTransform );" << Endl;
- if (image.m_Image.m_TextureData.m_TextureFlags.IsInvertUVCoords())
- vertexShader << "\t" << m_ImageTemp << ".y = 1.0 - " << m_ImageTemp << ".y;"
+ if (image.m_Image.m_TextureData.m_TextureFlags.IsInvertUVCoords()) {
+ vertexShader << " " << m_ImageTemp << ".y = 1.0 - " << m_ImageTemp << ".y;"
<< Endl;
+ }
vertexShader.AssignOutput(m_ImageFragCoords.c_str(), m_ImageTemp.c_str());
} else {
- fragmentShader << "\tuTransform = vec3( " << m_ImageRotations << ".x, "
+ fragmentShader.AddUniform(m_ImageOffsets, "vec3");
+ fragmentShader.AddUniform(m_ImageRotations, "vec4");
+ fragmentShader << " uTransform = vec3( " << m_ImageRotations << ".x, "
<< m_ImageRotations << ".y, " << m_ImageOffsets << ".x );" << Endl;
- fragmentShader << "\tvTransform = vec3( " << m_ImageRotations << ".z, "
+ fragmentShader << " vTransform = vec3( " << m_ImageRotations << ".z, "
<< m_ImageRotations << ".w, " << m_ImageOffsets << ".y );" << Endl;
vertexShader.GenerateEnvMapReflection();
addFunction(fragmentShader, "getTransformedUVCoords");
- fragmentShader << "\tvec2 " << m_ImageFragCoords
+ fragmentShader << " vec2 " << m_ImageFragCoords
<< " = getTransformedUVCoords( environment_map_reflection, uTransform, "
"vTransform );"
<< Endl;
if (image.m_Image.m_TextureData.m_TextureFlags.IsInvertUVCoords())
- fragmentShader << "\t" << m_ImageFragCoords << ".y = 1.0 - " << m_ImageFragCoords
+ fragmentShader << " " << m_ImageFragCoords << ".y = 1.0 - " << m_ImageFragCoords
<< ".y;" << Endl;
}
}
@@ -466,19 +467,19 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
inShader.AddUniform(m_ImageOffsets, "vec3");
inShader.AddUniform(m_ImageRotations, "vec4");
- inShader << "\tuTransform = vec3( " << m_ImageRotations << ".x, " << m_ImageRotations
+ inShader << " uTransform = vec3( " << m_ImageRotations << ".x, " << m_ImageRotations
<< ".y, " << m_ImageOffsets << ".x );" << Endl;
- inShader << "\tvTransform = vec3( " << m_ImageRotations << ".z, " << m_ImageRotations
+ inShader << " vTransform = vec3( " << m_ImageRotations << ".z, " << m_ImageRotations
<< ".w, " << m_ImageOffsets << ".y );" << Endl;
- inShader << "\tvec2 " << m_ImageFragCoords << ";" << Endl;
+ inShader << " vec2 " << m_ImageFragCoords << ";" << Endl;
addFunction(inShader, "getTransformedUVCoords");
inShader.GenerateUVCoords();
inShader
- << "\t" << m_ImageFragCoords
+ << " " << m_ImageFragCoords
<< " = getTransformedUVCoords( vec3( varTexCoord0, 1.0), uTransform, vTransform );"
<< Endl;
if (image.m_Image.m_TextureData.m_TextureFlags.IsInvertUVCoords())
- inShader << "\t" << m_ImageFragCoords << ".y = 1.0 - " << m_ImageFragCoords << ".y;"
+ inShader << " " << m_ImageFragCoords << ".y = 1.0 - " << m_ImageFragCoords << ".y;"
<< Endl;
}
}
@@ -491,7 +492,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
case DefaultMaterialSpecularModel::KGGX: {
fragmentShader.AddInclude("defaultMaterialPhysGlossyBSDF.glsllib");
fragmentShader.AddUniform("material_specular", "vec4");
- fragmentShader << "\tglobal_specular_light.rgb += lightAttenuation * specularAmount * "
+ fragmentShader << " global_specular_light.rgb += lightAttenuation * specularAmount * "
"specularColor * kggxGlossyDefaultMtl( "
<< "world_normal, tangent, -" << inLightDir << ".xyz, view_vector, "
<< inLightSpecColor
@@ -502,7 +503,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
case DefaultMaterialSpecularModel::KWard: {
fragmentShader.AddInclude("defaultMaterialPhysGlossyBSDF.glsllib");
fragmentShader.AddUniform("material_specular", "vec4");
- fragmentShader << "\tglobal_specular_light.rgb += lightAttenuation * specularAmount * "
+ fragmentShader << " global_specular_light.rgb += lightAttenuation * specularAmount * "
"specularColor * wardGlossyDefaultMtl( "
<< "world_normal, tangent, -" << inLightDir << ".xyz, view_vector, "
<< inLightSpecColor
@@ -512,11 +513,11 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
} break;
default:
addFunction(fragmentShader, "specularBSDF");
- fragmentShader << "\tglobal_specular_light.rgb += lightAttenuation * specularAmount * "
+ fragmentShader << " global_specular_light.rgb += lightAttenuation * specularAmount * "
"specularColor * specularBSDF( "
<< "world_normal, -" << inLightDir << ".xyz, view_vector, "
- << inLightSpecColor << ".rgb, 1.0, 2.56 / (roughnessAmount + "
- "0.01), vec3(1.0), scatter_reflect ).rgb;"
+ << inLightSpecColor << ".rgb, 2.56 / (roughnessAmount + "
+ "0.01)).rgb;"
<< Endl;
break;
}
@@ -527,7 +528,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
{
m_NormalizedDirection = inLightPrefix + "_areaDir";
AddLocalVariable(infragmentShader, m_NormalizedDirection, "vec3");
- infragmentShader << "\tlightAttenuation = calculateDiffuseAreaOld( " << m_LightDirection
+ infragmentShader << " lightAttenuation = calculateDiffuseAreaOld( " << m_LightDirection
<< ".xyz, " << m_LightPos << ".xyz, " << m_LightUp << ", " << m_LightRt
<< ", " << inPos << ", " << m_NormalizedDirection << " );" << Endl;
}
@@ -542,7 +543,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
"specularAmount * sampleAreaGlossyDefault( tanFrame, "
<< inPos << ", " << m_NormalizedDirection << ", " << m_LightPos << ".xyz, "
<< m_LightRt << ".w, " << m_LightUp << ".w, " << inView
- << ", roughnessAmount, roughnessAmount ).rgb;" << Endl;
+ << ", roughnessAmount).rgb;" << Endl;
}
void AddTranslucencyIrradiance(IShaderStageGenerator &infragmentShader, SRenderableImage *image,
@@ -553,13 +554,13 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
addFunction(infragmentShader, "diffuseReflectionWrapBSDF");
if (areaLight) {
- infragmentShader << "\tglobal_diffuse_light.rgb += lightAttenuation * "
+ infragmentShader << " global_diffuse_light.rgb += lightAttenuation * "
"translucent_thickness_exp * diffuseReflectionWrapBSDF( "
"-world_normal, "
<< m_NormalizedDirection << ", " << m_LightColor
<< ".rgb, diffuseLightWrap ).rgb;" << Endl;
} else {
- infragmentShader << "\tglobal_diffuse_light.rgb += lightAttenuation * "
+ infragmentShader << " global_diffuse_light.rgb += lightAttenuation * "
"translucent_thickness_exp * diffuseReflectionWrapBSDF( "
"-world_normal, "
<< "-" << m_NormalizedDirection << ", " << m_LightColor
@@ -601,7 +602,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if ( inType == RenderLightTypes::Area )
{
inLightShader << "vec2 " << m_ShadowCoordStem << ";" << Endl;
- inLightShader << "\tshadow_map_occl = sampleParaboloid( " << m_ShadowMapStem << ", "
+ inLightShader << " shadow_map_occl = sampleParaboloid( " << m_ShadowMapStem << ", "
<< m_ShadowControlStem << ", "
<<
m_ShadowMatrixStem << ", varWorldPos, vec2(1.0, " << m_ShadowControlStem << ".z), "
@@ -610,12 +611,12 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
else */
if (inType != RenderLightTypes::Directional) {
- inLightShader << "\tshadow_map_occl = sampleCubemap( " << m_ShadowCubeStem << ", "
+ inLightShader << " shadow_map_occl = sampleCubemap( " << m_ShadowCubeStem << ", "
<< m_ShadowControlStem << ", " << m_ShadowMatrixStem << ", " << m_LightPos
<< ".xyz, varWorldPos, vec2(1.0, " << m_ShadowControlStem << ".z) );"
<< Endl;
} else
- inLightShader << "\tshadow_map_occl = sampleOrthographic( " << m_ShadowMapStem << ", "
+ inLightShader << " shadow_map_occl = sampleOrthographic( " << m_ShadowMapStem << ", "
<< m_ShadowControlStem << ", " << m_ShadowMatrixStem
<< ", varWorldPos, vec2(1.0, " << m_ShadowControlStem << ".z) );" << Endl;
}
@@ -630,18 +631,18 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
inShader.AddUniform("displacementMap_offset", "vec3");
inShader.AddInclude("defaultMaterialFileDisplacementTexture.glsllib");
- inShader.Append("\tvec3 uTransform = vec3( displacementMap_rot.x, displacementMap_rot.y, "
+ inShader.Append(" vec3 uTransform = vec3( displacementMap_rot.x, displacementMap_rot.y, "
"displacementMap_offset.x );");
- inShader.Append("\tvec3 vTransform = vec3( displacementMap_rot.z, displacementMap_rot.w, "
+ inShader.Append(" vec3 vTransform = vec3( displacementMap_rot.z, displacementMap_rot.w, "
"displacementMap_offset.y );");
addFunction(inShader, "getTransformedUVCoords");
- inShader.Append("\tvec2 uv_coords = attr_uv0;");
- inShader << "\tuv_coords = getTransformedUVCoords( vec3( uv_coords, 1.0), uTransform, "
+ inShader.Append(" vec2 uv_coords = attr_uv0;");
+ inShader << " uv_coords = getTransformedUVCoords( vec3( uv_coords, 1.0), uTransform, "
"vTransform );\n";
- inShader << "\tvec3 displacedPos = defaultMaterialFileDisplacementTexture( "
+ inShader << " vec3 displacedPos = defaultMaterialFileDisplacementTexture( "
"displacementSampler , displaceAmount, uv_coords , attr_norm, attr_pos );"
<< Endl;
- inShader.Append("\tgl_Position = model_view_projection * vec4(displacedPos, 1.0);");
+ inShader.Append(" gl_Position = model_view_projection * vec4(displacedPos, 1.0);");
}
void AddDisplacementImageUniforms(IShaderStageGenerator &inGenerator,
@@ -663,15 +664,15 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
{
if (m_DefaultMaterialShaderKeyProperties.m_FresnelEnabled.GetValue(inKey)) {
if (inFragmentHasSpecularAmount == false)
- fragmentShader << "\tfloat specularAmount = 1.0;" << Endl;
+ fragmentShader << " float specularAmount = 1.0;" << Endl;
inFragmentHasSpecularAmount = true;
fragmentShader.AddInclude("defaultMaterialFresnel.glsllib");
fragmentShader.AddUniform("fresnelPower", "float");
fragmentShader.AddUniform("material_specular", "vec4");
- fragmentShader << "\tfloat fresnelRatio = defaultMaterialSimpleFresnel( world_normal, "
+ fragmentShader << " float fresnelRatio = defaultMaterialSimpleFresnel( world_normal, "
"view_vector, material_specular.w, fresnelPower );"
<< Endl;
- fragmentShader << "\tspecularAmount *= fresnelRatio;" << Endl;
+ fragmentShader << " specularAmount *= fresnelRatio;" << Endl;
}
return inFragmentHasSpecularAmount;
}
@@ -742,18 +743,18 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
inShader.AddUniform("displacementMap_offset", "vec3");
inShader.AddInclude("defaultMaterialFileDisplacementTexture.glsllib");
- inShader.Append("\tvec3 uTransform = vec3( displacementMap_rot.x, displacementMap_rot.y, "
+ inShader.Append(" vec3 uTransform = vec3( displacementMap_rot.x, displacementMap_rot.y, "
"displacementMap_offset.x );");
- inShader.Append("\tvec3 vTransform = vec3( displacementMap_rot.z, displacementMap_rot.w, "
+ inShader.Append(" vec3 vTransform = vec3( displacementMap_rot.z, displacementMap_rot.w, "
"displacementMap_offset.y );");
addFunction(inShader, "getTransformedUVCoords");
inShader.GenerateUVCoords();
- inShader << "\tvarTexCoord0 = getTransformedUVCoords( vec3( varTexCoord0, 1.0), "
+ inShader << " varTexCoord0 = getTransformedUVCoords( vec3( varTexCoord0, 1.0), "
"uTransform, vTransform );\n";
- inShader << "\tvec3 displacedPos = defaultMaterialFileDisplacementTexture( "
+ inShader << " vec3 displacedPos = defaultMaterialFileDisplacementTexture( "
"displacementSampler , displaceAmount, varTexCoord0 , attr_norm, attr_pos );"
<< Endl;
- inShader.Append("\tgl_Position = model_view_projection * vec4(displacedPos, 1.0);");
+ inShader.Append(" gl_Position = model_view_projection * vec4(displacedPos, 1.0);");
}
void GenerateTextureSwizzle(NVRenderTextureSwizzleMode::Enum swizzleMode,
@@ -875,14 +876,14 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
/*
VertexGenerator().AddUniform( m_ShadowMatrixStem, "mat4" );
VertexGenerator().AddOutgoing( m_ShadowCoordStem, "vec4" );
- VertexGenerator() << "\tvec4 local_" << m_ShadowCoordStem << " = " << m_ShadowMatrixStem
+ VertexGenerator() << " vec4 local_" << m_ShadowCoordStem << " = " << m_ShadowMatrixStem
<< " * vec4(local_model_world_position, 1.0);" << Endl;
m_TempStr.assign( "local_" );
m_TempStr.append( m_ShadowCoordStem );
VertexGenerator().AssignOutput( m_ShadowCoordStem.c_str(), m_TempStr.c_str() );
*/
} else {
- FragmentGenerator() << "\tshadow_map_occl = 1.0;" << Endl;
+ FragmentGenerator() << " shadow_map_occl = 1.0;" << Endl;
}
}
@@ -1035,9 +1036,9 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
// generated.
// we rely on the linker to strip out what isn't necessary instead of explicitly stripping
// it for code simplicity.
- if (hasImage) {
- fragmentShader.Append("\tvec3 uTransform;");
- fragmentShader.Append("\tvec3 vTransform;");
+ if (hasImage && hasLighting && hasLightmaps) {
+ fragmentShader.Append(" vec3 uTransform;");
+ fragmentShader.Append(" vec3 vTransform;");
}
if (includeSSAOSSDOVars || hasSpecMap || hasLighting || hasEnvMap || enableFresnel
@@ -1052,7 +1053,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if (vertexColorsEnabled)
vertexShader.GenerateVertexColor();
else
- fragmentShader.Append("\tvec3 vertColor = vec3(1.0);");
+ fragmentShader.Append(" vec3 vertColor = vec3(1.0);");
// You do bump or normal mapping but not both
if (bumpImage != nullptr) {
@@ -1061,41 +1062,41 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
fragmentShader.AddUniform(m_ImageSamplerSize, "vec2");
fragmentShader.AddInclude("defaultMaterialBumpNoLod.glsllib");
- fragmentShader << "\tworld_normal = defaultMaterialBumpNoLod( " << m_ImageSampler
+ fragmentShader << " world_normal = defaultMaterialBumpNoLod( " << m_ImageSampler
<< ", bumpAmount, " << m_ImageFragCoords
<< ", tangent, binormal, world_normal, "
<< m_ImageSamplerSize << ");" << Endl;
// Do gram schmidt
- fragmentShader << "\tbinormal = normalize(cross(world_normal, tangent) );\n";
- fragmentShader << "\ttangent = normalize(cross(binormal, world_normal) );\n";
+ fragmentShader << " binormal = normalize(cross(world_normal, tangent) );\n";
+ fragmentShader << " tangent = normalize(cross(binormal, world_normal) );\n";
} else if (normalImage != nullptr) {
GenerateImageUVCoordinates(normalImageIdx, *normalImage);
- fragmentShader.AddInclude("defaultMaterialFileNormalTexture.glsllib");
+ fragmentShader.AddFunction("sampleNormalTexture.glsllib");
fragmentShader.AddUniform("bumpAmount", "float");
- fragmentShader << "\tworld_normal = defaultMaterialFileNormalTexture( "
+ fragmentShader << " world_normal = sampleNormalTexture( "
<< m_ImageSampler << ", bumpAmount, " << m_ImageFragCoords
- << ", tangent, binormal );" << Endl;
+ << ", tangent, binormal, world_normal);" << Endl;
}
if (includeSSAOSSDOVars || specularEnabled || hasIblProbe || enableBumpNormal)
- fragmentShader << "\tmat3 tanFrame = mat3(tangent, binormal, world_normal);" << Endl;
+ fragmentShader << " mat3 tanFrame = mat3(tangent, binormal, world_normal);" << Endl;
bool fragmentHasSpecularAmount = false;
if (hasEmissiveMap) {
- fragmentShader.Append("\tvec3 global_emission = material_diffuse.rgb;");
+ fragmentShader.Append(" vec3 global_emission = material_diffuse.rgb;");
}
if (hasLighting) {
fragmentShader.AddUniform("light_ambient_total", "vec3");
fragmentShader.Append(
- "\tvec4 global_diffuse_light = vec4(light_ambient_total.xyz, 1.0);");
- fragmentShader.Append("\tvec3 global_specular_light = vec3(0.0, 0.0, 0.0);");
- fragmentShader.Append("\tfloat shadow_map_occl = 1.0;");
+ " vec4 global_diffuse_light = vec4(light_ambient_total.xyz, 1.0);");
+ fragmentShader.Append(" vec3 global_specular_light = vec3(0.0, 0.0, 0.0);");
+ fragmentShader.Append(" float shadow_map_occl = 1.0;");
if (specularEnabled) {
vertexShader.GenerateViewVector();
@@ -1104,24 +1105,24 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if (lightmapIndirectImage != nullptr) {
GenerateImageUVCoordinates(lightmapIndirectImageIdx, *lightmapIndirectImage, 1);
- fragmentShader << "\tvec4 indirect_light = texture2D( " << m_ImageSampler << ", "
+ fragmentShader << " vec4 indirect_light = texture2D( " << m_ImageSampler << ", "
<< m_ImageFragCoords << ");" << Endl;
- fragmentShader << "\tglobal_diffuse_light += indirect_light;" << Endl;
+ fragmentShader << " global_diffuse_light += indirect_light;" << Endl;
if (specularEnabled) {
fragmentShader
- << "\tglobal_specular_light += indirect_light.rgb * material_properties.x;"
+ << " global_specular_light += indirect_light.rgb * material_properties.x;"
<< Endl;
}
}
if (lightmapRadiosityImage != nullptr) {
GenerateImageUVCoordinates(lightmapRadiosityImageIdx, *lightmapRadiosityImage, 1);
- fragmentShader << "\tvec4 direct_light = texture2D( " << m_ImageSampler << ", "
+ fragmentShader << " vec4 direct_light = texture2D( " << m_ImageSampler << ", "
<< m_ImageFragCoords << ");" << Endl;
- fragmentShader << "\tglobal_diffuse_light += direct_light;" << Endl;
+ fragmentShader << " global_diffuse_light += direct_light;" << Endl;
if (specularEnabled) {
fragmentShader
- << "\tglobal_specular_light += direct_light.rgb * material_properties.x;"
+ << " global_specular_light += direct_light.rgb * material_properties.x;"
<< Endl;
}
}
@@ -1132,52 +1133,52 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
GenerateImageUVCoordinates(translucencyImageIdx, *translucencyImage);
- fragmentShader << "\tvec4 translucent_depth_range = texture2D( " << m_ImageSampler
+ fragmentShader << " vec4 translucent_depth_range = texture2D( " << m_ImageSampler
<< ", " << m_ImageFragCoords << ");" << Endl;
- fragmentShader << "\tfloat translucent_thickness = translucent_depth_range.r * "
+ fragmentShader << " float translucent_thickness = translucent_depth_range.r * "
"translucent_depth_range.r;"
<< Endl;
- fragmentShader << "\tfloat translucent_thickness_exp = exp( translucent_thickness "
+ fragmentShader << " float translucent_thickness_exp = exp( translucent_thickness "
"* translucentFalloff);"
<< Endl;
}
- fragmentShader.Append("\tfloat lightAttenuation = 1.0;");
+ fragmentShader.Append(" float lightAttenuation = 1.0;");
AddLocalVariable(fragmentShader, "aoFactor", "float");
if (hasLighting && enableSSAO)
- fragmentShader.Append("\taoFactor = customMaterialAO();");
+ fragmentShader.Append(" aoFactor = customMaterialAO();");
else
- fragmentShader.Append("\taoFactor = 1.0;");
+ fragmentShader.Append(" aoFactor = 1.0;");
AddLocalVariable(fragmentShader, "shadowFac", "float");
if (specularEnabled) {
- fragmentShader << "\tfloat specularAmount = material_properties.x;" << Endl;
+ fragmentShader << " float specularAmount = material_properties.x;" << Endl;
fragmentHasSpecularAmount = true;
}
// Fragment lighting means we can perhaps attenuate the specular amount by a texture
// lookup.
- fragmentShader << "\tvec3 specularColor = vec3(1.0);" << Endl;
+ fragmentShader << " vec3 specularColor = vec3(1.0);" << Endl;
if (specularAmountImage) {
if (!specularEnabled)
- fragmentShader << "\tfloat specularAmount = 1.0;" << Endl;
+ fragmentShader << " float specularAmount = 1.0;" << Endl;
GenerateImageUVCoordinates(specularAmountImageIdx, *specularAmountImage);
- fragmentShader << "\tspecularColor = texture2D( "
+ fragmentShader << " specularColor = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << " ).xyz;" << Endl;
fragmentHasSpecularAmount = true;
}
- fragmentShader << "\tfloat roughnessAmount = material_properties.y;" << Endl;
+ fragmentShader << " float roughnessAmount = material_properties.y;" << Endl;
if (roughnessImage) {
GenerateImageUVCoordinates(roughnessImageIdx, *roughnessImage);
- fragmentShader << "\tfloat sampledRoughness = texture2D( "
+ fragmentShader << " float sampledRoughness = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << " ).x;" << Endl;
//The roughness sampled from roughness textures is Disney roughness
//which has to be squared to get the proper value
- fragmentShader << "\troughnessAmount = roughnessAmount * "
+ fragmentShader << " roughnessAmount = roughnessAmount * "
<< "sampledRoughness * sampledRoughness;" << Endl;
}
@@ -1199,8 +1200,8 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
m_TempStr.assign("light");
m_TempStr.append(buf);
- fragmentShader << "\t//Light " << buf << Endl;
- fragmentShader << "\tlightAttenuation = 1.0;" << Endl;
+ fragmentShader << " //Light " << buf << Endl;
+ fragmentShader << " lightAttenuation = 1.0;" << Endl;
if (isDirectional) {
if (m_LightsAsSeparateUniforms) {
@@ -1209,22 +1210,22 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
if (enableSSDO) {
- fragmentShader << "\tshadowFac = customMaterialShadow( " << m_LightDirection
+ fragmentShader << " shadowFac = customMaterialShadow( " << m_LightDirection
<< ".xyz, varWorldPos );" << Endl;
} else {
- fragmentShader << "\tshadowFac = 1.0;" << Endl;
+ fragmentShader << " shadowFac = 1.0;" << Endl;
}
GenerateShadowMapOcclusion(lightIdx, enableShadowMaps && isShadow,
lightNode->m_LightType);
if (specularEnabled && enableShadowMaps && isShadow)
- fragmentShader << "\tlightAttenuation *= shadow_map_occl;" << Endl;
+ fragmentShader << " lightAttenuation *= shadow_map_occl;" << Endl;
- fragmentShader << "\tglobal_diffuse_light.rgb += shadowFac * shadow_map_occl * "
+ fragmentShader << " global_diffuse_light.rgb += shadowFac * shadow_map_occl * "
"diffuseReflectionBSDF( world_normal, "
- << "-" << m_LightDirection << ".xyz, view_vector, "
- << m_LightColor << ".rgb, 0.0 ).rgb;" << Endl;
+ << "-" << m_LightDirection << ".xyz, "
+ << m_LightColor << ".rgb).rgb;" << Endl;
if (specularEnabled) {
if (m_LightsAsSeparateUniforms)
@@ -1250,7 +1251,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
// Debug measure to make sure paraboloid sampling was projecting to the right
// location
- // fragmentShader << "\tglobal_diffuse_light.rg += " << m_ShadowCoordStem << ";"
+ // fragmentShader << " global_diffuse_light.rg += " << m_ShadowCoordStem << ";"
// << Endl;
m_NormalizedDirection = m_TempStr;
m_NormalizedDirection.append("_Frame");
@@ -1261,10 +1262,10 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
<< Endl;
if (enableSSDO) {
- fragmentShader << "\tshadowFac = shadow_map_occl * customMaterialShadow( "
+ fragmentShader << " shadowFac = shadow_map_occl * customMaterialShadow( "
<< m_LightDirection << ".xyz, varWorldPos );" << Endl;
} else {
- fragmentShader << "\tshadowFac = shadow_map_occl;" << Endl;
+ fragmentShader << " shadowFac = shadow_map_occl;" << Endl;
}
if (specularEnabled) {
@@ -1276,14 +1277,14 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
OutputDiffuseAreaLighting(fragmentShader, "varWorldPos", m_TempStr);
- fragmentShader << "\tlightAttenuation *= shadowFac;" << Endl;
+ fragmentShader << " lightAttenuation *= shadowFac;" << Endl;
AddTranslucencyIrradiance(fragmentShader, translucencyImage, m_TempStr, true);
- fragmentShader << "\tglobal_diffuse_light.rgb += lightAttenuation * "
+ fragmentShader << " global_diffuse_light.rgb += lightAttenuation * "
"diffuseReflectionBSDF( world_normal, "
- << m_NormalizedDirection << ", view_vector, " << m_LightColor
- << ".rgb, 0.0 ).rgb;" << Endl;
+ << m_NormalizedDirection << ", " << m_LightColor
+ << ".rgb).rgb;" << Endl;
} else {
vertexShader.GenerateWorldPosition();
@@ -1304,19 +1305,19 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
m_RelativeDistance = m_TempStr;
m_RelativeDistance.append("_distance");
- fragmentShader << "\tvec3 " << m_RelativeDirection << " = varWorldPos - "
+ fragmentShader << " vec3 " << m_RelativeDirection << " = varWorldPos - "
<< m_LightPos << ".xyz;" << Endl;
- fragmentShader << "\tfloat " << m_RelativeDistance << " = length( "
+ fragmentShader << " float " << m_RelativeDistance << " = length( "
<< m_RelativeDirection << " );" << Endl;
- fragmentShader << "\tvec3 " << m_NormalizedDirection << " = "
+ fragmentShader << " vec3 " << m_NormalizedDirection << " = "
<< m_RelativeDirection << " / " << m_RelativeDistance << ";"
<< Endl;
if (enableSSDO) {
- fragmentShader << "\tshadowFac = shadow_map_occl * customMaterialShadow( "
+ fragmentShader << " shadowFac = shadow_map_occl * customMaterialShadow( "
<< m_NormalizedDirection << ", varWorldPos );" << Endl;
} else {
- fragmentShader << "\tshadowFac = shadow_map_occl;" << Endl;
+ fragmentShader << " shadowFac = shadow_map_occl;" << Endl;
}
addFunction(fragmentShader, "calculatePointLightAttenuation");
@@ -1324,13 +1325,13 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if (m_LightsAsSeparateUniforms) {
fragmentShader.AddUniform(m_LightAttenuation, "vec3");
fragmentShader
- << "\tlightAttenuation = shadowFac * calculatePointLightAttenuation("
+ << " lightAttenuation = shadowFac * calculatePointLightAttenuation("
<< "vec3( " << m_LightAttenuation << ".x, " << m_LightAttenuation
<< ".y, " << m_LightAttenuation << ".z), " << m_RelativeDistance
<< ");" << Endl;
} else {
fragmentShader
- << "\tlightAttenuation = shadowFac * calculatePointLightAttenuation("
+ << " lightAttenuation = shadowFac * calculatePointLightAttenuation("
<< "vec3( " << m_LightConstantAttenuation << ", "
<< m_LightLinearAttenuation << ", " << m_LightQuadraticAttenuation
<< "), " << m_RelativeDistance << ");"
@@ -1341,10 +1342,10 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
AddTranslucencyIrradiance(fragmentShader, translucencyImage, m_TempStr, false);
- fragmentShader << "\tglobal_diffuse_light.rgb += lightAttenuation * "
+ fragmentShader << " global_diffuse_light.rgb += lightAttenuation * "
"diffuseReflectionBSDF( world_normal, "
- << "-" << m_NormalizedDirection << ", view_vector, "
- << m_LightColor << ".rgb, 0.0 ).rgb;" << Endl;
+ << "-" << m_NormalizedDirection << ", "
+ << m_LightColor << ".rgb).rgb;" << Endl;
if (specularEnabled) {
if (m_LightsAsSeparateUniforms)
@@ -1363,14 +1364,14 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
// Furthermore object_opacity is something that may come from the vertex pipeline or
// somewhere else.
// We leave it up to the vertex pipeline to figure it out.
- fragmentShader << "\tglobal_diffuse_light = vec4(global_diffuse_light.xyz * aoFactor, "
+ fragmentShader << " global_diffuse_light = vec4(global_diffuse_light.xyz * aoFactor, "
"object_opacity);"
- << Endl << "\tglobal_specular_light = vec3(global_specular_light.xyz);"
+ << Endl << " global_specular_light = vec3(global_specular_light.xyz);"
<< Endl;
} else // no lighting.
{
- fragmentShader << "\tvec4 global_diffuse_light = vec4(0.0, 0.0, 0.0, object_opacity);"
- << Endl << "\tvec3 global_specular_light = vec3(0.0, 0.0, 0.0);" << Endl;
+ fragmentShader << " vec4 global_diffuse_light = vec4(0.0, 0.0, 0.0, object_opacity);"
+ << Endl << " vec3 global_specular_light = vec3(0.0, 0.0, 0.0);" << Endl;
// We still have specular maps and such that could potentially use the fresnel variable.
fragmentHasSpecularAmount =
@@ -1379,19 +1380,19 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if (!hasEmissiveMap)
fragmentShader
- << "\tglobal_diffuse_light.rgb += diffuse_color.rgb * material_diffuse.rgb;"
+ << " global_diffuse_light.rgb += diffuse_color.rgb * material_diffuse.rgb;"
<< Endl;
// since we already modulate our material diffuse color
// into the light color we will miss it entirely if no IBL
// or light is used
if (hasLightmaps && !(m_Lights.size() || hasIblProbe))
- fragmentShader << "\tglobal_diffuse_light.rgb *= diffuse_color.rgb;" << Endl;
+ fragmentShader << " global_diffuse_light.rgb *= diffuse_color.rgb;" << Endl;
if (hasLighting && hasIblProbe) {
vertexShader.GenerateWorldNormal();
- fragmentShader << "\tglobal_diffuse_light.rgb += diffuse_color.rgb * aoFactor * "
+ fragmentShader << " global_diffuse_light.rgb += diffuse_color.rgb * aoFactor * "
"sampleDiffuse( tanFrame ).xyz;"
<< Endl;
@@ -1399,7 +1400,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
fragmentShader.AddUniform("material_specular", "vec4");
- fragmentShader << "\tglobal_specular_light.xyz += specularAmount * specularColor * "
+ fragmentShader << " global_specular_light.xyz += specularAmount * specularColor * "
"vec3(material_specular.xyz) * sampleGlossy( tanFrame, "
"view_vector, roughnessAmount ).xyz;"
<< Endl;
@@ -1407,7 +1408,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
if (hasImage) {
- fragmentShader.Append("\tvec4 texture_color;");
+ fragmentShader.Append(" vec4 texture_color;");
QT3DSU32 idx = 0;
for (SRenderableImage *image = m_FirstImage; image; image = image->m_NextImage, ++idx) {
// Various maps are handled on a different locations
@@ -1431,18 +1432,18 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
lookupSwizzle);
if (texLodStr.empty()) {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << " = texture2D( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << " = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ")"
<< lookupSwizzle.c_str() << ";" << Endl;
} else {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << "= textureLod( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << "= textureLod( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ", "
<< texLodStr.c_str() << " )" << lookupSwizzle.c_str() << ";"
<< Endl;
}
if (image->m_Image.m_TextureData.m_TextureFlags.IsPreMultiplied() == true)
- fragmentShader << "\ttexture_color.rgb = texture_color.a > 0.0 ? "
+ fragmentShader << " texture_color.rgb = texture_color.a > 0.0 ? "
"texture_color.rgb / texture_color.a : vec3( 0, 0, 0 );"
<< Endl;
@@ -1454,27 +1455,27 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
// not premultiplied textures.
// If Z is 1, then we assume the incoming texture is already premultiplied, else
// we just read the rgb value.
- fragmentShader.Append("\tglobal_diffuse_light *= texture_color;");
+ fragmentShader.Append(" global_diffuse_light *= texture_color;");
break;
case ImageMapTypes::Specular:
fragmentShader.AddUniform("material_specular", "vec4");
if (fragmentHasSpecularAmount) {
- fragmentShader.Append("\tglobal_specular_light.xyz += specularAmount * "
+ fragmentShader.Append(" global_specular_light.xyz += specularAmount * "
"specularColor * texture_color.xyz * "
"material_specular.xyz;");
} else {
- fragmentShader.Append("\tglobal_specular_light.xyz += texture_color.xyz * "
+ fragmentShader.Append(" global_specular_light.xyz += texture_color.xyz * "
"material_specular.xyz;");
}
- fragmentShader.Append("\tglobal_diffuse_light.a *= texture_color.a;");
+ fragmentShader.Append(" global_diffuse_light.a *= texture_color.a;");
break;
case ImageMapTypes::Opacity:
- fragmentShader.Append("\tglobal_diffuse_light.a *= texture_color.a;");
+ fragmentShader.Append(" global_diffuse_light.a *= texture_color.a;");
break;
case ImageMapTypes::Emissive:
fragmentShader.Append(
- "\tglobal_emission *= texture_color.xyz * texture_color.a;");
+ " global_emission *= texture_color.xyz * texture_color.a;");
break;
default:
QT3DS_ASSERT(false); // fallthrough intentional
@@ -1486,27 +1487,27 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
if (enableAlphaTest) {
fragmentShader.AddUniform("alphaOpRef", "vec2");
fragmentShader.Append(
- "\tif (dot(vec2(global_diffuse_light.a, 1.0), alphaOpRef) <= 0.0)\n"
- "\t\tdiscard;");
+ " if (dot(vec2(global_diffuse_light.a, 1.0), alphaOpRef) <= 0.0)\n"
+ " discard;");
}
if (hasEmissiveMap) {
- fragmentShader.Append("\tglobal_diffuse_light.rgb += global_emission.rgb;");
+ fragmentShader.Append(" global_diffuse_light.rgb += global_emission.rgb;");
}
// Ensure the rgb colors are in range.
- fragmentShader.Append("\tfragOutput = vec4( clamp( vertColor * global_diffuse_light.xyz + "
+ fragmentShader.Append(" fragOutput = vec4( clamp( vertColor * global_diffuse_light.xyz + "
"global_specular_light.xyz, 0.0, 65519.0 ), global_diffuse_light.a "
");");
if (VertexGenerator().HasActiveWireframe()) {
fragmentShader.Append("vec3 edgeDistance = varEdgeDistance * gl_FragCoord.w;");
fragmentShader.Append(
- "\tfloat d = min(min(edgeDistance.x, edgeDistance.y), edgeDistance.z);");
- fragmentShader.Append("\tfloat mixVal = smoothstep(0.0, 1.0, d);"); // line width 1.0
+ " float d = min(min(edgeDistance.x, edgeDistance.y), edgeDistance.z);");
+ fragmentShader.Append(" float mixVal = smoothstep(0.0, 1.0, d);"); // line width 1.0
fragmentShader.Append(
- "\tfragOutput = mix( vec4(0.0, 1.0, 0.0, 1.0), fragOutput, mixVal);");
+ " fragOutput = mix( vec4(0.0, 1.0, 0.0, 1.0), fragOutput, mixVal);");
}
}
@@ -1552,13 +1553,13 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
vertexShader.AddIncoming("attr_pos", "vec3");
vertexShader.AddUniform("model_view_projection", "mat4");
vertexShader.Append("void main() {");
- vertexShader.Append("\tgl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
- vertexShader.Append("\tvec3 uTransform;");
- vertexShader.Append("\tvec3 vTransform;");
+ vertexShader.Append(" gl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
+ vertexShader.Append(" vec3 uTransform;");
+ vertexShader.Append(" vec3 vTransform;");
- fragmentShader << "\tfloat global_opacity = object_opacity;" << Endl;
+ fragmentShader << " float global_opacity = object_opacity;" << Endl;
- fragmentShader.Append("\tvec4 texture_color;");
+ fragmentShader.Append(" vec4 texture_color;");
QT3DSU32 idx = 0;
for (SRenderableImage *image = m_FirstImage; image; image = image->m_NextImage, ++idx) {
// Various maps are handled on a different locations
@@ -1583,11 +1584,11 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
lookupSwizzle);
if (texLodStr.empty()) {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << " = texture2D( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << " = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ")"
<< lookupSwizzle.c_str() << ";" << Endl;
} else {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << "= textureLod( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << "= textureLod( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ", "
<< texLodStr.c_str() << " )" << lookupSwizzle.c_str() << ";"
<< Endl;
@@ -1598,7 +1599,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
case ImageMapTypes::LightmapShadow:
case ImageMapTypes::Specular:
case ImageMapTypes::Opacity:
- fragmentShader.Append("\tglobal_opacity *= texture_color.a;");
+ fragmentShader.Append(" global_opacity *= texture_color.a;");
break;
default:
break;
@@ -1606,9 +1607,9 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
fragmentShader.AddUniform("alphaOpRef", "vec2");
- fragmentShader.Append("\tif (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
- "\t\tdiscard;");
- fragmentShader.Append("\tfragOutput = vec4(0.0);");
+ fragmentShader.Append(" if (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
+ " discard;");
+ fragmentShader.Append(" fragOutput = vec4(0.0);");
fragmentShader.Append("}");
vertexShader.Append("}");
@@ -1663,16 +1664,16 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
vertexShader.AddOutgoing("world_pos", "vec4");
vertexShader.Append("void main() {");
- vertexShader.Append("\tvec3 uTransform;");
- vertexShader.Append("\tvec3 vTransform;");
- vertexShader.Append("\tworld_pos = model_matrix * vec4( attr_pos, 1.0 );");
- vertexShader.Append("\tworld_pos /= world_pos.w;");
- vertexShader.Append("\tgl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
- vertexShader.Append("\traw_pos = vec4( attr_pos, 1.0 );");
+ vertexShader.Append(" vec3 uTransform;");
+ vertexShader.Append(" vec3 vTransform;");
+ vertexShader.Append(" world_pos = model_matrix * vec4( attr_pos, 1.0 );");
+ vertexShader.Append(" world_pos /= world_pos.w;");
+ vertexShader.Append(" gl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
+ vertexShader.Append(" raw_pos = vec4( attr_pos, 1.0 );");
- fragmentShader << "\tfloat global_opacity = object_opacity;" << Endl;
+ fragmentShader << " float global_opacity = object_opacity;" << Endl;
- fragmentShader.Append("\tvec4 texture_color;");
+ fragmentShader.Append(" vec4 texture_color;");
QT3DSU32 idx = 0;
for (SRenderableImage *image = m_FirstImage; image; image = image->m_NextImage, ++idx) {
// Various maps are handled on different locations
@@ -1697,11 +1698,11 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
lookupSwizzle);
if (texLodStr.empty()) {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << " = texture2D( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << " = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ")"
<< lookupSwizzle.c_str() << ";" << Endl;
} else {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << "= textureLod( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << "= textureLod( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ", "
<< texLodStr.c_str() << " )" << lookupSwizzle.c_str() << ";"
<< Endl;
@@ -1712,7 +1713,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
case ImageMapTypes::LightmapShadow:
case ImageMapTypes::Specular:
case ImageMapTypes::Opacity:
- fragmentShader.Append("\tglobal_opacity *= texture_color.a;");
+ fragmentShader.Append(" global_opacity *= texture_color.a;");
break;
default:
break;
@@ -1721,14 +1722,14 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
fragmentShader.AddUniform("camera_position", "vec3");
fragmentShader.AddUniform("camera_properties", "vec2");
- fragmentShader.Append("\tvec3 camPos = vec3(camera_position.x, camera_position.y, "
+ fragmentShader.Append(" vec3 camPos = vec3(camera_position.x, camera_position.y, "
"-camera_position.z);");
- fragmentShader.Append("\tfloat dist = length(world_pos.xyz - camPos);");
- fragmentShader.Append("\tdist = max((dist - 1.0) / (camera_properties.y - 1.0), 0.0);");
+ fragmentShader.Append(" float dist = length(world_pos.xyz - camPos);");
+ fragmentShader.Append(" dist = max((dist - 1.0) / (camera_properties.y - 1.0), 0.0);");
fragmentShader.AddUniform("alphaOpRef", "vec2");
- fragmentShader.Append("\tif (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
- "\t\tdist = 1.0;");
- fragmentShader.Append("\tfragOutput = vec4(dist);");
+ fragmentShader.Append(" if (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
+ " dist = 1.0;");
+ fragmentShader.Append(" fragOutput = vec4(dist);");
fragmentShader.Append("}");
vertexShader.Append("}");
@@ -1781,14 +1782,14 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
vertexShader.AddOutgoing("outDepth", "vec3");
vertexShader.Append("void main() {");
- vertexShader.Append("\tvec3 uTransform;");
- vertexShader.Append("\tvec3 vTransform;");
- vertexShader.Append("\tgl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
- vertexShader.Append("\toutDepth.x = gl_Position.z / gl_Position.w;");
+ vertexShader.Append(" vec3 uTransform;");
+ vertexShader.Append(" vec3 vTransform;");
+ vertexShader.Append(" gl_Position = model_view_projection * vec4( attr_pos, 1.0 );");
+ vertexShader.Append(" outDepth.x = gl_Position.z / gl_Position.w;");
- fragmentShader << "\tfloat global_opacity = object_opacity;" << Endl;
+ fragmentShader << " float global_opacity = object_opacity;" << Endl;
- fragmentShader.Append("\tvec4 texture_color;");
+ fragmentShader.Append(" vec4 texture_color;");
QT3DSU32 idx = 0;
for (SRenderableImage *image = m_FirstImage; image; image = image->m_NextImage, ++idx) {
// Various maps are handled on different locations
@@ -1813,11 +1814,11 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
lookupSwizzle);
if (texLodStr.empty()) {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << " = texture2D( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << " = texture2D( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ")"
<< lookupSwizzle.c_str() << ";" << Endl;
} else {
- fragmentShader << "\ttexture_color" << texSwizzle.c_str() << "= textureLod( "
+ fragmentShader << " texture_color" << texSwizzle.c_str() << "= textureLod( "
<< m_ImageSampler << ", " << m_ImageFragCoords << ", "
<< texLodStr.c_str() << " )" << lookupSwizzle.c_str() << ";"
<< Endl;
@@ -1828,7 +1829,7 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
case ImageMapTypes::LightmapShadow:
case ImageMapTypes::Specular:
case ImageMapTypes::Opacity:
- fragmentShader.Append("\tglobal_opacity *= texture_color.a;");
+ fragmentShader.Append(" global_opacity *= texture_color.a;");
break;
default:
break;
@@ -1836,10 +1837,10 @@ struct SShaderGenerator : public IDefaultMaterialShaderGenerator
}
fragmentShader.AddUniform("alphaOpRef", "vec2");
- fragmentShader.Append("\tfloat depth = (outDepth.x + 1.0) * 0.5;");
- fragmentShader.Append("\tif (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
- "\t\tdepth = 1.0;");
- fragmentShader.Append("\tfragOutput = vec4(depth);");
+ fragmentShader.Append(" float depth = (outDepth.x + 1.0) * 0.5;");
+ fragmentShader.Append(" if (dot(vec2(global_opacity, 1.0), alphaOpRef) <= 0.0)\n"
+ " depth = 1.0;");
+ fragmentShader.Append(" fragOutput = vec4(depth);");
fragmentShader.Append("}");
vertexShader.Append("}");