Bug fixes
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 803 KiB After Width: | Height: | Size: 336 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 336 KiB After Width: | Height: | Size: 803 KiB |
+4
-5
@@ -21,7 +21,7 @@
|
|||||||
</style>
|
</style>
|
||||||
<body bgcolor=white text=black link=black alink=blue vlink=blue>
|
<body bgcolor=white text=black link=black alink=blue vlink=blue>
|
||||||
<center>
|
<center>
|
||||||
<canvas id='canvas1' width=600 height=600></canvas>
|
<canvas id='canvas1' style="width: 600px; height:600px;" width=1200 height=1200></canvas>
|
||||||
</center>
|
</center>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
@@ -53,9 +53,8 @@ Solar RTX
|
|||||||
<!!-------- HERE IS WHERE YOU CAN PROVIDE A LONGER TEXT DESCRIPTION -------->
|
<!!-------- HERE IS WHERE YOU CAN PROVIDE A LONGER TEXT DESCRIPTION -------->
|
||||||
|
|
||||||
<script id='my_instructions' type='text/html'><font color=#909090>
|
<script id='my_instructions' type='text/html'><font color=#909090>
|
||||||
<p style="font-size:30px; ">I am implementing ray tracing<br>
|
<p style="font-size:30px; ">In this homework, I implemented Global illumination w/
|
||||||
to multiple spheres with a single<br>
|
Realtime Recursive Ray Tracing!
|
||||||
light source and Phong shading.
|
|
||||||
<p>
|
<p>
|
||||||
<i style="font-size:25px;">Here is how it works:</i>
|
<i style="font-size:25px;">Here is how it works:</i>
|
||||||
<ul>
|
<ul>
|
||||||
@@ -142,7 +141,7 @@ editor.setOptions({
|
|||||||
});
|
});
|
||||||
editor.setAutoScrollEditorIntoView(true);
|
editor.setAutoScrollEditorIntoView(true);
|
||||||
// REPARSE THE SHADER PROGRAM AFTER EVERY KEYSTROKE.
|
// REPARSE THE SHADER PROGRAM AFTER EVERY KEYSTROKE.
|
||||||
|
delete editor.KeyBinding;
|
||||||
let lastTime = Date.now();
|
let lastTime = Date.now();
|
||||||
let animating = true;
|
let animating = true;
|
||||||
let ctrl = false;
|
let ctrl = false;
|
||||||
|
|||||||
+23
-17
@@ -11,7 +11,7 @@ varying vec3 vPos;// -1 < vPos.x < +1
|
|||||||
|
|
||||||
float fl=3.;
|
float fl=3.;
|
||||||
const float pi=3.14159265359;
|
const float pi=3.14159265359;
|
||||||
const int n_ref=1;
|
const int n_ref=2;
|
||||||
const int ns=2;
|
const int ns=2;
|
||||||
vec4 Sph[ns];
|
vec4 Sph[ns];
|
||||||
uniform sampler2D uSampler[ns];
|
uniform sampler2D uSampler[ns];
|
||||||
@@ -51,13 +51,13 @@ void main(){
|
|||||||
|
|
||||||
// SURFACE REFLECTANCE PROPERTIES
|
// SURFACE REFLECTANCE PROPERTIES
|
||||||
|
|
||||||
Ambient[0]=vec3(.1,.05,.05);// r,g,b
|
Ambient[1]=vec3(.1,.05,.05);// r,g,b
|
||||||
Diffuse[0]=vec3(1.,.5,.5);// r,g,b
|
Diffuse[1]=vec3(1.,.5,.5);// r,g,b
|
||||||
Specular[0]=vec4(1.,.5,.5,10.);// r,g,b,power
|
Specular[1]=vec4(1.,.5,.5,10.);// r,g,b,power
|
||||||
|
|
||||||
Ambient[1]=vec3(.05,.05,.1);// r,g,b
|
Ambient[0]=vec3(.05,.05,.1);// r,g,b
|
||||||
Diffuse[1]=vec3(.5,.5,1.);// r,g,b
|
Diffuse[0]=vec3(.5,.5,1.);// r,g,b
|
||||||
Specular[1]=vec4(1.,.5,.5,20.);// r,g,b,power
|
Specular[0]=vec4(1.,.5,.5,20.);// r,g,b,power
|
||||||
|
|
||||||
// INITIALIZE TO A BACKGROUND COLOR
|
// INITIALIZE TO A BACKGROUND COLOR
|
||||||
|
|
||||||
@@ -121,12 +121,11 @@ void main(){
|
|||||||
Ambient[i]
|
Ambient[i]
|
||||||
+Diffuse[i]*max(0.,dot(N,realLDir))*LCol
|
+Diffuse[i]*max(0.,dot(N,realLDir))*LCol
|
||||||
)*texture_color
|
)*texture_color
|
||||||
|
|
||||||
;
|
;
|
||||||
// + SPECULAR COMPONENT GOES HERE
|
// + SPECULAR COMPONENT GOES HERE
|
||||||
if(rtxoff || j == n_ref - 1)
|
if(rtxoff || j == n_ref - 1)
|
||||||
color += Specular[i].xyz*pow(max(0.,dot(2.*dot(N,realLDir)*N-realLDir,-W)),Specular[i].w);
|
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.05);
|
stack[j] = RT(color, 0.15);
|
||||||
V = S;
|
V = S;
|
||||||
W = -normalize(2. * dot(N, W) * N - W);
|
W = -normalize(2. * dot(N, W) * N - W);
|
||||||
break;
|
break;
|
||||||
@@ -137,10 +136,12 @@ void main(){
|
|||||||
// IS INSIDE THE BOUNDING BOX [(-1,-1,-1), (1,1,1)]
|
// IS INSIDE THE BOUNDING BOX [(-1,-1,-1), (1,1,1)]
|
||||||
// AND THERE'S A INFINITE FLOOR [y = -1]
|
// AND THERE'S A INFINITE FLOOR [y = -1]
|
||||||
|
|
||||||
float t = -(1.+V.y)/W.y;
|
float t = -(.2+V.y)/W.y;
|
||||||
if(t >= 0.)
|
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);
|
vec3 realLDir=normalize(LDir - S);
|
||||||
color=(
|
color=(
|
||||||
0.5
|
0.5
|
||||||
@@ -149,16 +150,21 @@ void main(){
|
|||||||
;
|
;
|
||||||
// + SPECULAR COMPONENT GOES HERE
|
// + SPECULAR COMPONENT GOES HERE
|
||||||
if(rtxoff || j == n_ref - 1)
|
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);
|
pow(max(0., dot(vec3(-realLDir.x, realLDir.y,-realLDir.z),-W)),groundSpecular.w);
|
||||||
stack[j] = RT(color, 0.1);
|
stack[j] = RT(color, 0.1);
|
||||||
V = S;
|
V = S;
|
||||||
W = vec3(-W.x, W.y, -W.z);
|
W = vec3(W.x, -W.y, W.z);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(j > 0)
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user