Skip to content

Instantly share code, notes, and snippets.

View devshgraphicsprogramming's full-sized avatar

Mateusz Kielan devshgraphicsprogramming

View GitHub Profile
@devshgraphicsprogramming
devshgraphicsprogramming / STDVectorCompatibileGPUMemAllocator.cpp
Created April 27, 2019 21:55
Garbage Collection, fencing, etc. Without Separate Memory Arenas [EARLY PROTOTYPE]
template <class T>
class STLCompatibleGPUAllocator : public irr::core::AllocatorTrivialBase<T>
{
public:
typedef size_t size_type;
typedef T* pointer;
template< class U> struct rebind { typedef STLCompatibleGPUAllocator<U> other; };
STLCompatibleGPUAllocator() {}
@devshgraphicsprogramming
devshgraphicsprogramming / SphericalHarmonicUtilMath.cpp
Created April 9, 2019 11:32
Spherical Harmonics WignerJ matrix for 3 SH function multiplications
///float tripleProductCoefficients[121][36][9];
///bool tripleProductCoefficientSparsityMask[121][121][121];
bool tripleProductCoefficientSparsityMask[121][36][9];
/**
void calculateTripleProductCoefficients()
{
float tripleComplexProductCoefficients[9][36][121];
memset(tripleComplexProductCoefficients,0,sizeof(float)*9*36*121);
@devshgraphicsprogramming
devshgraphicsprogramming / raycastPlanetAtmosphere.glsl
Created February 15, 2018 16:01
Planet Atmosphere Intersection Shader Function
//!Warning does not model intersection with the Planet itself in the middle of the atmosphere
float calculateHazeFactor(in float fragDepth, in vec3 viewDir)
{
//hazeHeight and camPos are heights above sea level
bool aboveHaze = camPos>hazeHeight;
if (aboveHaze&&viewDir.y>=0.0)
return 1.0;
float planetRadius = 6357.0;
float hazeRadius = planetRadius+hazeHeight;