summaryrefslogtreecommitdiffstats
path: root/src/extras/shaders/es3
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras/shaders/es3')
-rw-r--r--src/extras/shaders/es3/light.inc.frag1
-rw-r--r--src/extras/shaders/es3/metalrough.inc.frag11
2 files changed, 2 insertions, 10 deletions
diff --git a/src/extras/shaders/es3/light.inc.frag b/src/extras/shaders/es3/light.inc.frag
index 18012ccc1..7b6bf3bc5 100644
--- a/src/extras/shaders/es3/light.inc.frag
+++ b/src/extras/shaders/es3/light.inc.frag
@@ -20,6 +20,7 @@ uniform int lightCount;
struct EnvironmentLight {
highp samplerCube irradiance; // For diffuse contribution
highp samplerCube specular; // For specular contribution
+ int specularMipLevels;
};
uniform EnvironmentLight envLight;
uniform int envLightCount;
diff --git a/src/extras/shaders/es3/metalrough.inc.frag b/src/extras/shaders/es3/metalrough.inc.frag
index 188a367f5..fc014b81b 100644
--- a/src/extras/shaders/es3/metalrough.inc.frag
+++ b/src/extras/shaders/es3/metalrough.inc.frag
@@ -59,13 +59,6 @@ const FP float gamma = 2.2;
#pragma include light.inc.frag
-int mipLevelCount(const in FP samplerCube cube)
-{
- int baseSize = textureSize(cube, 0).x;
- int nMips = int(log2(float(baseSize > 0 ? baseSize : 1))) + 1;
- return nMips;
-}
-
FP float remapRoughness(const in FP float roughness)
{
// As per page 14 of
@@ -91,10 +84,8 @@ FP float alphaToMipLevel(FP float alpha)
const FP float k1 = 0.9921;
FP float glossiness = (pow(2.0, -10.0 / sqrt(specPower)) - k0) / k1;
- // TODO: Optimize by doing this on CPU and set as
- // uniform int envLight.specularMipLevels say (if present in shader).
// Lookup the number of mips in the specular envmap
- int mipLevels = mipLevelCount(envLight.specular);
+ int mipLevels = envLight.specularMipLevels;
// Offset of smallest miplevel we should use (corresponds to specular
// power of 1). I.e. in the 32x32 sized mip.