diff --git a/libs/gfx/include/psemek/gfx/renderer/deferred.hpp b/libs/gfx/include/psemek/gfx/renderer/deferred.hpp index d3084898..8184c65a 100644 --- a/libs/gfx/include/psemek/gfx/renderer/deferred.hpp +++ b/libs/gfx/include/psemek/gfx/renderer/deferred.hpp @@ -38,7 +38,6 @@ namespace psemek::gfx bool blooming = false; bool casts_shadow = true; - float diffuse = 1.f; struct { // specular highlight is calculated as diff --git a/libs/gfx/source/renderer/deferred.cpp b/libs/gfx/source/renderer/deferred.cpp index d58732c3..3e54578e 100644 --- a/libs/gfx/source/renderer/deferred.cpp +++ b/libs/gfx/source/renderer/deferred.cpp @@ -99,7 +99,7 @@ R"( uniform vec4 u_color; uniform sampler2D u_texture; -uniform vec3 u_material; +uniform vec2 u_material; uniform float u_max_intensity; in vec3 position; @@ -110,7 +110,7 @@ in vec3 normal; layout (location = 0) out vec3 out0; layout (location = 1) out vec4 out1; layout (location = 2) out uint out2; -layout (location = 3) out vec3 out3; +layout (location = 3) out vec2 out3; uint pack_normal(vec3 n) { @@ -390,7 +390,7 @@ void main() vec3 position = texture(u_g0, texcoord).xyz; vec3 normal = unpack_normal(texture(u_g2, texcoord).r); - vec3 material = texture(u_g3, texcoord).xyz; + vec2 material = texture(u_g3, texcoord).xy; vec3 view = normalize(u_camera_position - position); @@ -398,7 +398,7 @@ void main() vec3 refl = 2.0 * normal * d - u_light_direction; - float l = max(0.0, d) * material.x + pow(max(0.0, dot(view, refl)), material.z) * material.y; + float l = max(0.0, d) + pow(max(0.0, dot(view, refl)), material.y) * material.x; vec3 color = l * albedo.rgb * u_light_color; @@ -447,7 +447,7 @@ void main() vec3 position = texture(u_g0, texcoord).xyz; vec3 normal = unpack_normal(texture(u_g2, texcoord).r); - vec3 material = texture(u_g3, texcoord).xyz; + vec2 material = texture(u_g3, texcoord).xy; vec3 view = normalize(u_camera_position - position); @@ -461,7 +461,7 @@ void main() vec3 refl = 2.0 * normal * d - light_n; - float l = max(0.0, d) * material.x + pow(max(0.0, dot(view, refl)), material.z) * material.y; + float l = max(0.0, d) + pow(max(0.0, dot(view, refl)), material.y) * material.x; vec3 color = l * albedo.rgb * u_light_color / (u_light_attenuation.x + r * (u_light_attenuation.y + r * u_light_attenuation.z)); @@ -985,7 +985,7 @@ void main() if (mask & O_POST_TRANSFORM) program["u_post_transform"] = *o.post_transform; - program["u_material"] = geom::vector{o.mat->diffuse, o.mat->specular.intensity, o.mat->specular.shininess}; + program["u_material"] = geom::vector{o.mat->specular.intensity, o.mat->specular.shininess}; o.mesh->draw(); } @@ -1007,7 +1007,7 @@ void main() { impl().g_buffer_texture[1].load>(buffer_size); impl().g_buffer_texture[2].load>(buffer_size); - impl().g_buffer_texture[3].load>(buffer_size); + impl().g_buffer_texture[3].load>(buffer_size); impl().g_buffer_depth.load(buffer_size); }