Deferred renderer: remove explicit diffuse material property

This commit is contained in:
Nikita Lisitsa 2020-12-10 23:34:00 +03:00
parent 91650cb4ac
commit 82817304e2
2 changed files with 8 additions and 9 deletions

View file

@ -38,7 +38,6 @@ namespace psemek::gfx
bool blooming = false; bool blooming = false;
bool casts_shadow = true; bool casts_shadow = true;
float diffuse = 1.f;
struct struct
{ {
// specular highlight is calculated as // specular highlight is calculated as

View file

@ -99,7 +99,7 @@ R"(
uniform vec4 u_color; uniform vec4 u_color;
uniform sampler2D u_texture; uniform sampler2D u_texture;
uniform vec3 u_material; uniform vec2 u_material;
uniform float u_max_intensity; uniform float u_max_intensity;
in vec3 position; in vec3 position;
@ -110,7 +110,7 @@ in vec3 normal;
layout (location = 0) out vec3 out0; layout (location = 0) out vec3 out0;
layout (location = 1) out vec4 out1; layout (location = 1) out vec4 out1;
layout (location = 2) out uint out2; layout (location = 2) out uint out2;
layout (location = 3) out vec3 out3; layout (location = 3) out vec2 out3;
uint pack_normal(vec3 n) uint pack_normal(vec3 n)
{ {
@ -390,7 +390,7 @@ void main()
vec3 position = texture(u_g0, texcoord).xyz; vec3 position = texture(u_g0, texcoord).xyz;
vec3 normal = unpack_normal(texture(u_g2, texcoord).r); 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); vec3 view = normalize(u_camera_position - position);
@ -398,7 +398,7 @@ void main()
vec3 refl = 2.0 * normal * d - u_light_direction; 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; vec3 color = l * albedo.rgb * u_light_color;
@ -447,7 +447,7 @@ void main()
vec3 position = texture(u_g0, texcoord).xyz; vec3 position = texture(u_g0, texcoord).xyz;
vec3 normal = unpack_normal(texture(u_g2, texcoord).r); 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); vec3 view = normalize(u_camera_position - position);
@ -461,7 +461,7 @@ void main()
vec3 refl = 2.0 * normal * d - light_n; 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)); 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) if (mask & O_POST_TRANSFORM)
program["u_post_transform"] = *o.post_transform; program["u_post_transform"] = *o.post_transform;
program["u_material"] = geom::vector<float, 3>{o.mat->diffuse, o.mat->specular.intensity, o.mat->specular.shininess}; program["u_material"] = geom::vector<float, 2>{o.mat->specular.intensity, o.mat->specular.shininess};
o.mesh->draw(); o.mesh->draw();
} }
@ -1007,7 +1007,7 @@ void main()
{ {
impl().g_buffer_texture[1].load<geom::vector<std::uint16_t, 4>>(buffer_size); impl().g_buffer_texture[1].load<geom::vector<std::uint16_t, 4>>(buffer_size);
impl().g_buffer_texture[2].load<gfx::integer<std::uint32_t>>(buffer_size); impl().g_buffer_texture[2].load<gfx::integer<std::uint32_t>>(buffer_size);
impl().g_buffer_texture[3].load<geom::vector<gfx::float16, 3>>(buffer_size); impl().g_buffer_texture[3].load<geom::vector<gfx::float16, 2>>(buffer_size);
impl().g_buffer_depth.load<gfx::depth24_pixel>(buffer_size); impl().g_buffer_depth.load<gfx::depth24_pixel>(buffer_size);
} }