Skip to content

Instantly share code, notes, and snippets.

@mrange
mrange / README.md
Last active February 18, 2023 11:33
The joy of Shadertoy

The joy of Shadertoy

Shadertoy is an online platform where programmers can create and share shaders - small programs that run on a GPU and render graphics and animations in real-time. The platform has become popular among graphics enthusiasts and game developers, as it provides an accessible and engaging environment for exploring the capabilities of modern graphics hardware.

image shadertoy.com

The joy of Shadertoy

For those who enjoy programming and are interested in graphics, there are few experiences as rewarding as writing shaders on Shadertoy. In this blog post, we'll explore the joy of programming shaders on Shadertoy, and why it has become such a popular platform among graphics enthusiasts.

@mrange
mrange / Example.cs
Created December 20, 2022 18:30
Invariant String Interpolation
namespace SomeLib
{
using System.Globalization;
using System.Runtime.CompilerServices;
static partial class StringInterpolation
{
// This is to allow to use fast string interpolation
public static string FastInvariantInterpolation(ref DefaultInterpolatedStringHandler handler)
{
@mrange
mrange / Program.fs
Created November 28, 2022 06:37
Illustrating invalid and ambiguous dates in F#
open System
open System.Globalization
let dtos =
let ts = TimeSpan(2, 0, 0)
[|
// Nothing weird about this date
DateTimeOffset(2022, 6, 22, 2, 30, 0, ts)
// This time is invalid in CEST because clock is set ahead at this date
DateTimeOffset(2022, 3, 27, 2, 30, 0, ts)
@mrange
mrange / 0_README.md
Last active May 26, 2023 03:58
Happy little terminal shader

Install shader

  1. Save happy.hlsl to disk, note the path for later.
  2. Open Windows terminal settings
  3. Open settings as JSON
  4. Add a custom shader to the default profile, see excerpt below.
{
 "profiles": {
@mrange
mrange / build.cake
Last active October 8, 2022 19:38
Cake model update
#nullable enable
#addin nuget:?package=Cake.Git&version=2.0.0
var target = Argument("target", "GithubAction");
var repoUri = "https://github.com/mrange/cake.tool.experiments.git";
record BuildData(
DirectoryPath RootPath
, DirectoryPath GithubPath
, DirectoryPath RepoPath
@mrange
mrange / Microsoft.PowerShell_profile.ps1
Created September 28, 2022 07:55
mrange powershell prompt
# Stored under My Documents\WindowsPowerShell
function global:prompt
{
"╭─ PS $($executionContext.SessionState.Path.CurrentLocation) $('+' * ($nestedPromptLevel))`n╰─$ ";
}
@mrange
mrange / commit-msg
Created September 26, 2022 09:28
gerrit commit hook
#!/bin/sh
# From Gerrit Code Review 2.12.3
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@mrange
mrange / FsDistanceField.fsproj
Last active September 24, 2022 10:42
F# Distance Field
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
@mrange
mrange / 0_readme.md
Last active May 26, 2023 03:58
Reactor shader inspired by Microsoft Reactor Graphics. For us in windows terminal

Install shader

Note: Doesn't work on latest preview of windows terminal (2022-09-15) but should work on later previews.

  1. Save reactor.hlsl to disk, note the path for later.
  2. Open Windows terminal settings
  3. Open settings as JSON
  4. Add a custom shader to the default profile, see excerpt below.
@mrange
mrange / thindal.hlsl
Created September 11, 2022 10:38
Thindal Windows Terminal
#define WINDOWS_TERMINAL
Texture2D shaderTexture;
SamplerState samplerState;
// --------------------
#if defined(WINDOWS_TERMINAL)
cbuffer PixelShaderSettings {
float Time;
float Scale;