diff --git a/include/spica.h b/include/spica.h index ed0de2e..0e12695 100644 --- a/include/spica.h +++ b/include/spica.h @@ -9,6 +9,7 @@ #include "../sources/core/engine.h" #include "../sources/core/path.h" #include "../sources/core/timer.h" +#include "../sources/core/memory.h" #include "../sources/core/sampling.h" #include "../sources/core/spica_dirs.h" #include "../sources/core/point2d.h" @@ -85,7 +86,7 @@ #include "../sources/texture/spica_texture.h" // -------------------------------------------- -// Textures +// Materials // -------------------------------------------- #include "../sources/material/spica_material.h" diff --git a/sources/bxdf/bsdf.cc b/sources/bxdf/bsdf.cc index b068b07..e730504 100644 --- a/sources/bxdf/bsdf.cc +++ b/sources/bxdf/bsdf.cc @@ -7,6 +7,7 @@ #include "../math/vect_math.h" #include "bxdf.h" +#include "fresnel.h" namespace spica { diff --git a/sources/bxdf/bsdf.h b/sources/bxdf/bsdf.h index 240caf7..d3c78ff 100644 --- a/sources/bxdf/bsdf.h +++ b/sources/bxdf/bsdf.h @@ -16,7 +16,7 @@ namespace spica { -class BSDF { +class SPICA_EXPORTS BSDF { public: // Public methods BSDF(const SurfaceInteraction& isect, double eta = 1.0); diff --git a/sources/bxdf/bssrdf.h b/sources/bxdf/bssrdf.h index 05c8978..38cf4de 100644 --- a/sources/bxdf/bssrdf.h +++ b/sources/bxdf/bssrdf.h @@ -54,8 +54,8 @@ class SPICA_EXPORTS SeparableBSSRDF : public BSSRDF { protected: // Protected methods + virtual Spectrum Sp(const SurfaceInteraction& pi) const; Spectrum Sw(const Vector3d& w) const; - Spectrum Sp(const SurfaceInteraction& pi) const; Spectrum sampleSp(const Scene& scene, double rand1, const Point2d& rand2, MemoryArena& arena, SurfaceInteraction* pi, double* pdf) const; diff --git a/sources/bxdf/bxdf.h b/sources/bxdf/bxdf.h index 8fb2829..7ca8f97 100644 --- a/sources/bxdf/bxdf.h +++ b/sources/bxdf/bxdf.h @@ -11,6 +11,7 @@ #include "../core/forward_decl.h" #include "../core/uncopyable.h" #include "../core/spectrum.h" +#include "fresnel.h" namespace spica { @@ -45,9 +46,6 @@ class SPICA_EXPORTS BxDF : public Uncopyable { explicit BxDF(BxDFType type = BxDFType::None); virtual ~BxDF(); - BxDF(const BxDF&) = default; - BxDF& operator=(const BxDF&) = default; - virtual Spectrum f(const Vector3d& wo, const Vector3d& wi) const = 0; virtual Spectrum sample(const Vector3d& wo, Vector3d* wi, const Point2d& rands, double* pdf, @@ -64,7 +62,7 @@ class SPICA_EXPORTS BxDF : public Uncopyable { /** * Lambertian refrection. */ -class LambertianReflection : public BxDF { +class SPICA_EXPORTS LambertianReflection : public BxDF { public: explicit LambertianReflection(const Spectrum& ref); @@ -77,7 +75,7 @@ class LambertianReflection : public BxDF { /** * Lambertian transmission. */ -class LambertianTransmission : public BxDF { +class SPICA_EXPORTS LambertianTransmission : public BxDF { public: explicit LambertianTransmission(const Spectrum& tr); @@ -90,7 +88,7 @@ class LambertianTransmission : public BxDF { /** * Specular reflection (Metal-like effect). */ -class SpecularReflection : public BxDF { +class SPICA_EXPORTS SpecularReflection : public BxDF { public: // Public methods SpecularReflection(const Spectrum& ref, Fresnel* fresnel); @@ -109,7 +107,7 @@ class SpecularReflection : public BxDF { /** * Specular transmission. */ -class SpecularTransmission : public BxDF { +class SPICA_EXPORTS SpecularTransmission : public BxDF { public: // Public methods SpecularTransmission(const Spectrum& tr, double etaA, double etaB); @@ -130,7 +128,7 @@ class SpecularTransmission : public BxDF { /** * Fresnel specular refraction (Glass-like effect). */ -class FresnelSpecular : public BxDF { +class SPICA_EXPORTS FresnelSpecular : public BxDF { public: // Public methods FresnelSpecular(); @@ -152,7 +150,7 @@ class FresnelSpecular : public BxDF { /** * Microfacet reflaction. */ -class MicrofacetReflection : public BxDF { +class SPICA_EXPORTS MicrofacetReflection : public BxDF { public: MicrofacetReflection(const Spectrum& ref, MicrofacetDistribution* distrib, Fresnel* fresnel); @@ -170,7 +168,7 @@ class MicrofacetReflection : public BxDF { /** * Microfacet transmission. */ -class MicrofacetTransmission : public BxDF { +class SPICA_EXPORTS MicrofacetTransmission : public BxDF { public: // Public methods MicrofacetTransmission(const Spectrum& tr, diff --git a/sources/bxdf/fresnel.h b/sources/bxdf/fresnel.h index 9f986cf..0c19924 100644 --- a/sources/bxdf/fresnel.h +++ b/sources/bxdf/fresnel.h @@ -5,6 +5,7 @@ #ifndef _SPICA_FRESNEL_H_ #define _SPICA_FRESNEL_H_ +#include "../core/common.h" #include "../core/spectrum.h" namespace spica { @@ -12,7 +13,7 @@ namespace spica { /** * The inteface for Fresnel reflections. */ -class Fresnel { +class SPICA_EXPORTS Fresnel { public: virtual ~Fresnel() {} virtual Spectrum evaluate(double cosThetaI) const = 0; @@ -21,7 +22,7 @@ class Fresnel { /** * Fresnel conductor class. */ -class FresnelConductor : public Fresnel { +class SPICA_EXPORTS FresnelConductor : public Fresnel { public: FresnelConductor(const Spectrum& etaI, const Spectrum& etaT, const Spectrum& k); @@ -34,7 +35,7 @@ class FresnelConductor : public Fresnel { /** * Fresnel dielectric class. */ -class FresnelDielectric : public Fresnel { +class SPICA_EXPORTS FresnelDielectric : public Fresnel { public: FresnelDielectric(double etaI, double etaT); Spectrum evaluate(double cosThetaI) const override; @@ -46,7 +47,7 @@ class FresnelDielectric : public Fresnel { /** * Dammy Fresnel class which returns always one. */ -class FresnelNoOp : public Fresnel { +class SPICA_EXPORTS FresnelNoOp : public Fresnel { public: FresnelNoOp() {} Spectrum evaluate(double cosThetaI) const override { diff --git a/sources/core/interaction.cc b/sources/core/interaction.cc index 58bed93..5c82678 100644 --- a/sources/core/interaction.cc +++ b/sources/core/interaction.cc @@ -5,6 +5,7 @@ #include "../core/primitive.h" #include "../math/vector3d.h" #include "../bxdf/bsdf.h" +#include "../bxdf/fresnel.h" #include "../light/area_light.h" namespace spica { diff --git a/sources/integrator/integrator.cc b/sources/integrator/integrator.cc index 15f0894..5039c56 100644 --- a/sources/integrator/integrator.cc +++ b/sources/integrator/integrator.cc @@ -6,6 +6,7 @@ #include "../bxdf/bxdf.h" #include "../bxdf/bsdf.h" +#include "../bxdf/fresnel.h" #include "../camera/camera.h" #include "../image/film.h" diff --git a/sources/material/subsurface.cc b/sources/material/subsurface.cc index db566b7..bff8037 100644 --- a/sources/material/subsurface.cc +++ b/sources/material/subsurface.cc @@ -43,7 +43,6 @@ void SubsurfaceMaterial::setScatterFuncs(SurfaceInteraction* isect, double uRough = uRoughness_ ? uRoughness_->evaluate(*isect) : 0.0; double vRough = vRoughness_ ? vRoughness_->evaluate(*isect) : 0.0; - // TODO: check which method "allocate" is called. isect->setBSDF(arena.allocate(*isect, eta_)); if (re.isBlack() && tr.isBlack()) return; diff --git a/sources/texture/texture.cc b/sources/texture/texture.cc index 7821f60..5aa3f28 100644 --- a/sources/texture/texture.cc +++ b/sources/texture/texture.cc @@ -16,8 +16,8 @@ namespace spica { Point2d UVMapping2D::map(const SurfaceInteraction& intr, Vector2d* dstdx, Vector2d* dstdy) const { - *dstdx = Vector2d(su_ * intr.dudx(), sv_ * intr.dvdx()); - *dstdy = Vector2d(su_ * intr.dudy(), sv_ * intr.dvdy()); + if (dstdx) *dstdx = Vector2d(su_ * intr.dudx(), sv_ * intr.dvdx()); + if (dstdy) *dstdy = Vector2d(su_ * intr.dudy(), sv_ * intr.dvdy()); return Point2d(su_ * intr.uv()[0] + du_, sv_ * intr.uv()[1] + dv_); } diff --git a/sources/texture/texture.h b/sources/texture/texture.h index 60983a5..8ca5853 100644 --- a/sources/texture/texture.h +++ b/sources/texture/texture.h @@ -16,8 +16,9 @@ namespace spica { class SPICA_EXPORTS TextureMapping2D { public: virtual ~TextureMapping2D() {} - virtual Point2d map(const SurfaceInteraction& intr, Vector2d* dstdx, - Vector2d* dstdy) const = 0; + virtual Point2d map(const SurfaceInteraction& intr, + Vector2d* dstdx = nullptr, + Vector2d* dstdy = nullptr) const = 0; }; class UVMapping2D : public TextureMapping2D {