From 4d198fe4f5cbe9e022776bdbd0bd8ec8094c8953 Mon Sep 17 00:00:00 2001 From: omnisci3nce Date: Thu, 18 Jul 2024 12:03:15 +1000 Subject: draw pbr container --- assets/shaders/pbr_textured.frag | 8 +++++--- assets/shaders/pbr_textured.vert | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'assets') diff --git a/assets/shaders/pbr_textured.frag b/assets/shaders/pbr_textured.frag index e76a099..5353fa7 100644 --- a/assets/shaders/pbr_textured.frag +++ b/assets/shaders/pbr_textured.frag @@ -6,6 +6,8 @@ in vec3 fragWorldPos; in vec3 fragNormal; in vec2 fragTexCoords; +in vec4 viewPos; + struct PointLight { vec4 position; vec4 color; @@ -15,11 +17,11 @@ struct PointLight { // Lights data #define NUM_POINT_LIGHTS 4 -uniform Scene_Lights { +uniform Lights { PointLight pointLights[NUM_POINT_LIGHTS]; - vec4 viewPos; } scene; + // Material Textures uniform sampler2D albedoMap; uniform sampler2D metallicRoughnessMap; @@ -62,7 +64,7 @@ void main() { // vec3 norm = normalize(fragNormal); // N vec3 norm = getNormalFromMap(); vec3 N = norm; - vec3 viewDir = normalize(vec3(scene.viewPos) - fragWorldPos); // V + vec3 viewDir = normalize(vec3(viewPos) - fragWorldPos); // V vec3 V = viewDir; vec3 F0 = vec3(0.04); diff --git a/assets/shaders/pbr_textured.vert b/assets/shaders/pbr_textured.vert index 391cef3..2021691 100644 --- a/assets/shaders/pbr_textured.vert +++ b/assets/shaders/pbr_textured.vert @@ -8,6 +8,7 @@ layout(location = 2) in vec2 inTexCoords; uniform Camera { mat4 view; mat4 proj; + vec4 viewPos; } cam; uniform Model { @@ -19,10 +20,14 @@ layout(location = 0) out vec3 fragWorldPos; layout(location = 1) out vec3 fragNormal; layout(location = 2) out vec2 fragTexCoords; +out vec4 viewPos; + void main() { fragWorldPos = vec3(model.inner * vec4(inPosition, 1.0)); fragNormal = mat3(transpose(inverse(model.inner))) * inNormal; // world-space normal fragTexCoords = inTexCoords; + viewPos = cam.viewPos; + gl_Position = cam.proj * cam.view * model.inner * vec4(inPosition, 1.0); } -- cgit v1.2.3-70-g09d2