master
bill 3 years ago
parent 834bbea250
commit f7eb9cb123

BIN
1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 803 KiB

After

Width:  |  Height:  |  Size: 336 KiB

BIN
2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 KiB

After

Width:  |  Height:  |  Size: 803 KiB

@ -21,7 +21,7 @@
</style>
<body bgcolor=white text=black link=black alink=blue vlink=blue>
<center>
<canvas id='canvas1' width=600 height=600></canvas>
<canvas id='canvas1' style="width: 600px; height:600px;" width=1200 height=1200></canvas>
</center>
</body>
@ -53,9 +53,8 @@ Solar RTX
<!!-------- HERE IS WHERE YOU CAN PROVIDE A LONGER TEXT DESCRIPTION -------->
<script id='my_instructions' type='text/html'><font color=#909090>
<p style="font-size:30px; ">I am implementing ray tracing<br>
to multiple spheres with a single<br>
light source and Phong shading.
<p style="font-size:30px; ">In this homework, I implemented Global illumination w/
Realtime Recursive Ray Tracing!
<p>
<i style="font-size:25px;">Here is how it works:</i>
<ul>
@ -142,7 +141,7 @@ editor.setOptions({
});
editor.setAutoScrollEditorIntoView(true);
// REPARSE THE SHADER PROGRAM AFTER EVERY KEYSTROKE.
delete editor.KeyBinding;
let lastTime = Date.now();
let animating = true;
let ctrl = false;

@ -11,7 +11,7 @@ varying vec3 vPos;// -1 < vPos.x < +1
float fl=3.;
const float pi=3.14159265359;
const int n_ref=1;
const int n_ref=2;
const int ns=2;
vec4 Sph[ns];
uniform sampler2D uSampler[ns];
@ -51,13 +51,13 @@ void main(){
// SURFACE REFLECTANCE PROPERTIES
Ambient[0]=vec3(.1,.05,.05);// r,g,b
Diffuse[0]=vec3(1.,.5,.5);// r,g,b
Specular[0]=vec4(1.,.5,.5,10.);// r,g,b,power
Ambient[1]=vec3(.1,.05,.05);// r,g,b
Diffuse[1]=vec3(1.,.5,.5);// r,g,b
Specular[1]=vec4(1.,.5,.5,10.);// r,g,b,power
Ambient[1]=vec3(.05,.05,.1);// r,g,b
Diffuse[1]=vec3(.5,.5,1.);// r,g,b
Specular[1]=vec4(1.,.5,.5,20.);// r,g,b,power
Ambient[0]=vec3(.05,.05,.1);// r,g,b
Diffuse[0]=vec3(.5,.5,1.);// r,g,b
Specular[0]=vec4(1.,.5,.5,20.);// r,g,b,power
// INITIALIZE TO A BACKGROUND COLOR
@ -121,12 +121,11 @@ void main(){
Ambient[i]
+Diffuse[i]*max(0.,dot(N,realLDir))*LCol
)*texture_color
;
// + SPECULAR COMPONENT GOES HERE
if(rtxoff || j == n_ref - 1)
color += Specular[i].xyz*pow(max(0.,dot(2.*dot(N,realLDir)*N-realLDir,-W)),Specular[i].w);
stack[j] = RT(color, 0.05);
color += float(j) * Specular[i].xyz*pow(max(0.,dot(2.*dot(N,realLDir)*N-realLDir,-W)),Specular[i].w);
stack[j] = RT(color, 0.15);
V = S;
W = -normalize(2. * dot(N, W) * N - W);
break;
@ -137,10 +136,12 @@ void main(){
// IS INSIDE THE BOUNDING BOX [(-1,-1,-1), (1,1,1)]
// AND THERE'S A INFINITE FLOOR [y = -1]
float t = -(1.+V.y)/W.y;
if(t >= 0.)
float t = -(.2+V.y)/W.y;
float sx = V.x + t* W.x, sz = V.z + t * W.z;
if(t >= 0.&&abs(sx)<1.5 && abs(sz+.6)<3.)
{
vec3 S = vec3(V.x + t*W.x, -1, V.z + t*W.z);
vec3 S = vec3(sx, -.2, sz);
vec3 realLDir=normalize(LDir - S);
color=(
0.5
@ -149,16 +150,21 @@ void main(){
;
// + SPECULAR COMPONENT GOES HERE
if(rtxoff || j == n_ref - 1)
color += groundSpecular.xyz*
color += float(j)*groundSpecular.xyz*
pow(max(0., dot(vec3(-realLDir.x, realLDir.y,-realLDir.z),-W)),groundSpecular.w);
stack[j] = RT(color, 0.1);
V = S;
W = vec3(-W.x, W.y, -W.z);
W = vec3(W.x, -W.y, W.z);
}
else{
if(j > 0)
stack[j] = RT(vec3(1.,1.,1.)*pow(max(0.,dot(-W, normalize(LDir - V))), 10.), 1.);
cnt_ref = j;// + 1;
{
stack[j] = RT(vec3(12.,12.,12.)*pow(max(0.,dot(W, normalize(LDir - V))), 10.), 0.);
cnt_ref = j + 1;
}
else
cnt_ref = j;
break;
}
}

Loading…
Cancel
Save