Skip to content

Instantly share code, notes, and snippets.

View cs-altshift's full-sized avatar

Christophe SAUVEUR cs-altshift

View GitHub Profile
@cs-altshift
cs-altshift / TestRendererFeature.cs
Created January 19, 2023 15:25
Simple Fog (URP)
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class TestRendererFeature : ScriptableRendererFeature
{
private TestRenderPass testRenderPass;
public Material fogMaterial;
public Color fogColor;
@cs-altshift
cs-altshift / ExtendedColors.cs
Created November 2, 2022 10:49
Extended Colors for Unity
using UnityEngine;
namespace AltShift.Productivity
{
// Extracted from: https://www.december.com/html/spec/colorpercompact.html
public static class ExtendedColor
{
public static Color _100_euro = new Color(0.53f, 0.78f, 0.49f);
public static Color _20_pound = new Color(0.64f, 0.4f, 0.51f);
public static Color _6_ball = new Color(0.11f, 0.39f, 0.33f);
@cs-altshift
cs-altshift / SeededRandomNumberGenerator.cs
Last active February 9, 2023 07:59
C# Allocation-free Seeded Random Number Generator
using System;
namespace AltShift.Maths.Randomization
{
// No-alloc version coded from Random source code
// https://referencesource.microsoft.com/#mscorlib/system/random.cs
public unsafe struct SeededRandomNumberGenerator
{
private const int MSEED = 161803398;
private const int MZ = 0;
@cs-altshift
cs-altshift / ScreenSpaceNormals.shader
Created December 9, 2021 10:23
Screen-space normals shader for Unity - Compatible with URP
Shader "Unlit/Screen Space Normals"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
@cs-altshift
cs-altshift / CS-Rim.compute
Created September 24, 2021 11:45
Crying Suns' Rim Light Effect Normal Map Generator
#pragma kernel CSMain
RWTexture2D<float4> Result;
Texture2D<float4> InputTexture;
uint textureWidth;
uint textureHeight;
uint maxIteration;
[numthreads(8,8,1)]
@cs-altshift
cs-altshift / CC-Glass.shader
Created July 28, 2021 07:29
Crying Suns Command-Center Glass Shader
Shader "Crying Suns/Command Center Glass"
{
Properties
{
[PerRendererData] _MainTex ("Main Texture (ignored)", 2D) = "white" {}
[NoScaleOffset] _ReflectionTex ("Reflection Texture", 2D) = "black" {}
_ReflectionAlpha ("Reflection Alpha", Range(0, 1)) = 0.25
_ReflectionScale ("Reflection Scale", Range(0, 1)) = 1
[HideInInspector] _SunCenteredViewportPos ("Sun Centered Viewport Position", Vector) = (0, 0, 0, 0)
[HideInInspector] _SunAngle ("Sun Angle", Float) = 0
@cs-altshift
cs-altshift / FogComponent.cs
Last active April 7, 2023 06:02
Simple Fog Shader
using UnityEngine;
[RequireComponent(typeof(Camera))]
public class FogComponent : MonoBehaviour
{
public Shader myFogShader;
public Color fogColor = Color.red;
private Material myFogMaterial;
@cs-altshift
cs-altshift / AnimatedAlpha.shader
Created June 4, 2021 12:06
Crying Suns' Animated Alpha Shader
Shader "Animated Alpha"
{
Properties
{
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
_TargetColor ("Target Color", Color) = (1, 1, 1, 0)
_AlphaAttenuation ("Alpha Attenuation", Vector) = (0, 0.25, 0.75, 1)
}
SubShader