Skip to content

Instantly share code, notes, and snippets.

@Shell64
Shell64 / ffmpeg_build.sh
Last active April 8, 2021 17:21 — forked from talkingnews/ffmpeg_build.sh
Build & Install FFMPEG into ClearLinux script
#!/bin/bash
rm -rf ~/ffmpeg_sources ~/bin ~/ffmpeg_build
mkdir -p ~/ffmpeg_sources ~/bin ~/ffmpeg_build
cd ~/ffmpeg_sources && \
wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2 && \
tar xjvf nasm-2.15.05.tar.bz2 && \
cd nasm-2.15.05 && \
./autogen.sh && \
@Shell64
Shell64 / spritebatch.glsl
Created February 22, 2020 03:19
SpriteBatch Vertex Shader GLSL code
#version 330 core
layout (location = 0) in vec3 VertexPosition;
layout (location = 1) in vec2 VertexTexCoord;
layout (location = 2) in vec4 VertexColor;
int QuadIndexOffsets[6] = int[6](0, 1, 2, 2, 3, 0);
vec2 QuadCoords[6] = vec2[6](vec2(0.0, 0.0), vec2(1.0, 0.0), vec2(1.0, 1.0), vec2(1.0, 1.0), vec2(0.0, 1.0), vec2(0.0, 0.0));
uniform samplerBuffer VertexBuffer;
uniform mat4 ProjectionMatrix;
local MAXVCACHE = 32
local function CalculateScore(Object)
if #Object.Uses > 0 then
Object.Score = 2.0 * ((#Object.Uses) ^ -0.5)
if Object.CacheRank >= 3 then
Object.Score = Object.Score + ((1.0 - (Object.CacheRank - 3) / MAXVCACHE) ^ 1.5)
elseif Object.CacheRank >= 0 then
Object.Score = Object.Score + 0.75
end
@Shell64
Shell64 / ssr.c
Created April 8, 2017 21:04
SSR Render Loop
for(int Count = 0; Count < 160; Count++)
{
if(CurrentPosition.x < 0.0 || CurrentPosition.x > 1.0 ||
CurrentPosition.y < 0.0 || CurrentPosition.y > 1.0 ||
CurrentPosition.z < 0.0 || CurrentPosition.z > 1.0)
{
return vec4(0.0, 0.0, 0.0, 1.0);
}
//intersections
//Image.cpp:136
throw love::Exception("Image cannot have mipmaps: compressed image data does not have all required mipmap levels.");
//Should be upgraded to:
throw love::Exception("Image cannot have mipmaps: compressed image data does not have all required mipmap levels (expected %d, got %d)", getMipmapCount(width, height), compresseddata[0]->getMipmapCount());
/*
This software is in the public domain. Where that dedication is not recognized,
you are granted a perpetual, irrevokable license to copy and modify this file
as you see fit.
*/
float GetDepth(sampler2D tex_heightmap, vec2 UV ) {
return texture2D(tex_heightmap, UV).r;
}
@Shell64
Shell64 / stencil.lua
Created November 4, 2015 22:06
love 0.10.0 stencil API abstraction (like 0.9.2) for my engine.
local CurrentStencil = nil
function Graphics.SetStencil(Stencil)
if Stencil then
Graphics.SetStencilTest(true, false)
Graphics.Stencil(Stencil, false)
CurrentStencil = Stencil
else
CurrentStencil = nil
@Shell64
Shell64 / gist:6a5e7d904633e5958efd
Last active November 2, 2015 11:25
Daltonism shader for LOVE
uniform float colorblind_mode = 0.0;
const mat3 protanopia = mat3(0.567, 0.433, 0 , 0.558, 0.442, 0 , 0 , 0.242 ,0.758);
const mat3 protanomaly = mat3(0.817, 0.183, 0 , 0.333, 0.667, 0 , 0 , 0.125 ,0.875);
const mat3 deuteranopia = mat3(0.625, 0.375, 0 , 0.7 , 0.3 , 0 , 0 , 0.3 ,0.7 );
const mat3 deuteranomaly = mat3(0.8 , 0.2 , 0 , 0.258, 0.742, 0 , 0 , 0.142 ,0.858);
const mat3 tritanopia = mat3(0.95 , 0.05 , 0 , 0 , 0.433, 0.567, 0 , 0.475 ,0.525);
const mat3 tritanomaly = mat3(0.967, 0.033, 0 , 0 , 0.733, 0.267, 0 , 0.183 ,0.817);
const mat3 achromatopsia = mat3(0.299, 0.587, 0.114, 0.299, 0.587, 0.114, 0.299, 0.587 ,0.114);
const mat3 achromatomaly = mat3(0.618, 0.320, 0.062, 0.163, 0.775, 0.062, 0.163, 0.320 ,0.516);
@Shell64
Shell64 / gist:3f7e8308c2499bc43e25
Created October 22, 2015 05:49
LuaWebserver2 simple POST example
function Application.POST(Information, Content)
if Information.Parameter == "MyFuncName" then
return '{"d": "1"}', 200
else
return '{"d": "0"}', 200
end
end
@Shell64
Shell64 / gist:5d12f50b4a0cabc08900
Last active October 18, 2015 16:01
Geometric Shadowing term G (Schilik using UE4 roughness)
// Geometric Shadowing term G (Schilik using UE4 roughness)
float k = alpha / 2.0;
float GL = dotNL / (dotNL * (1.0 - k) + k);
float GV = dotNV / (dotNV * (1.0 - k) + k);
float G = GV * GL;