From: John Tsiombikas Date: Fri, 4 Dec 2020 14:25:36 +0000 (+0200) Subject: foo X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=demo_prior;a=commitdiff_plain;h=a89e74326444df1da625ad9614919bb7ad2352cb foo --- diff --git a/sdr/whitted.p.glsl b/sdr/whitted.p.glsl new file mode 100644 index 0000000..567f127 --- /dev/null +++ b/sdr/whitted.p.glsl @@ -0,0 +1,43 @@ +varying vec3 v_rorg, v_rdir; + +vec3 shade(in vec3 pos, in vec3 norm); +vec3 backdrop(in vec3 dir); +float isect_plane(in vec3 ro, in vec3 rd, out vec3 norm_ret); + +void main() +{ + vec3 rdir = normalize(v_rdir); + + float t = isect_floor(v_rorg, rdir); + if(t >= 0.0) { + gl_FragColor.rgb = shade(v_rorg + rdir * t, vec3(0.0, 1.0, 0.0)); + } else { + gl_FragColor.rgb = backdrop(rdir); + } + gl_FragColor.a = 1.0; +} + +vec3 shade(in vec3 pos, in vec3 norm) +{ +} + +vec3 backdrop(in vec3 dir) +{ +} + +float isect_floor(in vec3 ro, in vec3 rd) +{ + float t = isect_plane(ro, rd, vec4(0.0, 1.0, 0.0, -1.0)); + if(t < 0.0) return t; + + vec3 p = ro + rd * t; + float d = max(abs(p.x), max(abs(p.y), abs(p.z))); + if(d >= 1.0) return -1.0; + + return t; +} + +float isect_plane(in vec3 ro, in vec3 rd, in vec4 plane) +{ + +} diff --git a/sdr/whitted.v.glsl b/sdr/whitted.v.glsl new file mode 100644 index 0000000..ad2878e --- /dev/null +++ b/sdr/whitted.v.glsl @@ -0,0 +1,13 @@ +#define FOV 0.873 /* about 50 deg */ + +varying vec3 v_rorg, v_rdir; + +void main() +{ + gl_Position = gl_Vertex; + + float dist = 1.0 / tan(FOV / 2.0); + vec3 dir = vec3(gl_MultiTexCoord0.xy * 2.0 - 1.0, dist); + v_rdir = gl_NormalMatrix * dir; + v_rorg = (gl_ModelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz; +}