Skip to content

Instantly share code, notes, and snippets.

View iOrange's full-sized avatar
💭
🎮

iOrange

💭
🎮
View GitHub Profile
@Devaniti
Devaniti / Setup.bat
Last active August 3, 2023 19:24
(deprecated, please use https://gist.github.com/Devaniti/f2cc137cd746d103171393647248fc3a instead) Setup script for new Windows 11 graphic developer PC
rem Script for setting up new Windows 11 PC for graphic development
rem You need need to run it with administator rights
rem You can modify list of installed software below
rem Windows explorer settings
rem Sets option to always show file extensions
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v HideFileExt /t REG_DWORD /d 0 /f
rem Sets option to show hidden files (but not OS protected files)
reg add HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced /v Hidden /t REG_DWORD /d 1 /f
rem Sets option to show full path instead of just folder name in file explorer window title
@hugoam
hugoam / function.h
Created January 22, 2019 11:15
function.h
template <typename T>
class function;
template <typename Return, typename... Args>
class function<Return(Args...)>
{
public:
function() {}
template <class T, typename = typename enable_if<is_invocable<T, Args...>::value>::type>
@sebbbi
sebbbi / FastUniformLoadWithWaveOps.txt
Last active February 15, 2024 08:41
Fast uniform load with wave ops (up to 64x speedup)
In shader programming, you often run into a problem where you want to iterate an array in memory over all pixels in a compute shader
group (tile). Tiled deferred lighting is the most common case. 8x8 tile loops over a light list culled for that tile.
Simplified HLSL code looks like this:
Buffer<float4> lightDatas;
Texture2D<uint2> lightStartCounts;
RWTexture2D<float4> output;
[numthreads(8, 8, 1)]
@vurtun
vurtun / defl.c
Last active June 13, 2023 21:30
Full deflate/inflate implementation in ~300 LoC
/* ===============================================================
* SDEFL
* ===============================================================
* public domain - no warranty implied; use at your own risk
* References:
https://bitbucket.org/rmitton/tigr/src/be3832bee7fb2f274fe5823e38f8ec7fa94e0ce9/src/tigr_inflate.c?at=default&fileviewer=file-view-default
https://github.com/github/putty/blob/49fb598b0e78d09d6a2a42679ee0649df482090e/sshzlib.c
https://www.ietf.org/rfc/rfc1951.txt
*/
#include <stdlib.h>
@podgorskiy
podgorskiy / FrustumCull.h
Created July 12, 2017 10:33
Ready to use frustum culling code. Depends only on GLM. The input is only bounding box and ProjectionView matrix. Based on Inigo Quilez's code.
#include <glm/matrix.hpp>
class Frustum
{
public:
Frustum() {}
// m = ProjectionMatrix * ViewMatrix
Frustum(glm::mat4 m);
@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Math.md
Last active April 15, 2024 20:34
GLSL Math functions

Trigonometry

const float PI = 3.1415926535897932384626433832795;
const float PI_2 = 1.57079632679489661923;
const float PI_4 = 0.785398163397448309616;

float PHI = (1.0+sqrtf(5.0))/2.0;
@reinsteam
reinsteam / tbn_from_quat.c
Last active October 15, 2020 03:05
Snippet to calculate TBN basis from quaternion in 8 instructions (seems like this one is used at Crytek: http://www.crytek.com/download/izfrey_siggraph2011.pdf)
/*----------------------------------------------------------------------------------------------------------------------
Custom cross-product: mad + mul
----------------------------------------------------------------------------------------------------------------------*/
half3 crs(half3 v0, half3 v1)
{
//return cross(v0, v1);
half3 v0_0 = v0.yzx;
half3 v0_1 = v1.zxy;
half3 v1_0 = v0.zxy;
half3 v1_1 = v1.yzx;