summaryrefslogtreecommitdiff
path: root/intermediate
diff options
context:
space:
mode:
Diffstat (limited to 'intermediate')
-rw-r--r--intermediate/forward.h44
-rw-r--r--intermediate/surface.glsl36
2 files changed, 51 insertions, 29 deletions
diff --git a/intermediate/forward.h b/intermediate/forward.h
new file mode 100644
index 0000000..7c4c9d3
--- /dev/null
+++ b/intermediate/forward.h
@@ -0,0 +1,44 @@
+#ifndef forward_h
+#define forward_h
+#ifdef DESC
+
+[struct]
+name: Light
+[variable]
+name: dir
+type: vec3
+[variable]
+name: brightness
+type: float
+[variable]
+name: colour
+type: vec3
+[variable]
+name: caster_id
+type: int
+
+[struct]
+name: Caster
+[variable]
+name: projection
+type: mat4
+
+[struct]
+name: Globals
+[variable]
+name: camera_pos
+type: vec3
+[variable]
+name: light_count
+type: int
+[variable]
+name: frame
+type: int
+
+[cbuffer]
+name: globals
+type: Globals
+stage: fragment
+
+#endif
+#endif
diff --git a/intermediate/surface.glsl b/intermediate/surface.glsl
index 10944ae..71a4307 100644
--- a/intermediate/surface.glsl
+++ b/intermediate/surface.glsl
@@ -3,6 +3,11 @@
type: graphics
vertex: main
fragment: main
+#endif
+
+#include "forward.h"
+
+#ifdef DESC
[binding]
name: mesh
@@ -56,33 +61,6 @@ type: float
[variable]
name: ao
type: float
-[variable]
-name: light_count
-type: int
-[variable]
-name: camera_pos
-type: vec3
-
-[struct]
-name: Light
-[variable]
-name: dir
-type: vec3
-[variable]
-name: brightness
-type: float
-[variable]
-name: colour
-type: vec3
-[variable]
-name: caster_id
-type: int
-
-[struct]
-name: Caster
-[variable]
-name: projection
-type: mat4
[cbuffer]
name: c_vp
@@ -251,7 +229,7 @@ void main() {
nrm = normalize(interpolator.tbn * nrm);
vec3 col = texture(albedo, uv).rgb * material.albedo;
- vec3 view_dir = normalize(material.camera_pos - p);
+ vec3 view_dir = normalize(globals.camera_pos - p);
float met = texture(metal, uv).r * material.metalness;
vec3 ref = reflect(-view_dir, nrm);
vec3 ref_col = texture(env_cube, ref, material.roughness * 8.0).rgb;
@@ -264,7 +242,7 @@ void main() {
vec3 base_diffuse = diffuse_brdf(uv) * (1.0 - met);
vec3 light = 0.0.xxx;
- for (i = 0; i < material.light_count; i++) {
+ for (i = 0; i < globals.light_count; i++) {
Light l = lights[i];
vec3 light_dir = l.dir;
float cos_theta_i = max(dot(nrm, light_dir), 0.0);