Skip to content

Instantly share code, notes, and snippets.

@laundmo
laundmo / lerp.py
Last active September 5, 2024 10:38
lerp, inverse lerp and remap in python
def lerp(a: float, b: float, t: float) -> float:
"""Linear interpolate on the scale given by a to b, using t as the point on that scale.
Examples
--------
50 == lerp(0, 100, 0.5)
4.2 == lerp(1, 5, 0.8)
"""
return (1 - t) * a + t * b
@takumifukasawa
takumifukasawa / CustomLitShader.cs
Last active February 25, 2023 16:28
Examples of Custom URP Lit Shader and Custom Shader GUI Script: Unity2019.4.21f, URP7.8.3
using System;
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.Universal.ShaderGUI;
class CustomLitShader : BaseShaderGUI
{
// Properties
private LitGUI.LitProperties litProperties;
@loopervfx
loopervfx / TouchdesignerPerlinSimplexNoise.glsl
Created June 11, 2019 03:30
Touchdesigner perlin + simplex noise
#version 330
#extension GL_NV_gpu_shader5 : enable
#extension GL_NV_bindless_texture : enable
#extension GL_ARB_shading_language_include : enable
/** BEGIN TD COMMON UTIL UNIFORMS Garbagesdmwk7**/
uniform sampler2D sTDNoiseMap;
uniform sampler1D sTDSineLookup;
uniform sampler2D sTDWhite2D;
uniform sampler3D sTDWhite3D;
uniform sampler2DArray sTDWhite2DArray;
@companje
companje / map.glsl
Created January 23, 2018 22:46
map() function for GLSL known from Processing & openFrameworks
float map(float value, float min1, float max1, float min2, float max2) {
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active November 10, 2024 05:01
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
# Taken from https://forums.aws.amazon.com/thread.jspa?messageID=332091
sudo su -
cd /usr/local/bin
mkdir ffmpeg
cd ffmpeg
wget http://ffmpeg.gusari.org/static/64bit/ffmpeg.static.64bit.latest.tar.gz
tar -xzf ffmpeg.static.64bit.latest.tar.gz
vec2 rotate(vec2 v, float a) {
float s = sin(a);
float c = cos(a);
mat2 m = mat2(c, s, -s, c);
return m * v;
}
@mbostock
mbostock / .block
Last active July 27, 2023 08:06
Force-Directed Web Worker
license: gpl-3.0
height: 960
@galek
galek / pbr.glsl
Created November 4, 2015 11:10
PBR GLSL SHADER
in vec2 v_texcoord; // texture coords
in vec3 v_normal; // normal
in vec3 v_binormal; // binormal (for TBN basis calc)
in vec3 v_pos; // pixel view space position
out vec4 color;
layout(std140) uniform Transforms
{
mat4x4 world_matrix; // object's world position
@irazasyed
irazasyed / sourceTree-git-fix.md
Created March 11, 2014 15:42
Git: SourceTree - Remote Error fix for Windows Users.

This works if you authenticate using a public/private key pair:

  • Open Sourcetree and go to "Tools > Create or Import SSH Keys" (this will open a PuTTY Key Generator window), Set the number of bits in a generated key to 2048 and click on "Generate".

  • Once generated go to git server panel and navigate to "My account > Profile > SSH Keys" and click "Add a public key".

  • Copy the generated public key from the "PuTTY Key Generator" window ("Public key for pasting into OpenSSH authorized_keys file:") to git panel and save it.

  • In the "PuTTY Key Generator" window enter a "Key passphrase" and "Confirm passphrase" and click "Save private key" and Public Key (for other uses too). Make sure to save it somewhere where you can find it again.