clray

diff src/rt.cc @ 4:3c95d568d3c7

wow a ball
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 15 Jul 2010 07:37:05 +0300
parents 88ac4eb2d18a
children 9f0ddb701882
line diff
     1.1 --- a/src/rt.cc	Tue Jul 13 03:38:29 2010 +0300
     1.2 +++ b/src/rt.cc	Thu Jul 15 07:37:05 2010 +0300
     1.3 @@ -13,7 +13,9 @@
     1.4  	cl_float4 pos;
     1.5  	cl_float radius;
     1.6  
     1.7 -	cl_float4 color;
     1.8 +	cl_float4 kd, ks;
     1.9 +	cl_float spow;
    1.10 +	cl_float kr, kt;
    1.11  } __attribute__((packed));
    1.12  
    1.13  struct Ray {
    1.14 @@ -31,21 +33,27 @@
    1.15  static CLProgram *prog;
    1.16  static int global_size;
    1.17  
    1.18 +static Sphere sphlist[] = {
    1.19 +	{{0, 0, 8, 1}, 1.0, {0.7, 0.2, 0.15, 1}, {1, 1, 1, 1}, 60, 0, 0},
    1.20 +	{{-0.2, 0.4, 5, 1}, 0.25, {0.2, 0.9, 0.3, 1}, {1, 1, 1, 1}, 40, 0, 0}
    1.21 +};
    1.22 +
    1.23 +static Light lightlist[] = {
    1.24 +	{{-10, 10, -20, 1}, {1, 1, 1, 1}}
    1.25 +};
    1.26 +
    1.27 +static RendInfo rinf;
    1.28 +
    1.29 +
    1.30  bool init_renderer(int xsz, int ysz, float *fb)
    1.31  {
    1.32 -	Sphere sphlist[] = {
    1.33 -		{{0, 0, 10, 1}, 1.0, {1, 0, 0, 1}}
    1.34 -	};
    1.35 -	Light lightlist[] = {
    1.36 -		{{-10, 10, -20, 1}, {1, 1, 1, 1}}
    1.37 -	};
    1.38 -	RendInfo rinf = {
    1.39 -		xsz, ysz,
    1.40 -		sizeof sphlist / sizeof *sphlist,
    1.41 -		sizeof lightlist / sizeof *lightlist,
    1.42 -		6
    1.43 -	};
    1.44 -	
    1.45 +	// render info
    1.46 +	rinf.xsz = xsz;
    1.47 +	rinf.ysz = ysz;
    1.48 +	rinf.num_sph = sizeof sphlist / sizeof *sphlist;
    1.49 +	rinf.num_lights = sizeof lightlist / sizeof *lightlist;
    1.50 +	rinf.max_iter = 6;
    1.51 +
    1.52  	/* calculate primary rays */
    1.53  	prim_rays = new Ray[xsz * ysz];
    1.54  
    1.55 @@ -105,7 +113,9 @@
    1.56  	float py = 1.0 - ((float)y / (float)h) * ysz;
    1.57  	float pz = 1.0 / tan(0.5 * vfov);
    1.58  
    1.59 -	pz *= 1000.0;
    1.60 +	px *= 100.0;
    1.61 +	py *= 100.0;
    1.62 +	pz *= 100.0;
    1.63  
    1.64  	Ray ray = {{0, 0, 0, 1}, {px, py, pz, 1}};
    1.65  	return ray;