KiCad PCB EDA Suite
render_3d_raytrace.cpp File Reference
#include <gal/opengl/kiglew.h>
#include <algorithm>
#include <atomic>
#include <chrono>
#include <climits>
#include <thread>
#include "render_3d_raytrace.h"
#include "mortoncodes.h"
#include "../color_rgb.h"
#include "3d_fastmath.h"
#include "3d_math.h"
#include "../common_ogl/ogl_utils.h"
#include <profile.h>
#include <wx/log.h>

Go to the source code of this file.

Macros

#define SRGB_GAMA   2.4f
 
#define DISP_FACTOR   0.075f
 
#define USE_EXPERIMENTAL_SOFT_SHADOWS   1
 

Functions

static void SetPixel (GLubyte *p, const COLOR_RGB &v)
 
static SFVEC3F convertLinearToSRGB (const SFVEC3F &aRGBcolor)
 
SFVEC3F ConvertSRGBToLinear (const SFVEC3F &aSRGBcolor)
 
static void HITINFO_PACKET_init (HITINFO_PACKET *aHitPacket)
 
static float distance (const SFVEC2UI &a, const SFVEC2UI &b)
 

Macro Definition Documentation

◆ DISP_FACTOR

#define DISP_FACTOR   0.075f

Definition at line 623 of file render_3d_raytrace.cpp.

◆ SRGB_GAMA

#define SRGB_GAMA   2.4f
Todo:
This should be removed in future when KiCad supports a greater version of glm lib.

Definition at line 413 of file render_3d_raytrace.cpp.

◆ USE_EXPERIMENTAL_SOFT_SHADOWS

#define USE_EXPERIMENTAL_SOFT_SHADOWS   1

Definition at line 1540 of file render_3d_raytrace.cpp.

Function Documentation

◆ convertLinearToSRGB()

static SFVEC3F convertLinearToSRGB ( const SFVEC3F aRGBcolor)
static

Definition at line 418 of file render_3d_raytrace.cpp.

419{
420 const float gammaCorrection = 1.0f / SRGB_GAMA;
421 const SFVEC3F clampedColor = glm::clamp( aRGBcolor, SFVEC3F( 0.0f ), SFVEC3F( 1.0f ) );
422
423 return glm::mix( glm::pow( clampedColor, SFVEC3F(gammaCorrection) ) * 1.055f - 0.055f,
424 clampedColor * 12.92f,
425 glm::lessThan( clampedColor, SFVEC3F(0.0031308f) ) );
426}
#define SRGB_GAMA
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44

References SRGB_GAMA.

Referenced by RENDER_3D_RAYTRACE::renderFinalColor().

◆ ConvertSRGBToLinear()

SFVEC3F ConvertSRGBToLinear ( const SFVEC3F aSRGBcolor)

Definition at line 431 of file render_3d_raytrace.cpp.

432{
433 const float gammaCorrection = SRGB_GAMA;
434
435 return glm::mix( glm::pow( ( aSRGBcolor + SFVEC3F( 0.055f ) )
436 * SFVEC3F( 0.94786729857819905213270142180095f ),
437 SFVEC3F( gammaCorrection ) ),
438 aSRGBcolor * SFVEC3F( 0.07739938080495356037151702786378f ),
439 glm::lessThanEqual( aSRGBcolor, SFVEC3F( 0.04045f ) ) );
440}

References SRGB_GAMA.

Referenced by RENDER_3D_RAYTRACE::addModels(), RENDER_3D_RAYTRACE::createItemsFromContainer(), RENDER_3D_RAYTRACE::createObject(), RENDER_3D_RAYTRACE::getModelMaterial(), RENDER_3D_RAYTRACE::insertHole(), RENDER_3D_RAYTRACE::Reload(), RENDER_3D_RAYTRACE::render(), and RENDER_3D_RAYTRACE::setupMaterials().

◆ distance()

◆ HITINFO_PACKET_init()

static void HITINFO_PACKET_init ( HITINFO_PACKET aHitPacket)
static

Definition at line 466 of file render_3d_raytrace.cpp.

467{
468 // Initialize hitPacket with a "not hit" information
469 for( unsigned int i = 0; i < RAYPACKET_RAYS_PER_PACKET; ++i )
470 {
471 aHitPacket[i].m_HitInfo.m_tHit = std::numeric_limits<float>::infinity();
472 aHitPacket[i].m_HitInfo.m_acc_node_info = 0;
473 aHitPacket[i].m_hitresult = false;
474 aHitPacket[i].m_HitInfo.m_HitNormal = SFVEC3F( 0.0f );
475 aHitPacket[i].m_HitInfo.m_ShadowFactor = 1.0f;
476 }
477}
#define RAYPACKET_RAYS_PER_PACKET
Definition: raypacket.h:35
bool m_hitresult
Definition: hitinfo.h:57
HITINFO m_HitInfo
Definition: hitinfo.h:58
unsigned int m_acc_node_info
( 4) The acc stores here the node that it hits
Definition: hitinfo.h:42
float m_tHit
( 4) distance
Definition: hitinfo.h:38
float m_ShadowFactor
( 4) Shadow attenuation (1.0 no shadow, 0.0f darkness)
Definition: hitinfo.h:45
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:37

References HITINFO::m_acc_node_info, HITINFO_PACKET::m_HitInfo, HITINFO::m_HitNormal, HITINFO_PACKET::m_hitresult, HITINFO::m_ShadowFactor, HITINFO::m_tHit, and RAYPACKET_RAYS_PER_PACKET.

Referenced by RENDER_3D_RAYTRACE::renderBlockTracing().

◆ SetPixel()

static void SetPixel ( GLubyte *  p,
const COLOR_RGB v 
)
inlinestatic

Definition at line 140 of file render_3d_raytrace.cpp.

141{
142 p[0] = v.c[0];
143 p[1] = v.c[1];
144 p[2] = v.c[2];
145 p[3] = 255;
146}
unsigned char c[3]
Definition: color_rgb.h:36

References COLOR_RGB::c.

Referenced by RENDER_3D_RAYTRACE::renderPreview().