KiCad PCB EDA Suite
PLASTIC_SHINE_NORMAL Class Reference

Procedural generation of the shiny plastic normals. More...

#include <material.h>

Inheritance diagram for PLASTIC_SHINE_NORMAL:
MATERIAL_GENERATOR

Public Member Functions

 PLASTIC_SHINE_NORMAL ()
 
 PLASTIC_SHINE_NORMAL (float aScale)
 
virtual ~PLASTIC_SHINE_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 shiny plastic normals.

Definition at line 173 of file material.h.

Constructor & Destructor Documentation

◆ PLASTIC_SHINE_NORMAL() [1/2]

PLASTIC_SHINE_NORMAL::PLASTIC_SHINE_NORMAL ( )
inline

Definition at line 176 of file material.h.

177  {
178  m_scale = 1.0f;
179  }

References m_scale.

◆ PLASTIC_SHINE_NORMAL() [2/2]

PLASTIC_SHINE_NORMAL::PLASTIC_SHINE_NORMAL ( float  aScale)

Definition at line 259 of file material.cpp.

260 {
261  m_scale = 1.0f / aScale;
262 }

References m_scale.

◆ ~PLASTIC_SHINE_NORMAL()

virtual PLASTIC_SHINE_NORMAL::~PLASTIC_SHINE_NORMAL ( )
inlinevirtual

Definition at line 183 of file material.h.

184  {
185  }

Member Function Documentation

◆ Generate()

SFVEC3F PLASTIC_SHINE_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 265 of file material.cpp.

266 {
267  const SFVEC3F hitPos = aHitInfo.m_HitPoint * m_scale;
268 
269  const float noise1 = s_perlinNoise.noise( hitPos.x * 0.01f, hitPos.y * 0.01f,
270  hitPos.z * 0.01f ) - 0.5f;
271 
272  const float noise2 = s_perlinNoise.noise( hitPos.x * 1.0f, hitPos.y * 1.0f,
273  hitPos.z * 1.6f ) - 0.5f;
274 
275  float noise3 = s_perlinNoise.noise( hitPos.x * 1.5f, hitPos.y * 1.5f,
276  hitPos.z * 1.0f ) - 0.5f;
277  noise3 = noise3 * noise3 * noise3;
278 
279  return SFVEC3F( noise1, noise2, noise3 ) * SFVEC3F( 0.1f, 0.2f, 1.0f );
280 }
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, PerlinNoise::noise(), and s_perlinNoise.

Member Data Documentation

◆ m_scale

float PLASTIC_SHINE_NORMAL::m_scale
private

Definition at line 191 of file material.h.

Referenced by Generate(), and PLASTIC_SHINE_NORMAL().


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