Skip to content

Instantly share code, notes, and snippets.

View thatcosmonaut's full-sized avatar

Evan Hemsley thatcosmonaut

View GitHub Profile
@thatcosmonaut
thatcosmonaut / buildshader.py
Last active March 26, 2024 17:26
Portable shader build script for use with SDL_gpu
#!/usr/bin/env python3
# Simple DirectMedia Layer
# Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
using System;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace KeyboardTest
{
unsafe class KeyboardTestGame : Game
{
@thatcosmonaut
thatcosmonaut / Glicko2.cs
Created November 28, 2023 20:06
Glicko-2 C#
// An implementation of the Glicko-2 system
// http://www.glicko.net/glicko/glicko2.pdf
// Copyright (c) 2023 Evan "cosmonaut" Hemsley
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@thatcosmonaut
thatcosmonaut / build_moonlibs.sh
Last active October 18, 2023 19:14
Build moonlibs
#!/bin/bash
run_builds() {
cd ~/programming/$1
mkdir -p moonbuild
mkdir -p moonbuildWin64
mkdir -p moonbuildMac
cd moonbuild
cmake ..
make -j8
@thatcosmonaut
thatcosmonaut / MotionSystem.cs
Last active September 28, 2023 18:12
Samurai Gunn 2 MotionSystem
using System;
using System.Collections.Generic;
using MoonTools.ECS;
using MoonWorks.Math.Fixed;
using SamuraiGunn2.Content;
namespace SamuraiGunn2
{
public class MotionSystem : MoonTools.ECS.System
{
@thatcosmonaut
thatcosmonaut / DebugRenderer.cs
Last active September 26, 2023 21:50
MoonWorks + Dear Imgui
#if DEBUG
using MoonWorks;
using MoonWorks.Graphics;
using MoonWorks.Math.Float;
using ImGuiNET;
using Buffer = MoonWorks.Graphics.Buffer;
namespace SamuraiGunn2
{
public class DebugRenderer
@thatcosmonaut
thatcosmonaut / phong.frag
Created August 15, 2023 05:50
Phong Lighting Shader
#version 450
layout(location = 0) in vec3 InColor;
layout(location = 1) in vec3 InNormal;
layout(location = 2) in vec3 InFragPos;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 3) uniform UBO
{
vec3 LightPos;
@thatcosmonaut
thatcosmonaut / specular.frag
Created August 15, 2023 05:44
Specular Lighting Shader
#version 450
layout(location = 0) in vec3 InNormal;
layout(location = 1) in vec3 InFragPos;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 3) uniform UBO
{
vec3 ViewPos;
float Strength;
@thatcosmonaut
thatcosmonaut / diffuse.frag
Created August 15, 2023 05:38
Diffuse lighting shader
#version 450
layout(location = 0) in vec3 InNormal;
layout(location = 1) in vec3 InFragPos;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 3) uniform UBO
{
vec3 LightPos;
vec3 LightColor;
@thatcosmonaut
thatcosmonaut / ambient.frag
Last active August 15, 2023 05:27
Ambient lighting
#version 450
layout(location = 0) in vec4 InColor;
layout(location = 0) out vec4 FragColor;
layout(binding = 0, set = 3) uniform UBO
{
vec4 LightColor;
float AmbientStrength;
} ubo;