%COMP 256 Assignment 1 %Adrian Ilie % toy problem clear; % make the height map and albedo map. width = 128; height = 128; width2 = 64; height2 = 64; heights=zeros(height,width); albedo=zeros(height,width); for i=1:height for j=1:width ip=((height2-i)*(height2-i))+((width2-j)*(width2-j)); h=width2*height2-ip; if h>0 heights(i,j)=sqrt(h); if ((height2-i)*(width2-j)>0) albedo(i,j)=1; else albedo(i,j)=0.5; end end end end [Nx,Ny,Nz]=surfnorm(heights); normalbedo = [Nx(:).*albedo(:) Ny(:).*albedo(:) Nz(:).*albedo(:)]; lightdirs = [0 0 1 0 0.34202 0.93969 0 0.70711 0.70711 0 1 0 0 -0.34202 0.93969 0 -0.57358 0.81915 0.085832 0.17365 0.98106 0.085832 -0.17365 0.98106 0.17365 0 0.98481 0.16318 -0.34202 0.92542 0.24321 0.34202 0.90767 0.33682 0.17365 0.92542 0.33682 -0.17365 0.92542 0.262 -0.64279 0.71985 0.42262 0 0.90631 0.55403 0.25882 0.79124 0.43939 0.64279 0.62751 0.2424 0.90631 0.34619 0.53899 -0.34202 0.76975 0.76604 0 0.64279 0.8138 0.34202 0.46985 0.8138 -0.34202 0.46985 0.93969 0 0.34202 0.66446 0.70711 0.24184 0.76975 -0.57358 0.28017 0.93612 0.34202 0.0819 0.93612 -0.34202 0.0819 0.99619 0 -0.087156 0.90767 0.25882 -0.33037 0.71985 0.64279 -0.262 0.39713 0.90631 -0.14454 0.88302 -0.34202 -0.32139 0.86603 0 -0.5 0.71985 0.34202 -0.60402 -0.085832 0.17365 0.98106 -0.085832 -0.17365 0.98106 -0.17365 0 0.98481 -0.16318 -0.34202 0.92542 -0.24321 0.34202 0.90767 -0.33682 0.17365 0.92542 -0.33682 -0.17365 0.92542 -0.262 -0.64279 0.71985 -0.42262 0 0.90631 -0.55403 0.25882 0.79124 -0.43939 0.64279 0.62751 -0.2424 0.90631 0.34619 -0.53899 -0.34202 0.76975 -0.76604 0 0.64279 -0.58682 -0.64279 0.4924 -0.8138 0.34202 0.46985 -0.8138 -0.34202 0.46985 -0.93969 0 0.34202 -0.66446 0.70711 0.24184 -0.76975 -0.57358 0.28017 -0.93612 0.34202 0.0819 -0.93612 -0.34202 0.0819 -0.99619 0 -0.087156 -0.90767 0.25882 -0.33037 -0.71985 0.64279 -0.262 -0.39713 0.90631 -0.14454 -0.88302 -0.34202 -0.32139 -0.86603 0 -0.5 -0.71985 0.34202 -0.60402]'; ims = (normalbedo*lightdirs); Nimages = size(lightdirs); Nimages=Nimages(2); imarray=reshape(ims,height,width,Nimages); %scale to 0..255 and divide by 255 for i = 1:(Nimages) img = imarray(:,:,i); img = img/255; imarray(:,:,i)=img; end process; pause; finalize;