32#define AMBIENT_FACTOR (1.0f / 6.0f)
33#define SPECULAR_FACTOR 1.0f
56 float aShinness,
float aTransparency,
float aReflection )
58 wxASSERT( aReflection >= 0.0f );
59 wxASSERT( aReflection <= 1.0f );
61 wxASSERT( aTransparency >= 0.0f );
62 wxASSERT( aTransparency <= 1.0f );
64 wxASSERT( aShinness >= 0.0f );
90 aNormal = aNormal +
m_generator->Generate( aRay, aHitInfo );
91 aNormal = glm::normalize( aNormal );
100 float aShadowAttenuationFactor )
const
102 wxASSERT( NdotL >= FLT_EPSILON );
106 if( aShadowAttenuationFactor > FLT_EPSILON )
110 const SFVEC3F diffuse = NdotL * aLightColor;
113 const SFVEC3F H = glm::normalize( aDirToLight - aRay.
m_Dir );
116 const float NdotH = glm::dot(
H, aHitInfo.
m_HitNormal );
117 const float intensitySpecular = glm::pow( glm::max( NdotH, 0.0f ),
m_reflectivity );
120 aShadowAttenuationFactor * ( diffuse * aDiffuseObjColor +
SPECULAR_FACTOR *
138 m_scale = ( 2.0f * glm::pi<float>() ) / aScale;
149 const float x = glm::sin( glm::sin( hitPos.x ) * 1.5f ) * 0.06f;
150 const float y = glm::sin( glm::sin( hitPos.y ) * 1.5f ) * 0.03f;
151 const float z = -(x + y) + glm::sin( hitPos.z ) * 0.06f;
153 const float noise1 =
s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 0.7f ) - 0.5f;
154 const float noise2 =
s_perlinNoise.noise( hitPos.x * 0.7f, hitPos.y * 1.0f ) - 0.5f;
155 const float noise3 =
s_perlinNoise.noise( hitPos.x * 0.3f, hitPos.z * 1.0f ) - 0.5f;
157 return (
SFVEC3F( noise1, noise2, -( noise3 ) ) * 0.3f +
SFVEC3F( x, y, z ) );
178 hitPos.y + boardNormal.x ) - 0.5f ) * 2.0f;
180 float scratchPattern =
181 (
s_perlinNoise.noise( noise + hitPos.x / 100.0f, hitPos.y * 100.0f ) - 0.5f );
183 const float x = scratchPattern * 0.14f;
184 const float y = (noise + noise * scratchPattern) * 0.14f;
186 return SFVEC3F( x, y, - ( x + y ) ) + boardNormal * 0.25f;
207 return copperNormal * 0.05f;
220 const float noise1 = (
s_perlinNoise.noise( hitPos.x, hitPos.y ) - 0.5f );
221 const float noise2 = (
s_perlinNoise.noise( hitPos.y, hitPos.x ) - 0.5f );
223 return SFVEC3F( noise1, noise2, 0.0f ) * 0.1f;
237 const float noise1 =
s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.1f,
238 hitPos.z * 1.2f ) - 0.5f;
240 const float noise2 =
s_perlinNoise.noise( hitPos.x * 1.3f, hitPos.y * 1.0f,
241 hitPos.z * 1.5f ) - 0.5f;
243 const float noise3 =
s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.0f,
244 hitPos.z * 1.8f ) - 0.5f;
246 const float distanceReduction = 1.0f / ( aHitInfo.
m_tHit + 0.5f );
248 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( distanceReduction );
262 const float noise1 =
s_perlinNoise.noise( hitPos.x * 0.01f, hitPos.y * 0.01f,
263 hitPos.z * 0.01f ) - 0.5f;
265 const float noise2 =
s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.0f,
266 hitPos.z * 1.6f ) - 0.5f;
268 float noise3 =
s_perlinNoise.noise( hitPos.x * 1.5f, hitPos.y * 1.5f,
269 hitPos.z * 1.0f ) - 0.5f;
270 noise3 = noise3 * noise3 * noise3;
272 return SFVEC3F( noise1, noise2, noise3 ) *
SFVEC3F( 0.1f, 0.2f, 1.0f );
286 const float noise1 =
s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.1f,
287 hitPos.z * 1.2f ) - 0.5f;
289 const float noise2 =
s_perlinNoise.noise( hitPos.x * 1.3f, hitPos.y * 1.4f,
290 hitPos.z * 1.5f ) - 0.5f;
292 const float noise3 =
s_perlinNoise.noise( hitPos.x * 0.1f, hitPos.y * 0.1f,
293 hitPos.z * 1.0f ) - 0.5f;
295 return SFVEC3F( noise1 * 0.15f + noise3 * 0.35f, noise2 * 0.25f, noise1 * noise2 * noise3 );
309 const float noise1 =
s_perlinNoise.noise( hitPos.x * 2.0f, hitPos.y * 2.0f, hitPos.z );
311 const float noise2 =
s_perlinNoise.noise( hitPos.x * 0.6f, hitPos.y * 0.6f, hitPos.z );
317 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
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is transparent.
unsigned int m_refractionRecursionCount
Number of levels it allows for refraction recursiveness.
float m_absorbance
absorbance factor for the transparent material.
unsigned int m_reflectionRayCount
Number of rays that will be interpolated for this material if it is reflective.
unsigned int m_reflectionRecursionCount
Number of levels it allows for reflection recursiveness.
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_transparency
1.0 is completely transparent, 0.0 completely opaque.
float m_reflection
1.0 completely reflective, 0.0 no reflective.
const MATERIAL_GENERATOR * m_generator
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.
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