36#define AMBIENT_FACTOR (1.0f / 6.0f)
37#define SPECULAR_FACTOR 1.0f
60 float aShinness,
float aTransparency,
float aReflection )
62 wxASSERT( aReflection >= 0.0f );
63 wxASSERT( aReflection <= 1.0f );
65 wxASSERT( aTransparency >= 0.0f );
66 wxASSERT( aTransparency <= 1.0f );
68 wxASSERT( aShinness >= 0.0f );
69 wxASSERT( aShinness <= 180.0f );
94 aNormal = glm::normalize( aNormal );
103 float aShadowAttenuationFactor )
const
105 wxASSERT( NdotL >= FLT_EPSILON );
109 if( aShadowAttenuationFactor > FLT_EPSILON )
113 const SFVEC3F diffuse = NdotL * aLightColor;
116 const SFVEC3F H = glm::normalize( aDirToLight - aRay.
m_Dir );
119 const float NdotH = glm::dot(
H, aHitInfo.
m_HitNormal );
120 const float intensitySpecular = glm::pow( glm::max( NdotH, 0.0f ),
m_reflectivity );
123 aShadowAttenuationFactor * ( diffuse * aDiffuseObjColor +
SPECULAR_FACTOR *
141 m_scale = ( 2.0f * glm::pi<float>() ) / aScale;
152 const float x = glm::sin( glm::sin( hitPos.x ) * 1.5f ) * 0.06f;
153 const float y = glm::sin( glm::sin( hitPos.y ) * 1.5f ) * 0.03f;
154 const float z = -(x + y) + glm::sin( hitPos.z ) * 0.06f;
160 return (
SFVEC3F( noise1, noise2, -( noise3 ) ) * 0.3f +
SFVEC3F( x, y, z ) );
181 hitPos.y + boardNormal.x ) - 0.5f ) * 2.0f;
183 float scratchPattern =
186 const float x = scratchPattern * 0.14f;
187 const float y = (noise + noise * scratchPattern) * 0.14f;
189 return SFVEC3F( x, y, - ( x + y ) ) + boardNormal * 0.25f;
210 return copperNormal * 0.05f;
226 return SFVEC3F( noise1, noise2, 0.0f ) * 0.1f;
241 hitPos.z * 1.2f ) - 0.5f;
244 hitPos.z * 1.5f ) - 0.5f;
247 hitPos.z * 1.8f ) - 0.5f;
249 const float distanceReduction = 1.0f / ( aHitInfo.
m_tHit + 0.5f );
251 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( distanceReduction );
266 hitPos.z * 0.01f ) - 0.5f;
269 hitPos.z * 1.6f ) - 0.5f;
272 hitPos.z * 1.0f ) - 0.5f;
273 noise3 = noise3 * noise3 * noise3;
275 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( 0.1f, 0.2f, 1.0f );
290 hitPos.z * 1.2f ) - 0.5f;
293 hitPos.z * 1.5f ) - 0.5f;
296 hitPos.z * 1.0f ) - 0.5f;
298 return SFVEC3F( noise1 * 0.15f + noise3 * 0.35f, noise2 * 0.25f, noise1 * noise2 * noise3 );
312 const float noise1 =
s_perlinNoise.
noise( hitPos.x * 2.0f, hitPos.y * 2.0f, hitPos.z );
314 const float noise2 =
s_perlinNoise.
noise( hitPos.x * 0.6f, hitPos.y * 0.6f, hitPos.z );
320 t = t * tt * tt * 100.0f;
Defines math related functions.
SFVEC3F Shade(const RAY &aRay, const HITINFO &aHitInfo, float NdotL, const SFVEC3F &aDiffuseObjColor, const SFVEC3F &aDirToLight, const SFVEC3F &aLightColor, float aShadowAttenuationFactor) const override
Shade an intersection point.
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
const MATERIAL_GENERATOR * m_board_normal_generator
A base class that can be used to derive procedurally generated materials.
virtual SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const =0
Generate a 3D vector based on the ray and hit information depending on the implementation.
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
float m_absorbance
absorbance factor for the transparent material.
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
unsigned int m_reflectionRecursionCount
static int m_defaultReflectionRayCount
static int m_defaultRefractionRayCount
static int m_defaultRefractionRecursionCount
bool m_castShadows
true if this object will block the light.
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
float m_reflection
1.0 completely reflective, 0.0 no reflective.
const MATERIAL_GENERATOR * m_generator
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
static int m_defaultFeflectionRecursionCount
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
float noise(float x, float y, float z) const
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
const MATERIAL_GENERATOR * m_copper_normal_generator
SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const override
Generate a 3D vector based on the ray and hit information depending on the implementation.
static PerlinNoise s_perlinNoise
Stores the hit information of a ray with a point on the surface of a object.
float m_tHit
( 4) distance
SFVEC3F m_HitNormal
(12) normal at the hit point
SFVEC3F m_HitPoint
(12) hit position