Skip to content

Instantly share code, notes, and snippets.

View zensharp's full-sized avatar
🌿
budding

Zensharp zensharp

🌿
budding
  • United States
View GitHub Profile
@zensharp
zensharp / Shaders.md
Last active February 7, 2023 17:40
Shader Snippets

CG Syntax

Declare constant

static const float PI = 3.14;

Declare constant expression

#define INV_FADE_DISTANCE 1.0 / (_FarFade - _NearFade)
public bool TryGetSecant(Vector3 position, Vector3 velocity, Vector3 acceleration, float arcDistance, out Vector3 secant) {
if (acceleration == Vector3.zero) {
secant = velocity;
return false;
}
var axis = Vector3.Cross(velocity, acceleration);
if (axis == Vector3.zero) {
secant = velocity;
@zensharp
zensharp / Fade Parameters.md
Last active January 18, 2021 16:48
Small writeup on FadeParams shader vectors

Overview

Returns a packed "FadeParams" vector for a shader. The standard packing format is:

Component Value
x near
y 1 / (far - near)
z (unused)
w (unused)