erebus

diff liberebus/src/brdf.h @ 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 53a98c148bf8
children
line diff
     1.1 --- a/liberebus/src/brdf.h	Tue Dec 29 12:19:53 2015 +0200
     1.2 +++ b/liberebus/src/brdf.h	Wed Feb 24 00:26:50 2016 +0200
     1.3 @@ -8,26 +8,26 @@
     1.4  
     1.5  class SurfaceGeometry {
     1.6  public:
     1.7 -	Vector3 normal, tangent;
     1.8 -	Vector2 uv;
     1.9 +	Vec3 normal, tangent;
    1.10 +	Vec2 uv;
    1.11  
    1.12  	enum VecLength { unit, unknown };
    1.13  
    1.14 -	explicit SurfaceGeometry(const Vector3 &norm, VecLength st = unknown);
    1.15 -	SurfaceGeometry(const Vector3 &norm, const Vector2 &uv, VecLength st = unknown);
    1.16 -	SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, VecLength st = unknown);
    1.17 -	SurfaceGeometry(const Vector3 &norm, const Vector3 &tang, const Vector2 &uv, VecLength st = unknown);
    1.18 +	explicit SurfaceGeometry(const Vec3 &norm, VecLength st = unknown);
    1.19 +	SurfaceGeometry(const Vec3 &norm, const Vec2 &uv, VecLength st = unknown);
    1.20 +	SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, VecLength st = unknown);
    1.21 +	SurfaceGeometry(const Vec3 &norm, const Vec3 &tang, const Vec2 &uv, VecLength st = unknown);
    1.22  
    1.23  	/** create a cartesian direction vector in sample space (zenith = +Z) and
    1.24  	 * transform it to world space.
    1.25  	 * \param theta the horizontal angle (azimuth, in radians) around the Z axis [0, 2pi]
    1.26  	 * \param phi the vertical angle (elevation, in radians) away from the Z axis [0, pi]
    1.27  	 */
    1.28 -	Vector3 spherical_to_world(float theta, float phi) const;
    1.29 +	Vec3 spherical_to_world(float theta, float phi) const;
    1.30  	/// transforms a direction vector from sample space (centered around Z) to world space
    1.31 -	Vector3 sample_to_world(const Vector3 &v) const;
    1.32 +	Vec3 sample_to_world(const Vec3 &v) const;
    1.33  	/// transforms a direction vector from world space to sample space (centered around Z)
    1.34 -	Vector3 world_to_sample(const Vector3 &v) const;
    1.35 +	Vec3 world_to_sample(const Vec3 &v) const;
    1.36  };
    1.37  
    1.38  /// abstract bidirection reflectance distribution function base class
    1.39 @@ -44,14 +44,14 @@
    1.40  	const Material *get_material() const;
    1.41  
    1.42  	/// given an outgoing light direction generate an incidence direction to sample the BRDF
    1.43 -	virtual Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const = 0;
    1.44 +	virtual Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const = 0;
    1.45  	/// given an outgoing direction, generate an incidence direction, and evaluate its probability
    1.46 -	virtual float sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const;
    1.47 +	virtual float sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const;
    1.48  	/// given an outgoing direction and an incidence direction, evaluate the probability of this path
    1.49 -	virtual float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const = 0;
    1.50 +	virtual float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const = 0;
    1.51  };
    1.52  
    1.53 -typedef float (*CompReflWeightFunc)(const SurfaceGeometry &geom, const Vector3 &outdir);
    1.54 +typedef float (*CompReflWeightFunc)(const SurfaceGeometry &geom, const Vec3 &outdir);
    1.55  
    1.56  /// composite BRDF, with multiple weighted sub-reflectances.
    1.57  class CompositeRefl : public Reflectance {
    1.58 @@ -64,7 +64,7 @@
    1.59  	std::vector<SubRefl> sub_brdf;
    1.60  	mutable bool valid_checked;
    1.61  
    1.62 -	int pick_brdf(const SurfaceGeometry &geom, const Vector3 &outdir) const;
    1.63 +	int pick_brdf(const SurfaceGeometry &geom, const Vec3 &outdir) const;
    1.64  
    1.65  public:
    1.66  	CompositeRefl();
    1.67 @@ -75,30 +75,30 @@
    1.68  
    1.69  	bool check_valid() const;
    1.70  
    1.71 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    1.72 -	float sample(const SurfaceGeometry &geom, const Vector3 &outdir, Vector3 *indir) const override;
    1.73 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    1.74 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    1.75 +	float sample(const SurfaceGeometry &geom, const Vec3 &outdir, Vec3 *indir) const override;
    1.76 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    1.77  };
    1.78  
    1.79  /// lambertian perfect diffuse reflectance
    1.80  class LambertRefl : public Reflectance {
    1.81  public:
    1.82 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    1.83 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    1.84 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    1.85 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    1.86  };
    1.87  
    1.88  /// perfect specular reflectance
    1.89  class MirrorRefl : public Reflectance {
    1.90  public:
    1.91 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
    1.92 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
    1.93 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
    1.94 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
    1.95  };
    1.96  
    1.97  /// glossy phong reflectance with lafortune sampling
    1.98  class PhongRefl : public Reflectance {
    1.99  public:
   1.100 -	Vector3 sample_dir(const SurfaceGeometry &geom, const Vector3 &outdir) const override;
   1.101 -	float eval(const SurfaceGeometry &geom, const Vector3 &outdir, const Vector3 &indir) const override;
   1.102 +	Vec3 sample_dir(const SurfaceGeometry &geom, const Vec3 &outdir) const override;
   1.103 +	float eval(const SurfaceGeometry &geom, const Vec3 &outdir, const Vec3 &indir) const override;
   1.104  };
   1.105  
   1.106  #endif	// BRDF_H_