Skip to content

Instantly share code, notes, and snippets.

View ncthbrt's full-sized avatar
🧶
Coding

Natalie Cuthbert ncthbrt

🧶
Coding
View GitHub Profile

Module System

New keyword mod allows declaration of a sub-module. This allows discovery of modules within a crate as well as providing a single entry point for processing preprocessor directives. Modules follow rust rules such that if a crate is called x which has a sub-module a, the canonical name for the module will be x::a. x::a is added to x's symbol scope. Additional keywords self, super, and crate allow users to refer to modules relative to the current module.

Future work

  • Allowing declaration of sub module code inline to the parent module
  • Rust macro that creates a set of shader modules embedded in the code based off of rust/cargo file resolution logic. These would also include the encased shader types in the rust code if no preprocessor directives would influence the result.
  • Allow modules in the same crate to mutually import symbols from one another. This will require parsing wgsl to generate the headers.
  • Later: Extension to the language to allow for definition of mo
@felixhaeberle
felixhaeberle / timeAgo.ts
Last active May 10, 2024 13:43
TypeScript: Get time distance as human readable string
// takes either a unix time number, string or a Date object and returns time string
export const timeAgo = (time: number | string | Date) => {
switch (typeof time) {
case "number":
break;
case "string":
time = +new Date(time);
break;
case "object":
@munrocket
munrocket / wgsl_3d_sdf.md
Last active March 2, 2025 22:13
WGSL 3D SDF Primitives

WGSL 3D SDF Primitives

Revision: 06.08.2023, https://compute.toys/view/407

Sphere - exact

fn sdSphere(p: vec3f, r: f32) -> f32 {
  return length(p) - r;
}
Shader "Hidden/JumpFloodOutline"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "PreviewType" = "Plane" }
Cull Off ZWrite Off ZTest Always
// Apply this to a Camera, and make a material with the shader.
public class CameraRenderWithMaterial : MonoBehaviour
{
public Material material;
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
Graphics.Blit(source, destination, material);
}
}
@ammarshah
ammarshah / all_email_provider_domains.txt
Last active April 17, 2025 20:57
A list of all email provider domains (free, paid, blacklist etc). Some of these are probably not around anymore. I've combined a dozen lists from around the web. Current "major providers" should all be in here as of the date this is created.
0-mail.com
007addict.com
020.co.uk
027168.com
0815.ru
0815.su
0clickemail.com
0sg.net
0wnd.net
0wnd.org
@EddieCameron
EddieCameron / EdgeDetect.cs
Created September 3, 2017 00:08
EdgeDetection in new Unity Postprocessing Stack
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
[Serializable]
[PostProcess( typeof( EdgeDetectRenderer ), PostProcessEvent.BeforeStack, "Custom/EdgeDetectNormals" )]
public sealed class EdgeDetect : PostProcessEffectSettings {
public enum EdgeDetectMode {
@benloong
benloong / UIDissolve.shader
Last active February 11, 2025 15:39 — forked from nukeop/dissolve.shader
Dissolve shader for Unity
Shader "UI/Dissolve"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_StencilComp ("Stencil Comparison", Float) = 8
_Stencil ("Stencil ID", Float) = 0
_StencilOp ("Stencil Operation", Float) = 0
@xanathar
xanathar / Easing.cs
Created March 17, 2016 23:54
Robert Penner's easing equations for Unity
/**
* Easing
* Animates the value of a float property between two target values using
* Robert Penner's easing equations for interpolation over a specified Duration.
*
* Original Author: Darren David darren-code@lookorfeel.com
*
* Ported to be easily used in Unity by Marco Mastropaolo
*
* Credit/Thanks:
@ruby0x1
ruby0x1 / tilt.shift.glsl
Last active November 5, 2024 10:54
Tilt shift shader, modified from something @grapefrukt gave me
// Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/)
// Read http://notes.underscorediscovery.com/ for context on shaders and this file
// License : MIT
uniform sampler2D tex0;
varying vec2 tcoord;
varying vec4 color;
/*
Take note that blurring in a single pass (the two for loops below) is more expensive than separating