This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
© 2010 Jens Ayton | |
This code may be used freely. | |
*/ | |
uniform float uValue; // Value/brighness component. | |
const float kPi = 3.141592653589793; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
© 2010 Jens Ayton | |
This code may be used freely. | |
*/ | |
uniform float uValue; // Value/brighness component. | |
const float kPi = 3.141592653589793; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void check_for_leaks() | |
{ | |
GLuint max_id = 10000; // better idea would be to keep track of assigned names. | |
GLuint id; | |
// if brute force doesn't work, you're not applying it hard enough | |
for ( id = 1 ; id <= max_id ; id++ ) | |
{ | |
#define CHECK( type ) if ( glIs##type( id ) ) fprintf( stderr, "GLX: leaked " #type " handle 0x%x\n", (unsigned int) id ) | |
CHECK( Texture ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "hemicube.h" | |
#define PACK_HEMICUBES 1 | |
static void get_hemicube_face_normal(int index, Vector3 *forward, Vector3 *left, Vector3 *up) { | |
// Unwrapped hemicube with positive-Z in the middle. | |
switch (index) { | |
case 0: *forward = Vector3(+1, 0, 0); *left = Vector3( 0, 1, 0); break; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class T> | |
class range | |
{ | |
public: | |
class range_iterator | |
{ | |
public: | |
range_iterator(const T Position_) : Position(Position_) | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// References | |
// | |
// [1] Sloan, P.-P., Luna, B., and Snyder, J. 2005. | |
// Local, deformable precomputedradiance transfer. | |
// ACM Trans. Graph. 24, 3, 1216–1223 | |
// | |
// [2] Stupid Spherical Harmonics (SH) Tricks | |
// Peter-Pike Sloan, Microsoft Corporation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Draws a graph using a triangle strip and simple gradient texture. | |
// Anti-aliasing may be off by a half a pixel. | |
// Works reasonable well with smooth as well as noisy data. | |
// The basic idea is that we draw the graph using a full height quad (or two triangles) | |
// per segment between two samples, and then we calculate texture coordinates | |
// so that 1px anti-aliasing gradient passes through the data points. The texture coordinate | |
// is calculated using the segment normal and one segment end point. | |
struct Point { | |
float x, y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C/C++ tips for using printf-style functions | |
// Lots of manipulation can be expressed simply and fast with printf-style formatting | |
// Also helps reducing the number of temporaries, memory allocations or copies | |
// ( If you are looking for a simple C++ string class that is printf-friendly and not heap-abusive, | |
// I've been using this one: https://github.com/ocornut/Str ) | |
// If you are interested in a FASTER implementation of sprintf functions, see stb_sprintf.h | |
// https://github.com/nothings/stb/blob/master/stb_sprintf.h | |
// How to concatenate non-zero terminated strings |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hybrid atomic loop weighted blended order independent transparency implementation (work in progress) | |
// Copyright (C) 2014 by Benjamin 'BeRo' Rosseaux | |
// Licensed under the CC0 license, since in the German legislation exists no public | |
// domain. | |
// This implementation needs at least OpenGL 4.3 as minimum OpenGL version, due to my usage of shader storage buffer objects here | |
// Supports also additive blending for emission color portions | |
uniform sampler2D uTexTailWeightedBlendedOrderIndependentTransparencyColor; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float3 PositionToOctahedron(float3 position) | |
{ | |
// Normalize input position to unit sphere to simplify required ops | |
float3 P = normalize(position); | |
// Get octant index | |
float3 side = P >= 0 ? 1 : 0; | |
float octant_index = side.x + side.y * 2 + side.z * 4; | |
// Project onto octahedron face, then onto each x/y plane |
OlderNewer