2015-12-08 07:31:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2016-07-19 17:35:25 +00:00
|
|
|
* Copyright (C) 2015-2016 Mario Luzeiro <mrluzeiro@ua.pt>
|
2020-12-12 17:29:11 +00:00
|
|
|
* Copyright (C) 2015-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2015-12-08 07:31:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-01-03 22:23:00 +00:00
|
|
|
* @file material.h
|
2015-12-08 07:31:57 +00:00
|
|
|
*/
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
#ifndef _MATERIAL_H_
|
|
|
|
#define _MATERIAL_H_
|
2015-12-08 07:31:57 +00:00
|
|
|
|
|
|
|
#include "ray.h"
|
|
|
|
#include "hitinfo.h"
|
2016-10-02 08:11:00 +00:00
|
|
|
#include "PerlinNoise.h"
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
/**
|
|
|
|
* A base class that can be used to derive procedurally generated materials.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class MATERIAL_GENERATOR
|
2016-09-30 23:59:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
MATERIAL_GENERATOR();
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
virtual ~MATERIAL_GENERATOR()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-09-30 23:59:51 +00:00
|
|
|
/**
|
2021-01-02 21:05:29 +00:00
|
|
|
* Generate a 3D vector based on the ray and hit information depending on the implementation.
|
2020-12-12 17:29:11 +00:00
|
|
|
*
|
|
|
|
* @param aRay the camera ray that hits the object
|
|
|
|
* @param aHitInfo the hit information
|
2016-09-30 23:59:51 +00:00
|
|
|
* @return the result of the procedural
|
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const = 0;
|
2016-09-30 23:59:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
class BOARD_NORMAL : public MATERIAL_GENERATOR
|
2016-09-30 23:59:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
BOARD_NORMAL() : MATERIAL_GENERATOR() { m_scale = 1.0f; }
|
2021-01-02 21:05:29 +00:00
|
|
|
BOARD_NORMAL( float aScale );
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~BOARD_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2016-09-30 23:59:51 +00:00
|
|
|
private:
|
|
|
|
float m_scale;
|
|
|
|
};
|
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Procedural generation of the copper normals.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class COPPER_NORMAL : public MATERIAL_GENERATOR
|
2016-09-30 23:59:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
COPPER_NORMAL() : MATERIAL_GENERATOR()
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
2021-01-02 21:05:29 +00:00
|
|
|
m_board_normal_generator = nullptr;
|
2016-10-02 08:11:00 +00:00
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
COPPER_NORMAL( float aScale, const MATERIAL_GENERATOR* aBoardNormalGenerator );
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~COPPER_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2016-09-30 23:59:51 +00:00
|
|
|
private:
|
2021-01-07 19:33:43 +00:00
|
|
|
const MATERIAL_GENERATOR* m_board_normal_generator;
|
2020-09-08 00:32:00 +00:00
|
|
|
float m_scale;
|
|
|
|
};
|
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
class PLATED_COPPER_NORMAL : public MATERIAL_GENERATOR
|
2020-09-08 00:32:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
PLATED_COPPER_NORMAL() : MATERIAL_GENERATOR()
|
2020-09-08 00:32:00 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
PLATED_COPPER_NORMAL( float aScale )
|
2020-09-08 00:32:00 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f / aScale;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~PLATED_COPPER_NORMAL()
|
2020-09-08 00:32:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
|
|
|
|
2020-09-08 00:32:00 +00:00
|
|
|
private:
|
2021-01-02 21:05:29 +00:00
|
|
|
float m_scale;
|
2016-09-30 23:59:51 +00:00
|
|
|
};
|
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Procedural generation of the solder mask.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class SOLDER_MASK_NORMAL : public MATERIAL_GENERATOR
|
2016-09-30 23:59:51 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
SOLDER_MASK_NORMAL() : MATERIAL_GENERATOR() { m_copper_normal_generator = nullptr; }
|
|
|
|
SOLDER_MASK_NORMAL( const MATERIAL_GENERATOR* aCopperNormalGenerator );
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~SOLDER_MASK_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2016-09-30 23:59:51 +00:00
|
|
|
private:
|
2021-01-07 19:33:43 +00:00
|
|
|
const MATERIAL_GENERATOR* m_copper_normal_generator;
|
2016-09-30 23:59:51 +00:00
|
|
|
};
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2016-10-02 08:11:00 +00:00
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
/**
|
|
|
|
* Procedural generation of the plastic normals.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class PLASTIC_NORMAL : public MATERIAL_GENERATOR
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
PLASTIC_NORMAL() : MATERIAL_GENERATOR()
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
PLASTIC_NORMAL( float aScale );
|
2016-10-02 08:11:00 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~PLASTIC_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2016-10-02 08:11:00 +00:00
|
|
|
private:
|
2021-01-02 21:05:29 +00:00
|
|
|
float m_scale;
|
2016-10-02 08:11:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
/**
|
|
|
|
* Procedural generation of the shiny plastic normals.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class PLASTIC_SHINE_NORMAL : public MATERIAL_GENERATOR
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
PLASTIC_SHINE_NORMAL() : MATERIAL_GENERATOR()
|
2016-10-02 08:11:00 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
PLASTIC_SHINE_NORMAL( float aScale );
|
2016-10-02 08:11:00 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~PLASTIC_SHINE_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
// Imported from MATERIAL_GENERATOR
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
|
|
|
|
2016-10-02 08:11:00 +00:00
|
|
|
private:
|
2021-01-02 21:05:29 +00:00
|
|
|
float m_scale;
|
2016-10-02 08:11:00 +00:00
|
|
|
};
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
/**
|
|
|
|
* Procedural generation of the shiny brushed metal.
|
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
class BRUSHED_METAL_NORMAL : public MATERIAL_GENERATOR
|
2016-10-02 12:16:40 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
BRUSHED_METAL_NORMAL() : MATERIAL_GENERATOR()
|
2016-10-02 12:16:40 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
BRUSHED_METAL_NORMAL( float aScale );
|
2016-10-02 12:16:40 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~BRUSHED_METAL_NORMAL()
|
2020-02-05 22:19:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2016-10-02 12:16:40 +00:00
|
|
|
private:
|
2021-01-02 21:05:29 +00:00
|
|
|
float m_scale;
|
2016-10-02 12:16:40 +00:00
|
|
|
};
|
2016-10-02 08:11:00 +00:00
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
class SILK_SCREEN_NORMAL : public MATERIAL_GENERATOR
|
2020-11-06 17:36:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
SILK_SCREEN_NORMAL() : MATERIAL_GENERATOR()
|
2020-11-06 17:36:04 +00:00
|
|
|
{
|
|
|
|
m_scale = 1.0f;
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SILK_SCREEN_NORMAL( float aScale );
|
2020-11-06 17:36:04 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~SILK_SCREEN_NORMAL()
|
2020-11-06 17:36:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
SFVEC3F Generate( const RAY& aRay, const HITINFO& aHitInfo ) const override;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2020-11-06 17:36:04 +00:00
|
|
|
private:
|
2021-01-02 21:05:29 +00:00
|
|
|
float m_scale;
|
2020-11-06 17:36:04 +00:00
|
|
|
};
|
2020-09-04 15:12:01 +00:00
|
|
|
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base material class that can be used to derive other material implementations.
|
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
class MATERIAL
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
2020-09-04 15:12:01 +00:00
|
|
|
public:
|
2021-01-07 19:33:43 +00:00
|
|
|
static void SetDefaultRefractionRayCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_defaultRefractionRayCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
2020-09-04 15:12:01 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
static void SetDefaultReflectionRayCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_defaultReflectionRayCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
2020-09-04 15:12:01 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
static void SetDefaultRefractionRecursionCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_defaultRefractionRecursionCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
static void SetDefaultReflectionRecursionCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_defaultFeflectionRecursionCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
2020-09-04 15:12:01 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
MATERIAL();
|
|
|
|
MATERIAL( const SFVEC3F& aAmbient, const SFVEC3F& aEmissive, const SFVEC3F& aSpecular,
|
2021-01-07 19:33:43 +00:00
|
|
|
float aShinness, float aTransparency, float aReflection );
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual ~MATERIAL() {}
|
2019-12-28 16:44:28 +00:00
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
const SFVEC3F& GetAmbientColor() const { return m_ambientColor; }
|
|
|
|
const SFVEC3F& GetEmissiveColor() const { return m_emissiveColor; }
|
|
|
|
const SFVEC3F& GetSpecularColor() const { return m_specularColor; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
float GetReflectivity() const { return m_reflectivity; }
|
2015-12-08 07:31:57 +00:00
|
|
|
float GetTransparency() const { return m_transparency; }
|
2016-07-19 17:35:25 +00:00
|
|
|
float GetReflection() const { return m_reflection; }
|
2017-01-21 12:30:05 +00:00
|
|
|
float GetAbsorvance() const { return m_absorbance; }
|
2021-01-07 19:33:43 +00:00
|
|
|
unsigned int GetRefractionRayCount() const { return m_refractionRayCount; }
|
|
|
|
unsigned int GetReflectionRayCount() const { return m_reflectionRayCount; }
|
|
|
|
unsigned int GetReflectionRecursionCount() const { return m_reflectionRecursionCount; }
|
|
|
|
unsigned int GetRefractionRecursionCount() const { return m_refractionRecursionCount; }
|
2017-01-21 12:30:05 +00:00
|
|
|
|
|
|
|
void SetAbsorvance( float aAbsorvanceFactor ) { m_absorbance = aAbsorvanceFactor; }
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetRefractionRayCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_refractionRayCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetReflectionRayCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_reflectionRayCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetReflectionRecursionCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_reflectionRecursionCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetRefractionRecursionCount( unsigned int aCount )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_refractionRecursionCount = aCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-12 17:29:11 +00:00
|
|
|
* Set if the material can receive shadows.
|
|
|
|
*
|
|
|
|
* @param aCastShadows true yes it can, false not it cannot
|
2016-07-19 17:35:25 +00:00
|
|
|
*/
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetCastShadows( bool aCastShadows ) { m_castShadows = aCastShadows; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
bool GetCastShadows() const { return m_castShadows; }
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/**
|
2020-12-12 17:29:11 +00:00
|
|
|
* Shade an intersection point.
|
|
|
|
*
|
|
|
|
* @param aRay the camera ray that hits the object
|
|
|
|
* @param aHitInfo the hit information
|
|
|
|
* @param NdotL the dot product between Normal and Light
|
|
|
|
* @param aDiffuseObjColor diffuse object color
|
|
|
|
* @param aDirToLight a vector of the incident light direction
|
|
|
|
* @param aLightColor the light color
|
2016-07-19 17:35:25 +00:00
|
|
|
* @param aShadowAttenuationFactor 0.0f total in shadow, 1.0f completely not in shadow
|
|
|
|
* @return the resultant color
|
|
|
|
*/
|
2021-01-02 21:05:29 +00:00
|
|
|
virtual SFVEC3F Shade( const RAY& aRay, const HITINFO& aHitInfo, float NdotL,
|
|
|
|
const SFVEC3F& aDiffuseObjColor, const SFVEC3F& aDirToLight,
|
|
|
|
const SFVEC3F& aLightColor,
|
2016-07-19 17:35:25 +00:00
|
|
|
float aShadowAttenuationFactor ) const = 0;
|
2015-12-08 07:31:57 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
void SetGenerator( const MATERIAL_GENERATOR* aGenerator )
|
2020-12-12 17:29:11 +00:00
|
|
|
{
|
2021-01-07 19:33:43 +00:00
|
|
|
m_generator = aGenerator;
|
2020-12-12 17:29:11 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
const MATERIAL_GENERATOR* GetGenerator() const { return m_generator; }
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
void Generate( SFVEC3F& aNormal, const RAY& aRay, const HITINFO& aHitInfo ) const;
|
2016-10-02 08:11:00 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
protected:
|
2015-12-10 00:31:44 +00:00
|
|
|
SFVEC3F m_ambientColor;
|
2016-07-19 17:35:25 +00:00
|
|
|
|
2015-12-08 07:31:57 +00:00
|
|
|
// NOTE: we will not use diffuse color material here,
|
|
|
|
// because it will be stored in object, since there are objects (i.e: triangles)
|
|
|
|
// that can have per vertex color
|
|
|
|
|
|
|
|
SFVEC3F m_emissiveColor;
|
|
|
|
SFVEC3F m_specularColor;
|
2021-01-07 19:33:43 +00:00
|
|
|
float m_reflectivity;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
///< 1.0 is completely transparent, 0.0 completely opaque.
|
|
|
|
float m_transparency;
|
|
|
|
float m_absorbance; ///< absorbance factor for the transparent material.
|
|
|
|
float m_reflection; ///< 1.0 completely reflective, 0.0 no reflective.
|
2021-01-07 19:33:43 +00:00
|
|
|
bool m_castShadows; ///< true if this object will block the light.
|
2020-12-12 17:29:11 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
///< Number of rays that will be interpolated for this material if it is transparent.
|
|
|
|
unsigned int m_refractionRayCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
///< Number of rays that will be interpolated for this material if it is reflective.
|
2021-01-07 19:33:43 +00:00
|
|
|
unsigned int m_reflectionRayCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
///< Number of levels it allows for refraction recursiveness.
|
2021-01-07 19:33:43 +00:00
|
|
|
unsigned int m_refractionRecursionCount;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
///< Number of levels it allows for reflection recursiveness.
|
2021-01-07 19:33:43 +00:00
|
|
|
unsigned int m_reflectionRecursionCount;
|
2016-09-30 23:59:51 +00:00
|
|
|
|
2021-01-07 19:33:43 +00:00
|
|
|
const MATERIAL_GENERATOR* m_generator;
|
2020-12-12 17:29:11 +00:00
|
|
|
|
|
|
|
private:
|
2021-01-07 19:33:43 +00:00
|
|
|
static int m_defaultRefractionRayCount;
|
|
|
|
static int m_defaultReflectionRayCount;
|
|
|
|
static int m_defaultRefractionRecursionCount;
|
|
|
|
static int m_defaultFeflectionRecursionCount;
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-07-19 17:35:25 +00:00
|
|
|
/// Blinn Phong based material
|
2015-12-08 07:31:57 +00:00
|
|
|
/// https://en.wikipedia.org/wiki/Blinn%E2%80%93Phong_shading_model
|
2021-01-02 21:05:29 +00:00
|
|
|
class BLINN_PHONG_MATERIAL : public MATERIAL
|
2015-12-08 07:31:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-02 21:05:29 +00:00
|
|
|
BLINN_PHONG_MATERIAL() : MATERIAL() {}
|
|
|
|
|
|
|
|
BLINN_PHONG_MATERIAL( const SFVEC3F& aAmbient, const SFVEC3F& aEmissive,
|
|
|
|
const SFVEC3F& aSpecular, float aShinness, float aTransparency,
|
|
|
|
float aReflection ) :
|
|
|
|
MATERIAL( aAmbient, aEmissive, aSpecular, aShinness, aTransparency, aReflection ) {}
|
|
|
|
|
|
|
|
// Imported from MATERIAL
|
|
|
|
SFVEC3F Shade( const RAY& aRay, const HITINFO& aHitInfo, float NdotL,
|
|
|
|
const SFVEC3F& aDiffuseObjColor, const SFVEC3F& aDirToLight,
|
|
|
|
const SFVEC3F& aLightColor, float aShadowAttenuationFactor ) const override;
|
2015-12-08 07:31:57 +00:00
|
|
|
};
|
|
|
|
|
2021-01-02 21:05:29 +00:00
|
|
|
#endif // _MATERIAL_H_
|