40 #define AMBIENT_FACTOR (1.0f / 6.0f) 41 #define SPECULAR_FACTOR 1.0f 64 float aShinness,
float aTransparency,
float aReflection )
66 wxASSERT( aReflection >= 0.0f );
67 wxASSERT( aReflection <= 1.0f );
69 wxASSERT( aTransparency >= 0.0f );
70 wxASSERT( aTransparency <= 1.0f );
72 wxASSERT( aShinness >= 0.0f );
73 wxASSERT( aShinness <= 180.0f );
98 aNormal = glm::normalize( aNormal );
107 float aShadowAttenuationFactor )
const 109 wxASSERT( NdotL >= FLT_EPSILON );
113 if( aShadowAttenuationFactor > FLT_EPSILON )
117 const SFVEC3F diffuse = NdotL * aLightColor;
120 const SFVEC3F H = glm::normalize( aDirToLight - aRay.
m_Dir );
123 const float NdotH = glm::dot(
H, aHitInfo.
m_HitNormal );
124 const float intensitySpecular = glm::pow( glm::max( NdotH, 0.0f ),
m_reflectivity );
127 aShadowAttenuationFactor * ( diffuse * aDiffuseObjColor +
SPECULAR_FACTOR *
145 m_scale = ( 2.0f * glm::pi<float>() ) / aScale;
156 const float x = glm::sin( glm::sin( hitPos.x ) * 1.5f ) * 0.06f;
157 const float y = glm::sin( glm::sin( hitPos.y ) * 1.5f ) * 0.03f;
158 const float z = -(x + y) + glm::sin( hitPos.z ) * 0.06f;
164 return (
SFVEC3F( noise1, noise2, -( noise3 ) ) * 0.3f +
SFVEC3F( x, y, z ) );
185 hitPos.y + boardNormal.x ) - 0.5f ) * 2.0f;
187 float scratchPattern =
190 const float x = scratchPattern * 0.14f;
191 const float y = (noise + noise * scratchPattern) * 0.14f;
193 return SFVEC3F( x, y, - ( x + y ) ) + boardNormal * 0.25f;
214 return copperNormal * 0.05f;
230 return SFVEC3F( noise1, noise2, -( noise1 + noise2 ) ) * 0.02f;
245 hitPos.z * 1.2f ) - 0.5f;
248 hitPos.z * 1.5f ) - 0.5f;
251 hitPos.z * 1.8f ) - 0.5f;
253 const float distanceReduction = 1.0f / ( aHitInfo.
m_tHit + 0.5f );
255 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( distanceReduction );
270 hitPos.z * 0.01f ) - 0.5f;
273 hitPos.z * 1.6f ) - 0.5f;
276 hitPos.z * 1.0f ) - 0.5f;
277 noise3 = noise3 * noise3 * noise3;
279 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( 0.1f, 0.2f, 1.0f );
294 hitPos.z * 1.2f ) - 0.5f;
297 hitPos.z * 1.5f ) - 0.5f;
300 hitPos.z * 1.0f ) - 0.5f;
302 return SFVEC3F( noise1 * 0.15f + noise3 * 0.35f, noise2 * 0.25f, noise1 * noise2 * noise3 );
316 const float noise1 =
s_perlinNoise.
noise( hitPos.x * 2.7f, hitPos.y * 2.6f, hitPos.z );
318 const float noise2 =
s_perlinNoise.
noise( hitPos.x * 1.1f, hitPos.y * 1.2f, hitPos.z );
321 glm::abs( ( 1.8f / (
SFVEC3F( noise1, noise2, hitPos.z ) + 0.4f ) ) - 1.5f ) - 0.25f;
322 t = t * t * t * 0.1f;
float m_reflection
1.0 completely reflective, 0.0 no reflective.
bool m_castShadows
true if this object will block the light.
void Generate(SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
static int m_defaultReflectionRayCount
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 m_tHit
( 4) distance
static int m_defaultFeflectionRecursionCount
SFVEC3F m_HitPoint
(12) hit position
unsigned int m_reflectionRecursionCount
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
A base class that can be used to derive procedurally generated materials.
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
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_generator
static int m_defaultRefractionRecursionCount
static PerlinNoise s_perlinNoise
const MATERIAL_GENERATOR * m_copper_normal_generator
static int m_defaultRefractionRayCount
Stores the hit information of a ray with a point on the surface of a object.
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.
const MATERIAL_GENERATOR * m_board_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.
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.
Defines math related functions.
float m_absorbance
absorbance factor for the transparent material.
SFVEC3F m_HitNormal
(12) normal at the hit point
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
float noise(float x, float y, float z) const
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.