Skip to content

Instantly share code, notes, and snippets.

View alaingalvan's full-sized avatar
Resident Latte Graphics Engineer. 👍

Alain Galvan alaingalvan

Resident Latte Graphics Engineer. 👍
View GitHub Profile
@alaingalvan
alaingalvan / bevel-normals.glsl
Created August 3, 2017 17:29
Some bevel shader magic. :3
void rng_seed(output int rng, int seed)
{
int chash = seed;
if (chash == 0) chash = 1;
rng = chash * 30391861;
}
float rng_uniform(output int rng)
{
float res = rng / float(2137483647) * 0.5 + 0.5;
@alaingalvan
alaingalvan / screenspacebentconesao.glsl
Last active December 27, 2023 20:53
GPU Pro 3 sample of bent cones screen space ambient occlusion.
void main()
{
vec3 positionX = backproject(depthTexture(pixelCoordinateI), inverseViewProjectionMatrix);
vec3 normalX = normalTexture(pixelCoordinateI);
// get ONB to transform samples
mat3 orthoNormalBasis = computeONB(normalX);
// select samples for pixel out of pattern
int patternOffset = getPatternOffset(pixelCoordinateI);
float ao = 0.0;
void printOpenGLDebugInfo()
{
int majorVersion, minorVersion;
glGetIntegerv(GL_MAJOR_VERSION, &majorVersion);
glGetIntegerv(GL_MINOR_VERSION, &minorVersion);
std::cout << "OpenGL Version: " << majorVersion << "." << minorVersion
<< std::endl;
int work_grp_cnt[3];
@alaingalvan
alaingalvan / Batch Scene Rendering.py
Last active July 9, 2023 08:29
A Marmoset Toolbag 3 plugin for rendering batches of scene data automatically.
"""
Batch Rendering
To render a set of scenes individually, you could create a scene with the lights/camera set up
how you would like, then run this plugin after configuring a list of files you want to render.
"""
import mset
import os.path
# List of scenes to load and render
@alaingalvan
alaingalvan / read_bmp_ds_grid.gml
Last active July 11, 2022 22:11
A way of reading a bitmap as a 2D array of colors in Game Maker Studio. Works with Game Maker 8.1.
///read_bmp(filename)
// Reads 24 or 32 bit bitmap files
//returns a ds_grid of colors encoded as rgb hex
var handle;
handle = file_bin_open(argument0, 0);
var offset, width, height, bits, output;
offset = 29;
width = 0;
height = 0;
bits = 0;

fujifilm pic

A shot of me with the fujifilm set to a lens length of 38 mm with 3 lights. In heinsight I look a little agressive but heh, at least it's different. 😅

Camera Setup

So I've been improving my camera setup to help with video recordings, livestreams, Zoom calls, etc.

Equipment

@alaingalvan
alaingalvan / halton.cpp
Last active December 5, 2020 03:28
Ray Tracing Gem's Halton State code, by Electronic Arts, Colin Barré-Brisebois et al. Errata corrected by Alain Galvan.
// Ray Tracing Gems Chapter 25
// Code provided by Electronic Arts
// Colin Barré-Brisebois, Henrik Halén, Graham Wihlidal, Andrew Lauritzen,
// Jasper Bekkers, Tomasz Stachowiak, and Johan Andersson
// Errata corrected by Alain Galvan
struct HaltonState
{
unsigned dimension;
@alaingalvan
alaingalvan / custom-baker-importer.py
Last active August 28, 2020 20:58
A Marmoset Toolbag plugin showcasing how to design a custom importer for the baker.
import mset
# Create a new BakerObject
baker = mset.BakerObject()
# Import model
myMesh = mset.importModel("E:/MyMesh.fbx")
# Traverse myMesh and find objects I want to be "High" or "Low"
@alaingalvan
alaingalvan / sobol.cpp
Last active June 4, 2020 06:14
Sobol Quasi-Random Sequence Generation by Dr. John Burkardt. Forked to not use cout errors, use less dimensions (saving code size)
/**
* Sobol Noise Generation
* GNU LGPL license
* By Dr. John Burkardt (Virginia Tech)
* https://gist.github.com/alaingalvan/af92ddbaf3bb01f5ef29bc431bd37891
*/
//returns the position of the high 1 bit base 2 in an integer n
int getHighBit1(int n)
{
@alaingalvan
alaingalvan / RecordingVSCodeMiniMap.md
Created August 14, 2019 04:13
Recording VS Code for use in YouTube Videos, etc.

So I wanted to make an animation of code being written in the minimap, so I set up VS Code so that it would write the minimap canvas to a PNG file every time there's a backspace (play that in reverse and you have typing out a file).

var fs = require('fs')
var curFrame = 0;
function saveCallback() {
    // Get the DataUrl from the Canvas
    const url = document.querySelectorAll('canvas')[1].toDataURL();

 // remove Base64 stuff from the Image