Browse Source

Make shade() understand materials

master
gradient 8 years ago
parent
commit
22e6297c7f
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      examples/test/shaders/test.frag

+ 12
- 6
examples/test/shaders/test.frag View File

@ -58,9 +58,15 @@ vec3 raymarch(vec3 o, vec3 d, float start, float end) {
return vec3(end, -1., MAX_STEPS); 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() { void main() {
@ -87,8 +93,8 @@ void main() {
return; 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);
} }

Loading…
Cancel
Save