KiCad PCB EDA Suite
c3d_render_raytracing.cpp File Reference
#include <GL/glew.h>
#include <climits>
#include "c3d_render_raytracing.h"
#include "mortoncodes.h"
#include "../ccolorrgb.h"
#include "3d_fastmath.h"
#include "3d_math.h"
#include "../common_ogl/ogl_utils.h"
#include <profile.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 CCOLORRGB &v)
 
static SFVEC3F convertLinearToSRGB (const SFVEC3F &aRGBcolor)
 
SFVEC3F ConvertSRGBToLinear (const SFVEC3F &aSRGBcolor)
 
static void HITINFO_PACKET_init (HITINFO_PACKET *aHitPacket)
 

Macro Definition Documentation

#define DISP_FACTOR   0.075f
#define SRGB_GAMA   2.4f

Definition at line 434 of file c3d_render_raytracing.cpp.

Referenced by convertLinearToSRGB(), and ConvertSRGBToLinear().

#define USE_EXPERIMENTAL_SOFT_SHADOWS   1

Definition at line 1701 of file c3d_render_raytracing.cpp.

Function Documentation

static SFVEC3F convertLinearToSRGB ( const SFVEC3F aRGBcolor)
static

Definition at line 438 of file c3d_render_raytracing.cpp.

References SRGB_GAMA.

Referenced by C3D_RENDER_RAYTRACING::rt_final_color(), and C3D_RENDER_RAYTRACING::rt_render_post_process_blur_finish().

439 {
440  const float gammaCorrection = 1.0f / SRGB_GAMA;
441  const SFVEC3F clampedColor = glm::clamp( aRGBcolor, SFVEC3F(0.0f), SFVEC3F(1.0f) );
442 
443  return glm::mix(
444  glm::pow( clampedColor, SFVEC3F(gammaCorrection) ) * 1.055f - 0.055f,
445  clampedColor * 12.92f,
446  glm::lessThan( clampedColor, SFVEC3F(0.0031308f) ) );
447 }
#define SRGB_GAMA
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F ConvertSRGBToLinear ( const SFVEC3F aSRGBcolor)

Definition at line 451 of file c3d_render_raytracing.cpp.

References SRGB_GAMA.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), C3D_RENDER_RAYTRACING::create_3d_object_from(), C3D_RENDER_RAYTRACING::insert3DPadHole(), C3D_RENDER_RAYTRACING::insert3DViaHole(), C3D_RENDER_RAYTRACING::reload(), C3D_RENDER_RAYTRACING::render(), and C3D_RENDER_RAYTRACING::setupMaterials().

452 {
453  const float gammaCorrection = SRGB_GAMA;
454 
455  return glm::mix(
456  glm::pow( (aSRGBcolor + SFVEC3F(0.055f)) * SFVEC3F(0.94786729857819905213270142180095f),
457  SFVEC3F(gammaCorrection) ),
458  aSRGBcolor * SFVEC3F(0.07739938080495356037151702786378f),
459  glm::lessThanEqual( aSRGBcolor, SFVEC3F(0.04045f) ) );
460 }
#define SRGB_GAMA
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
static void HITINFO_PACKET_init ( HITINFO_PACKET aHitPacket)
static

Definition at line 489 of file c3d_render_raytracing.cpp.

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 C3D_RENDER_RAYTRACING::rt_render_trace_block().

490 {
491  // Initialize hitPacket with a "not hit" information
492  for( unsigned int i = 0; i < RAYPACKET_RAYS_PER_PACKET; ++i )
493  {
494  aHitPacket[i].m_HitInfo.m_tHit = std::numeric_limits<float>::infinity();
495  aHitPacket[i].m_HitInfo.m_acc_node_info = 0;
496  aHitPacket[i].m_hitresult = false;
497  aHitPacket[i].m_HitInfo.m_HitNormal = SFVEC3F();
498  aHitPacket[i].m_HitInfo.m_ShadowFactor = 1.0f;
499  }
500 }
float m_ShadowFactor
( 4) Shadow attenuation (1.0 no shadow, 0.0f darkness)
Definition: hitinfo.h:50
float m_tHit
( 4) distance
Definition: hitinfo.h:43
HITINFO m_HitInfo
Definition: hitinfo.h:63
#define RAYPACKET_RAYS_PER_PACKET
Definition: raypacket.h:40
unsigned int m_acc_node_info
( 4) The acc stores here the node that it hits
Definition: hitinfo.h:47
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F m_HitNormal
(12) normal at the hit point
Definition: hitinfo.h:42
bool m_hitresult
Definition: hitinfo.h:62
static void SetPixel ( GLubyte *  p,
const CCOLORRGB v 
)
inlinestatic

Definition at line 142 of file c3d_render_raytracing.cpp.

References CCOLORRGB::c.

Referenced by C3D_RENDER_RAYTRACING::render_preview().

143 {
144  p[0] = v.c[0]; p[1] = v.c[1]; p[2] = v.c[2]; p[3] = 255;
145 }
unsigned char c[3]
Definition: ccolorrgb.h:37