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
@keijiro
keijiro / FpsCapper.cs
Last active May 12, 2025 04:34
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 March 16, 2025 08:15
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;
/**
* \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
@unitycoder
unitycoder / JumpFlooding3D.compute
Last active January 31, 2024 21:27
GPU-based 2D Voronoi diagram generation, technique Cone Projection (unity)
// https://forum.unity.com/threads/programming-tools-constrained-delaunay-triangulation.1066148/#post-9181676
#pragma kernel ClearVoxelsKernel
#pragma kernel BuildVoxelsKernel
#pragma kernel JumpFloodKernel
 
struct Seed
{
    float3 Location;
    float3 Color;
};
@RednibCoding
RednibCoding / 0 Odin debugging on windows.md
Last active May 6, 2025 10:52
Odin debugging on windows with vscode. See: readme

Setup

To setup debugging for Odin programs on Windows with VsCode follow these steps:

  • make sure you have the C/C++ extension pack (VsCode extension) installed
  • create a .vscode folder at the root of your Odin project
  • copy the launch.json and tasks.json into it
  • click on the debug tab in VsCode, then click on the debug button at the top (or press F5)

Note: if you want to use a starter template which also sets up a tracking allocator which tracks and reports memory leaks you can use: https://github.com/RednibCoding/Odin-Starter

@kraj0t
kraj0t / .Raycast inside RenderTexture.gif
Last active March 3, 2024 10:50
[Unity] PhysicsRaycaster for indirectly casting rays inside a quad that has a RenderTexture on it
.Raycast inside RenderTexture.gif
@ScottJDaley
ScottJDaley / Outline.shader
Last active May 12, 2025 04:36
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties