KiCad PCB EDA Suite
PLASTIC_NORMAL Class Reference

Procedural generation of the plastic normals. More...

#include <material.h>

Inheritance diagram for PLASTIC_NORMAL:
MATERIAL_GENERATOR

Public Member Functions

 PLASTIC_NORMAL ()
 
 PLASTIC_NORMAL (float aScale)
 
virtual ~PLASTIC_NORMAL ()
 
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. More...
 

Private Attributes

float m_scale
 

Detailed Description

Procedural generation of the plastic normals.

Definition at line 149 of file material.h.

Constructor & Destructor Documentation

◆ PLASTIC_NORMAL() [1/2]

PLASTIC_NORMAL::PLASTIC_NORMAL ( )
inline

Definition at line 152 of file material.h.

153  {
154  m_scale = 1.0f;
155  }
float m_scale
Definition: material.h:166

References m_scale.

◆ PLASTIC_NORMAL() [2/2]

PLASTIC_NORMAL::PLASTIC_NORMAL ( float  aScale)

Definition at line 234 of file material.cpp.

235 {
236  m_scale = 1.0f / aScale;
237 }
float m_scale
Definition: material.h:166

References m_scale.

◆ ~PLASTIC_NORMAL()

virtual PLASTIC_NORMAL::~PLASTIC_NORMAL ( )
inlinevirtual

Definition at line 159 of file material.h.

160  {
161  }

Member Function Documentation

◆ Generate()

SFVEC3F PLASTIC_NORMAL::Generate ( const RAY aRay,
const HITINFO aHitInfo 
) const
overridevirtual

Generate a 3D vector based on the ray and hit information depending on the implementation.

Parameters
aRaythe camera ray that hits the object
aHitInfothe hit information
Returns
the result of the procedural

Implements MATERIAL_GENERATOR.

Definition at line 240 of file material.cpp.

241 {
242  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
243 
244  const float noise1 = s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.1f,
245  hitPos.z * 1.2f ) - 0.5f;
246 
247  const float noise2 = s_perlinNoise.noise( hitPos.x * 1.3f, hitPos.y * 1.0f,
248  hitPos.z * 1.5f ) - 0.5f;
249 
250  const float noise3 = s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.0f,
251  hitPos.z * 1.8f ) - 0.5f;
252 
253  const float distanceReduction = 1.0f / ( aHitInfo.m_tHit + 0.5f );
254 
255  return SFVEC3F( noise1, noise2, noise3 ) * SFVEC3F( distanceReduction );
256 }
float m_scale
Definition: material.h:166
float m_tHit
( 4) distance
Definition: hitinfo.h:43
SFVEC3F m_HitPoint
(12) hit position
Definition: hitinfo.h:49
static PerlinNoise s_perlinNoise
Definition: material.cpp:140
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float noise(float x, float y, float z) const

References HITINFO::m_HitPoint, m_scale, HITINFO::m_tHit, PerlinNoise::noise(), and s_perlinNoise.

Member Data Documentation

◆ m_scale

float PLASTIC_NORMAL::m_scale
private

Definition at line 166 of file material.h.

Referenced by Generate(), and PLASTIC_NORMAL().


The documentation for this class was generated from the following files: