summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authoromnisci3nce <omniscient.oce@gmail.com>2024-07-18 12:03:15 +1000
committeromnisci3nce <omniscient.oce@gmail.com>2024-07-18 12:03:15 +1000
commit4d198fe4f5cbe9e022776bdbd0bd8ec8094c8953 (patch)
tree4fbbf2feba811ded8923bd964f940f1c71c78c0d /assets
parentc3737fff1be704e14a2bada69bbf8a6709c5f670 (diff)
draw pbr container
Diffstat (limited to 'assets')
-rw-r--r--assets/shaders/pbr_textured.frag8
-rw-r--r--assets/shaders/pbr_textured.vert5
2 files changed, 10 insertions, 3 deletions
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);
}