Skip to content

Instantly share code, notes, and snippets.

View andrew-raphael-lukasik's full-sized avatar
🏴‍☠️

Andrew Raphael Lukasik andrew-raphael-lukasik

🏴‍☠️
View GitHub Profile
#pragma once
// LICENSE AND COPYRIGHT (C) INFORMATION
// https://github.com/vittorioromeo/VRSFML/blob/master/license.md
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include "SFML/System/Clock.hpp"
#include "SFML/System/Time.hpp"
@d7samurai
d7samurai / .readme.md
Last active October 30, 2025 04:00
Minimal D3D11 bonus material: MSAA

Minimal D3D11 bonus material: MSAA

image

This is essentially just the original Minimal D3D11 codebase with 8x MSAA added. However, since MSAA only smooths triangle edges and does not affect textured surface interiors, texturing is removed to isolate the effect of MSAA and make it clearer.

In short there are two parts to it: 1) Create and render to an MSAA texture rather than your typical rendertarget/framebuffer (note: the depth buffer must match), and 2) [Resolve](https://gist.github.com/d7samurai/d74299f8bcadcb9cb0

@d7samurai
d7samurai / .readme.md
Last active August 17, 2025 16:07
Minimal D3D11 bonus material: simple 2D rendering

Minimal D3D11 bonus material: simple 2D rendering

image

Plain 2D rendering in D3D11, without the distracting feature set of a complete sprite renderer and allowing arbitrarily placed triangle vertices with absolute pixel coordinate positioning (there's really no need for the sometimes confusing complication of a full-on projection matrix pipeline for UI and 2D games). Like the original Minimal D3D11, this one uses a canonical 1:1 TRIANGLELIST vertex buffer with input layout, so no fancy manual custom buffer fetching and in-shader in

@keijiro
keijiro / FpsCapper.cs
Last active September 24, 2025 21:29
FpsCapper - Limits the frame rate of the Unity Editor in Edit Mode
using UnityEditor;
using UnityEngine;
using UnityEngine.LowLevel;
using System.Linq;
using System.Threading;
namespace EditorUtils {
//
// Serializable settings
@StagPoint
StagPoint / OuterGlow.cs
Last active August 14, 2025 19:27
Custom VisualElement for Unity's UI Toolkit which is useful for creating an "outer glow" effect for buttons, or a "drop shadow" effect for popups, windows, and dialogs.
// Created 2024 StagPoint. Released to the public domain.
using System;
using System.Runtime.CompilerServices;
using Unity.Collections;
using UnityEngine;
using UnityEngine.Scripting;
using UnityEngine.UIElements;
@d7samurai
d7samurai / .readme.md
Last active August 17, 2025 16:07
Minimal D3D11 sprite renderer NEO

sponsored by SuperNeo copy 4

Minimal D3D11 sprite renderer NEO

Ultra-compact sprite rendering code with example frame animation logic. This release contains tech bits from the upcoming SuperNeo™ 2D game engine and includes anchor/pivot point, rotation, color filtering, alpha blending and built-in antialiased point sampling. As usual: complete, runnable single-function app. ~150 LOC. No modern C++, OOP or (other) obscuring cruft.

Minimal D3D11 sprite renderer NEO 1337

Sprites are rendered back-to-front (AKA "painter's algorithm") in the order they are submitted, as one draw call. The provided setup employs a single texture atlas containing all the sprite graphics.

The renderer is "im

/**
* \brief Returns positional offset for a given point as a result of summing 4 gerstner waves
* \param positionWS point in world space
* \param wavelengths wavelength of each of the 4 waves
* \param amplitudes amplitudes of each of the 4 waves
* \param directions direction of each of the 4 waves (each row = one direction). MUST BE NORMALIZED!
* \param speed global speed multiplier. Individual wave speed depends on Wavelength
* \param steepness Gerstner wave 'Steepness' parameter. Modulates the horizontal offset of points
* \param normal returns the normal of given point.
* \return positional offset of the given point
@kraj0t
kraj0t / UsingCsCodeInHLSL.cs
Last active January 5, 2025 14:34
How to include C# code in an HLSL file - useful for sharing code between CPU and shader without duplicating any files
// Share code between HLSL (shaders) and C#
//
// Limitations:
// - Cannot use #include
// - Must use defines to hide certain keywords, such as public, private, protected, or any other object-oriented programming keywords
// - Use defines to convert half or fixed to your desired C# equivalent
// - Must always write f after float literals
// - Use #if !MY_DEFINE instead of #ifndef MY_DEFINE
// - #define cannot be used with a value in C#, not even inside an '#if SHADER_TARGET' block. Therefore, you have two options for declaring valued constants:
// a. Declare each constant separately in HLSL (using 'static const float MyConstant = 1.0f') and in C# (using 'const float MyConstant = 1.0f'). C# does not support 'static const'.
#include <stdio.h>
#include <stdlib.h>
#define da_append(xs, x) \
do { \
if ((xs)->count >= (xs)->capacity) { \
if ((xs)->capacity == 0) (xs)->capacity = 256; \
else (xs)->capacity *= 2; \
(xs)->items = realloc((xs)->items, (xs)->capacity*sizeof(*(xs)->items)); \
} \
@pema99
pema99 / WorldPositionFromDepth.shader
Created September 15, 2023 19:24
WorldPositionFromDepth thx d4rkpl4y3r and lox
Shader "Unlit/GridAllocation"
{
SubShader
{
Tags { "Queue" = "Overlay" }
ZTest Always
Pass
{
CGPROGRAM