Skip to content

Instantly share code, notes, and snippets.

View StagPoint's full-sized avatar

StagPoint Software StagPoint

  • StagPoint Software
  • Seattle, WA
View GitHub Profile
@Fewes
Fewes / Tricubic.cginc
Last active May 7, 2024 07:16
Tricubic texture sampling using 8 trilinear samples
#ifndef TRICUBIC_INCLUDED
#define TRICUBIC_INCLUDED
float4 Cubic(float v)
{
float4 n = float4(1.0, 2.0, 3.0, 4.0) - v;
float4 s = n * n * n;
float x = s.x;
float y = s.y - 4.0 * s.x;
float z = s.z - 4.0 * s.y + 6.0 * s.x;
@westonsoftware
westonsoftware / StartScript.cs
Last active May 15, 2025 16:05
Stride 3D rendered into Avalonia
using System;
using Stride.Core.Mathematics;
using Stride.Engine;
using Stride.Rendering;
using Stride.Graphics;
using System.IO;
namespace InfinityGame
{
public class StartScript : SyncScript
Shader "Hidden/JumpFloodOutline"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "PreviewType" = "Plane" }
Cull Off ZWrite Off ZTest Always
@brihernandez
brihernandez / LayerIDs.cs
Last active November 10, 2023 00:54
Simple wrapper classes for handling layer related operations in Unity.
using UnityEngine;
/// <summary>
/// Convenience class for handling layer related operations and lookups in Unity.
/// </summary>
public readonly struct UnityLayer
{
/// <summary>
/// Name of the layer as defined in the Tags and Layers window in Unity.
/// </summary>
@T5impact
T5impact / AtmosphericScattering.shader
Last active February 22, 2024 11:51
Atmospheric Scattering Shader for Unity that works in the URP (feel free to use this in any projects) (default settings are tailored towards an earth-like atmosphere)
Shader "Atmosphere/Atmospheric Scattering"
{
Properties
{
_LightIntensity("Light Intensity", Float) = 30
_LightColor("Light Color", Color) = (1,1,1)
_LightDirection("Light Direction", Vector) = (0,0,1)
_PlanetRadius("Planet Radius", Float) = 47
_AtmosphereRadius("Atmosphere Radius", Float) = 50
_Steps ("Steps", Int) = 20
@brihernandez
brihernandez / FloatingOrigin.cs
Last active June 3, 2025 17:58
Floating origin to handle large worlds in Unity.
// Based on the Unity Wiki FloatingOrigin script by Peter Stirling
// URL: http://wiki.unity3d.com/index.php/Floating_Origin
using UnityEngine;
using UnityEngine.SceneManagement;
public class FloatingOrigin : MonoBehaviour
{
[Tooltip("Point of reference from which to check the distance to origin.")]
public Transform ReferenceObject = null;
@FreyaHolmer
FreyaHolmer / FlyCamera.cs
Last active April 24, 2025 21:16
A camera controller for easily flying around a scene in Unity smoothly. WASD for lateral movement, Space & Ctrl for vertical movement, Shift to move faster. Add this script to an existing camera, or an empty game object, hit play, and you're ready to go~
using UnityEngine;
[RequireComponent( typeof(Camera) )]
public class FlyCamera : MonoBehaviour {
public float acceleration = 50; // how fast you accelerate
public float accSprintMultiplier = 4; // how much faster you go when "sprinting"
public float lookSensitivity = 1; // mouse look sensitivity
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable
@LotteMakesStuff
LotteMakesStuff / NetworkingTools.cs
Last active April 28, 2023 09:49
Since Unity 2018.3 we've had this cool new tool called [SettingsProvider] that we can use to add custom settings menu into Unitys settings screens. This short example shows how i use [SettingsProvider] and some [MenuItems] to help build and run test clients when im developing a multiplayer game. My usecase is that i want a quick way to build and…
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using Debug = UnityEngine.Debug;
public static class NetworkingTools
{
@TheAllenChou
TheAllenChou / Seek.cs
Last active February 2, 2025 16:22
Value Seeking
// example of how to move a current value towards a target value at a constant speed
// without going over the target value
// formula is the same for vectors of any dimension
Vector3 Seek(Vector3 currentValue, Vector3 targetValue, float maxSpeed, float dt)
{
// delta/difference from current value to target value
Vector3 delta = targetValue - currentValue;
// don't take the square root of magnitude yet
// so we can potentially early out on degenerate case of currenvValue ~= targetValue