From fcf78bdc0c10cd4fdf727fdd596d6a40a9e0f1ca Mon Sep 17 00:00:00 2001 From: "R.E. Kovalev" Date: Tue, 13 Jun 2023 15:08:21 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=88=D0=B5=D0=B9=D0=B4=D0=B5=D1=80=D0=B0=20?= =?UTF-8?q?=D0=B3=D0=B5=D0=BE=D0=BC=D0=B5=D1=82=D1=80=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=BE=D0=B3=D0=BE=20=D0=BF=D1=80=D0=BE=D1=85=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=20=D0=BE=D1=82=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5=D0=BD=D0=B4=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shaders/gshader.frag | 38 ++++++++++++++++++++++---------------- shaders/gshader.vert | 9 +++++---- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/shaders/gshader.frag b/shaders/gshader.frag index 140a525..d930562 100644 --- a/shaders/gshader.frag +++ b/shaders/gshader.frag @@ -2,10 +2,11 @@ layout(std140, binding = 1) uniform Material { - vec3 ka; - vec3 kd; - vec3 ks; - float p; + vec3 base_color; + float roughness; + float metallic; + float specular; + vec3 emitted; bool normalmapped; bool parallaxmapped; bool displacementmapped; @@ -13,9 +14,10 @@ layout(std140, binding = 1) uniform Material layout (location = 0) out vec3 gPosition; layout (location = 1) out vec3 gNormal; -layout (location = 2) out vec4 gDiffuseP; -layout (location = 3) out vec4 gAmbientSpecular; +layout (location = 2) out vec3 gBaseColor; +layout (location = 3) out vec3 gRMS; layout (location = 4) out uvec3 gID; +layout (location = 5) out vec3 gEmittedColor; in vec3 vertex; // Позиция вершины в пространстве in vec3 N; // Нормаль трансформированноая @@ -24,9 +26,11 @@ in vec3 T; // Касательный вектор in vec3 B; // Бикасательный вектор in vec3 view; // Вектор от поверхности к камере -uniform sampler2D tex_diffuse; -uniform sampler2D tex_ambient; +uniform sampler2D tex_albedo; +uniform sampler2D tex_roughness; +uniform sampler2D tex_metallic; uniform sampler2D tex_specular; +uniform sampler2D tex_emitted; uniform sampler2D tex_heights; uniform sampler2D tex_normal; @@ -98,14 +102,16 @@ void main() gNormal = normalize(TBN * gNormal); // Из касательного пространства в мировые координаты } - // Сохранение диффузного цвета - gDiffuseP.rgb = texture(tex_diffuse, new_texCoord).rgb * kd; - // Сохранение глянцевости - gDiffuseP.a = p; - // Сохранение фоновой составляющей - gAmbientSpecular.rgb = texture(tex_ambient, new_texCoord).rgb * ka; - // Сохранение зеркальной составляющей - gAmbientSpecular.a = texture(tex_specular, new_texCoord).r * ks.r; + // Сохранение базового цвета + gBaseColor.rgb = base_color.r<0?texture(tex_albedo, new_texCoord).rgb:base_color; + // Сохранение шероховатости + gRMS.r = roughness<0?texture(tex_roughness, new_texCoord).r:roughness; + // Сохранение металличности + gRMS.g = metallic<0?texture(tex_metallic, new_texCoord).r:metallic; + // Сохранение интенсивности блика диэлектриков + gRMS.b = specular<0?texture(tex_specular, new_texCoord).r:specular; // Сохранение идентификатора объекта gID = ID; + // Сохранение излучаемого света + gEmittedColor.rgb = emitted.r<0?texture(tex_emitted, new_texCoord).rgb:emitted; } \ No newline at end of file diff --git a/shaders/gshader.vert b/shaders/gshader.vert index b0b919f..1b070e3 100644 --- a/shaders/gshader.vert +++ b/shaders/gshader.vert @@ -15,10 +15,11 @@ layout(std140, binding = 0) uniform Camera layout(std140, binding = 1) uniform Material { - vec3 ka; - vec3 kd; - vec3 ks; - float p; + vec3 base_color; + float roughness; + float metallic; + float specular; + vec3 emitted; bool normalmapped; bool parallaxmapped; bool displacementmapped;