summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2021-10-08 20:44:28 -0400
committerDavid Thompson <dthompson2@worcester.edu>2021-10-08 20:44:28 -0400
commit53429f77e3fcfaa4fdc3d95b840b6728b4452f72 (patch)
treee5766772d1deac156871ce5ad119f8c3ab260243 /data
parentc22eda980c51db210bbe73f500e9f3fc3052a5f3 (diff)
graphics: Fix compatibility issue with cube maps in phong/pbr shaders.
Diffstat (limited to 'data')
-rw-r--r--data/shaders/pbr-frag.glsl5
-rw-r--r--data/shaders/phong-frag.glsl5
2 files changed, 8 insertions, 2 deletions
diff --git a/data/shaders/pbr-frag.glsl b/data/shaders/pbr-frag.glsl
index a211096..0986840 100644
--- a/data/shaders/pbr-frag.glsl
+++ b/data/shaders/pbr-frag.glsl
@@ -66,6 +66,9 @@ const float GAMMA = 2.2;
vec4 texture(sampler2D tex, vec2 coord) {
return texture2D(tex, coord);
}
+vec4 texture(samplerCube tex, vec3 coord) {
+ return textureCube(tex, coord);
+}
#endif
float posDot(vec3 v1, vec3 v2) {
@@ -364,7 +367,7 @@ void main(void) {
//
// TODO: Use fancy PBR equations instead of these basic ones.
float fresnel = pow(1.0 - clamp(dot(viewDirection, normal), 0.0, 1.0), 5);
- vec3 ambientDiffuse = textureCube(skybox, normal).rgb;
+ vec3 ambientDiffuse = texture(skybox, normal).rgb;
vec3 ambientSpecular = textureLod(skybox, reflection, roughness * 7.0).rgb;
color += (ambientDiffuse * albedo + ambientSpecular * fresnel) * ambientOcclusion;
// Apply Reinhard tone mapping to convert our high dynamic range
diff --git a/data/shaders/phong-frag.glsl b/data/shaders/phong-frag.glsl
index c1a19c1..2d70fda 100644
--- a/data/shaders/phong-frag.glsl
+++ b/data/shaders/phong-frag.glsl
@@ -50,6 +50,9 @@ const float GAMMA = 2.2;
vec4 texture(sampler2D tex, vec2 coord) {
return texture2D(tex, coord);
}
+vec4 texture(samplerCube tex, vec3 coord) {
+ return textureCube(tex, coord);
+}
#endif
vec3 gammaCorrect(vec3 color) {
@@ -161,7 +164,7 @@ void main() {
// Apply image based ambient lighting.
float fresnel = pow(1.0 - clamp(dot(viewDir, normal), 0.0, 1.0), 5);
float roughness = 1.0 - (material.shininess / 1000.0);
- vec3 ambientDiffuse = textureCube(skybox, normal).rgb * diffuseColor;
+ vec3 ambientDiffuse = texture(skybox, normal).rgb * diffuseColor;
vec3 ambientSpecular = textureLod(skybox, reflection, roughness * 7.0).rgb * fresnel;
vec3 ambientColor = (ambientDiffuse + ambientSpecular) * ambientOcclusion;
color += ambientColor;