Skip to content

Instantly share code, notes, and snippets.

@unitycoder
unitycoder / TerrainShaderTessellationDiffuse.shader
Created December 14, 2018 19:33
Terrain Shader Tesselation Diffuse
// Author: Przemyslaw Zaworski
// Modified version of original:
// https://github.com/przemyslawzaworski/Unity3D-CG-programming/blob/master/terrain_shader_tessellation_diffuse.shader
// Shader supports maximum four splat textures (Splat and Normal maps) with triangle tessellation.
// Works seamlessly with built-in Terrain Component. Lambert light model (directional) with shadow casting and receiving.
// https://forum.unity.com/threads/how-to-dynamically-tessellate-a-mesh.597469/#post-3997999
Shader "Terrain Shader Tessellation Diffuse"
{
Properties
@zeux
zeux / vertexcodec-comparison.txt
Last active May 23, 2019 16:45
Comparison of vertexcodec/indexcodec from meshoptimizer with Google Draco
Using fixed-point encoding for position (14 bits per component) and texture coordinates (12 bits per component), with 32-bit index buffer
and this vertex format:
// 12 bytes
struct PackedVertexOct
{
unsigned short px, py, pz;
unsigned char nu, nv; // octahedron encoded normal, aliases .pw
unsigned short tx, ty;
};
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active July 18, 2026 13:37
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
@smkplus
smkplus / UnityShaderCheatSheet.md
Last active June 5, 2026 02:15
Controlling fixed function states from materials/scripts in Unity

16999105_467532653370479_4085466863356780898_n

Shader "MaterialPropertyDrawer"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
 
[HideInInspector] _MainTex2("Hide Texture", 2D) = "white" {}
@takeit
takeit / INSTALL.md
Last active May 13, 2026 23:08
Write to NTFS on macOS Sierra (osxfuse + ntfs-3g)
  1. Install osxfuse:
brew cask install osxfuse
  1. Reboot your Mac.

  2. Install ntfs-3g:

@hiroki-o
hiroki-o / AddressableAssetSettingEditor.cs
Created May 2, 2017 06:31
Addressable Asset Settings Editor Tool (for debug)
using System.Collections.Generic;
using UnityEditorInternal;
using UnityEngine;
using UnityEditor.Hardware;
using UnityEditor.VersionControl;
#if ENABLE_CLOUD_SERVICES_COLLAB
using UnityEditor.Collaboration;
using UnityEditor.Web;
#endif
@turtleDev
turtleDev / pack.lua.md
Last active December 5, 2024 19:04
pack.lua | The Lua module bundler
@marcelsamyn
marcelsamyn / Structuring Neat .NET Core Command Line Apps Neatly.org
Created September 7, 2016 07:30
Structuring Neat .NET Core Command Line Apps Neatly
@unitycoder
unitycoder / if-branchless.shader
Last active July 10, 2026 10:02
Avoiding Branching / Conditionals in Shaders Fast No If
"The common wisdom of "don't use conditionals in shaders" is one of my biggest frustrations with how shaders are taught.
step(y, x) _is_ a conditional! It compiles to identical code as:
float val = (x >= y ? 1.0 : 0.0)
or
float val = 0.0;
if (x >= y) val = 1.0;"
https://twitter.com/bgolus/status/1235254923819802626
// Performing shader divisions without diving *rcp = approximation of 1/x
float myDividedVal = myValToDivide * rcp(myDivider);
@bkaradzic
bkaradzic / orthodoxc++.md
Last active May 16, 2026 11:21
Orthodox C++

Orthodox C++

This article has been updated and is available here.