From 22e6297c7fe483092cda8c26e6d839fc80155592 Mon Sep 17 00:00:00 2001 From: gradient Date: Mon, 29 May 2017 23:07:43 -0500 Subject: [PATCH] Make shade() understand materials --- examples/test/shaders/test.frag | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/test/shaders/test.frag b/examples/test/shaders/test.frag index f7f8768..d261ad7 100644 --- a/examples/test/shaders/test.frag +++ b/examples/test/shaders/test.frag @@ -58,9 +58,15 @@ vec3 raymarch(vec3 o, vec3 d, float start, float end) { return vec3(end, -1., MAX_STEPS); } -vec4 shade(vec3 p) { - vec3 normal = estimate_scene_normal(p); - return vec4((normal + vec3(1.0))/2.0, 1.0); +vec4 shade_material(vec3 p, vec3 norm, float mat_idx) { + return vec4(1.); +} + +vec4 shade(vec3 p, float mat_idx) { + vec3 norm = estimate_scene_normal(p); + vec4 color_mat = shade_material(p, norm, mat_idx); + + return color_mat; } void main() { @@ -87,8 +93,8 @@ void main() { return; } - color = colormap(iters/MAX_STEPS+0.5); - vec3 p = eye + dir * depth; - color = shade(p); + // color = colormap(iters/MAX_STEPS+0.5); + vec3 p = eye + dir * depth; // recast the ray + color = shade(p, mat_idx); }