Skip to content

Instantly share code, notes, and snippets.

View BeRo1985's full-sized avatar

Benjamin Rosseaux BeRo1985

View GitHub Profile
@BeRo1985
BeRo1985 / UnitScreenMainMenu.pas
Created October 31, 2018 17:20
PasVulkan Frame graph API code example
unit UnitScreenMainMenu;
{$ifdef fpc}
{$mode delphi}
{$ifdef cpu386}
{$asmmode intel}
{$endif}
{$ifdef cpuamd64}
{$asmmode intel}
{$endif}
{$else}
@BeRo1985
BeRo1985 / fragment.glsl
Last active August 20, 2018 15:32
Attribute-less-rendering-based cube map filitering GLSL shader code template
// Copyright (C) 2018, Benjamin "BeRo" Rosseaux (benjamin@rosseaux.de) - License: CC0
#version 330
layout(location = 0) out vec4 oOutput;
in vec2 vTexCoord;
flat in int vFaceIndex;
vec3 getCubeMapDirection(in vec2 uv,
in int faceIndex){
vec3 zDir = vec3(ivec3((faceIndex <= 1) ? 1 : 0,
(faceIndex & 2) >> 1,
@BeRo1985
BeRo1985 / astronomy.glsl
Last active July 31, 2018 20:29
GLSL Astronomy compute shader
// Copyright (C) 2018, Benjamin "BeRo" Rosseaux (benjamin@rosseaux.de) - License: CC0
// Hint: It's not super accurate, but it should be good enough for games and demos with sky rendering.
#version 430
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
uniform vec3 tc; // Time constant
layout(std430) buffer ssboAstronomy {
vec3 sunPosition;
float sunDistance;
@BeRo1985
BeRo1985 / MiniSoftFP32.pas
Last active July 30, 2018 02:19
MiniSoftFP32 - A simple small software 32-bit single precision floating point implementation
unit MiniSoftFP32; // Copyright (C) 2018, Benjamin "BeRo" Rosseaux (benjamin@rosseaux.de) - License: CC0
// Declaimer / Notice of caution:
// Attention, this code implements only the basic functions, but for example not the correct handling of
// Infinity, NaN, division-by-zero special cases and so on.
// In short, this code is only intended for demystifying the base floating point arithmetics (using 32-bit
// single precision floating point values in this implementation).
{$ifdef fpc}
{$mode delphi}
{$if defined(cpu386) or defined(cpuamd64)}
{$asmmode intel}
@BeRo1985
BeRo1985 / gfxapiwrappers.md
Last active January 9, 2024 12:58
GFX API wrappers
@BeRo1985
BeRo1985 / ForceDedicatedGPUUsageForOpenGL.pas
Created May 30, 2018 04:04
Force usage of dedicated GPU for OpenGL with Delphi and FreePascal/Lazarus on Multi-GPU systems such as Notebooks on Windows
// Force usage of dedicated GPU for OpenGL with Delphi and FreePascal/Lazarus on Multi-GPU systems such as Notebooks on Windows
// Insert that into your main source file, which is for example the .dpr (Delphi) or .lpr (Lazarus) file
{$define ForceDedicatedGPUUsage} // then you can uncomment and recomment this line, for compile-time-switching between
// integrated GPU and dedicated GPU
{$if defined(Windows) and defined(ForceDedicatedGPUUsage) and (defined(cpu386) or defined(cpux64) or defined(cpuamd64))}
{$ifdef fpc}
{$asmmode intel}
{$endif}
@BeRo1985
BeRo1985 / gist:c1373a49b8ed19499d8bc07eda95a382
Created April 30, 2018 05:26 — forked from lordkhonsu/gist:7eca5cbf0440589946c7
bash sed anonymize ip adresses in file

This line will replace the last octet of ipv4 adresses in a given file with a zero:

sed -i '' -e 's/(([0-9]{1,3}.){3})[0-9]{1,3}/\10/g'

@BeRo1985
BeRo1985 / en_DE
Created March 25, 2018 14:52
/usr/share/i18n/locales/en_DE
comment_char %
escape_char /
% Locale for English locale in Germany
LC_IDENTIFICATION
title "English locale for Germany"
source ""
address ""
contact "Benjamin Rosseaux"
email "benjamin@rosseaux.de"
@BeRo1985
BeRo1985 / spirv_variable_extractor.pas
Created February 28, 2018 17:31
spirv_variable_extractor.pas
function TpvVulkanShaderModule.GetVariables:TpvVulkanShaderModuleVariables;
// https://www.khronos.org/registry/spir-v/specs/1.1/SPIRV.html
type PUInt32Array=^TUInt32Array;
TUInt32Array=array[0..65535] of TpvUInt32;
var Position,Size:TpvInt32;
Opcode,Index,NameIndex,Count,CountIDs,CountNames:TpvUInt32;
Opcodes:PUInt32Array;
Endian:boolean;
Variable:PpvVulkanShaderModuleVariable;
Bindings,Locations,DescriptorSets:array of TpvUInt32;
@BeRo1985
BeRo1985 / proceduralhumanoidskeleton.glsl
Created February 6, 2018 01:01
Procedural humanoid skeleton structure
// ----------
// | |
// | |
// | |
// | |
// | |
// ---HEAD---
// | |
// _______________________________/--NECK--\______________________________