Skip to content

Instantly share code, notes, and snippets.

View erichlof's full-sized avatar

Erich Loftis erichlof

View GitHub Profile
@jdupuy
jdupuy / SampleVndf_GGX.cpp
Last active April 15, 2024 20:09
Sampling Visible GGX Normals with Spherical Caps
// Helper function: sample the visible hemisphere from a spherical cap
vec3 SampleVndf_Hemisphere(vec2 u, vec3 wi)
{
// sample a spherical cap in (-wi.z, 1]
float phi = 2.0f * M_PI * u.x;
float z = fma((1.0f - u.y), (1.0f + wi.z), -wi.z);
float sinTheta = sqrt(clamp(1.0f - z * z, 0.0f, 1.0f));
float x = sinTheta * cos(phi);
float y = sinTheta * sin(phi);
vec3 c = vec3(x, y, z);
@gingerBill
gingerBill / sdl2_opengl_demo.odin
Last active April 26, 2024 16:05
Simple SDL2 + OpenGL demo written in Odin
package main
import "core:fmt"
import glm "core:math/linalg/glsl"
import "core:time"
import SDL "vendor:sdl2"
import gl "vendor:OpenGL"
main :: proc() {
@gingerBill
gingerBill / microui_sdl_demo.odin
Last active April 18, 2024 18:55
microui + SDL Demo in Odin
package microui_sdl
import "core:fmt"
import "core:c/libc"
import SDL "vendor:sdl2"
import mu "vendor:microui"
state := struct {
mu_ctx: mu.Context,
log_buf: [1<<16]byte,
<!--
Go to Line 153 for the start of Uniform Buffer Object related code and intro
Prerequsite:
You at least know what uniforms are in the context of WebGL
and mininally understand the concepts involved in creating a square in WebGL
-->
<html>
@stevecondylios
stevecondylios / resize-image-in-github-issue-github-flavored-markdown.md
Last active April 27, 2024 19:04
How to Resize an Image in a Github Issue (e.g. Github flavored Markdown)

How to Resize an Image in Github README.md (i.e. Github Flavored Markdown)

Percentage:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width=50% height=50%>

Pixels:

<img src="https://user-images.githubusercontent.com/16319829/81180309-2b51f000-8fee-11ea-8a78-ddfe8c3412a7.png" width="150" height="280">

@patriciogonzalezvivo
patriciogonzalezvivo / GLSL-Noise.md
Last active May 5, 2024 09:04
GLSL Noise Algorithms

Please consider using http://lygia.xyz instead of copy/pasting this functions. It expand suport for voronoi, voronoise, fbm, noise, worley, noise, derivatives and much more, through simple file dependencies. Take a look to https://github.com/patriciogonzalezvivo/lygia/tree/main/generative

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);