Skip to content

Instantly share code, notes, and snippets.

View pema99's full-sized avatar

Pema Malling pema99

View GitHub Profile
@pema99
pema99 / QuadIntrinsics.cginc
Last active July 3, 2024 09:48
Emulated Quad and Wave intrinsics for basic fragment shaders
// SPDX-License-Identifier: MIT
// Author: pema99
// This file contains functions that simulate Quad and Wave Intrinsics without access to either.
// For more information on those, see: https://github.com/Microsoft/DirectXShaderCompiler/wiki/Wave-Intrinsics
// To use the functions, you must call SETUP_QUAD_INTRINSICS(pos) at the start of your fragment shader,
// where 'pos' is the pixel position, ie. the fragment input variable with the SV_Position semantic.
// Note that some functions will require SM 5.0, ie. #pragma target 5.0.
@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
@pema99
pema99 / AudioLinkUI.shader
Last active February 26, 2024 09:12
AudioLinkUI V3
Shader "AudioLink/AudioLinkUI"
{
Properties
{
_Gain("Gain", Range(0, 2)) = 1.0
[ToggleUI] _Autogain("Autogain", Float) = 0.0
_Threshold0("Low Threshold", Range(0, 1)) = 0.5
_Threshold1("Low Mid Threshold", Range(0, 1)) = 0.5
_Threshold2("High Mid Threshold", Range(0, 1)) = 0.5
Shader "Unlit/Shadowed"
{
SubShader
{
Pass
{
Tags { "LightMode"="Always" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
Shader "Unlit/AudioLinkUI"
{
Properties
{
}
SubShader
{
Pass
{
CGPROGRAM
float3 drawTopArea(float2 uv)
{
float3 color = FOREGROUND_COLOR;
float areaWidth = 1.0 - FRAME_MARGIN * 2;
float areaHeight = 0.35;
float boxWidth = areaWidth / 4.0;
for (uint i = 0; i < 4; i++)
{
float3 drawTopArea(float2 uv)
{
float3 color = FOREGROUND_COLOR;
float areaWidth = 1.0 - FRAME_MARGIN * 2;
float areaHeight = 0.35;
float boxWidth = areaWidth / 4.0;
for (uint i = 0; i < 4; i++)
{
This file has been truncated, but you can view the full file.
Module {
types: {
[1]: Type {
name: None,
inner: Scalar {
kind: Float,
width: 4,
},
},
[2]: Type {
This file has been truncated, but you can view the full file.
Module {
types: {
[1]: Type {
name: None,
inner: Scalar {
kind: Float,
width: 4,
},
},
[2]: Type {
// Input program
sum List 'a =
| Cons 'a * List 'a
| Nil unit
let iota = [n]
let inner = rec [inner] [acc]
if acc >= n then Nil ()
else Cons (acc, inner (acc + 1))