erebus

diff liberebus/src/rt.cc @ 46:c4d48a21bc4a

in the middle of the vmath->gph-math port
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 24 Feb 2016 00:26:50 +0200
parents ed18af9da8f7
children
line diff
     1.1 --- a/liberebus/src/rt.cc	Tue Dec 29 12:19:53 2015 +0200
     1.2 +++ b/liberebus/src/rt.cc	Wed Feb 24 00:26:50 2016 +0200
     1.3 @@ -32,16 +32,16 @@
     1.4  	const Ray &ray = hit.world_ray;
     1.5  	//bool entering = true;
     1.6  
     1.7 -	Vector3 pos = ray.origin + ray.dir * hit.dist;
     1.8 +	Vec3 pos = ray.origin + ray.dir * hit.dist;
     1.9  
    1.10 -	Vector3 norm = hit.calc_normal();
    1.11 +	Vec3 norm = hit.calc_normal();
    1.12  	if(dot_product(ray.dir, norm) > 0.0) {
    1.13  		//entering = false;
    1.14  		norm = -norm;
    1.15  	}
    1.16  
    1.17 -	//return norm * 0.5 + Vector3(0.5, 0.5, 0.5);
    1.18 -	Vector2 texcoords = hit.calc_texcoords();
    1.19 +	//return norm * 0.5 + Vec3(0.5, 0.5, 0.5);
    1.20 +	Vec2 texcoords = hit.calc_texcoords();
    1.21  
    1.22  	Color color = mtl->get_attrib_color("diffuse", texcoords.x, texcoords.y);
    1.23  	Color specular = mtl->get_attrib_color("specular", texcoords.x, texcoords.y);
    1.24 @@ -52,7 +52,7 @@
    1.25  
    1.26  	/*
    1.27  	// calculate direct illumination
    1.28 -	Vector3 vdir = -ray.dir.normalized();
    1.29 +	Vec3 vdir = -ray.dir.normalized();
    1.30  	std::list<ObjectInstance> lights = scn->gen_light_list();
    1.31  	auto it = lights.cbegin();
    1.32  	while(it != lights.cend()) {
    1.33 @@ -65,11 +65,11 @@
    1.34  			continue;
    1.35  		}
    1.36  
    1.37 -		const Matrix4x4 &xform = light_node->get_matrix();
    1.38 -		const Matrix4x4 &inv_xform = light_node->get_inv_matrix();
    1.39 -		Vector3 spt = light->gen_surface_point().transformed(xform);
    1.40 +		const Mat4x4 &xform = light_node->get_matrix();
    1.41 +		const Mat4x4 &inv_xform = light_node->get_inv_matrix();
    1.42 +		Vec3 spt = light->gen_surface_point().transformed(xform);
    1.43  
    1.44 -		Vector3 ldir = spt - pos;
    1.45 +		Vec3 ldir = spt - pos;
    1.46  		if(dot_product(ldir, norm) < 0.0) {
    1.47  			continue;
    1.48  		}
    1.49 @@ -91,14 +91,14 @@
    1.50  			shadow_hit.node = inst.node;
    1.51  		}
    1.52  
    1.53 -		Vector2 tc = shadow_hit.calc_texcoords();
    1.54 +		Vec2 tc = shadow_hit.calc_texcoords();
    1.55  		Color lcol = light->mtl.get_attrib_color("emissive", tc.x, tc.y);
    1.56  
    1.57  		ldir.normalize();
    1.58  		norm.normalize();
    1.59  		float ndotl = dot_product(ldir, norm);
    1.60  
    1.61 -		Vector3 refl = ldir.reflection(norm);
    1.62 +		Vec3 refl = ldir.reflection(norm);
    1.63  		float vdotr = dot_product(vdir, refl);
    1.64  
    1.65  		Color direct = ray.energy * lcol * (color * ndotl);// + specular * pow(vdotr, shininess));
    1.66 @@ -107,7 +107,7 @@
    1.67  	}
    1.68  	*/
    1.69  
    1.70 -	Vector3 sample_dir;
    1.71 +	Vec3 sample_dir;
    1.72  	float prob = brdf->sample(SurfaceGeometry(norm), -ray.dir, &sample_dir);
    1.73  	if(randf() <= prob) {
    1.74  		Ray sample_ray;