Skip to content

Instantly share code, notes, and snippets.

// http://graphicrants.blogspot.com/2009/04/rgbm-color-encoding.html
float4 RGBMEncode( float3 color ) {
float4 rgbm;
color *= 1.0 / 6.0;
rgbm.a = saturate( max( max( color.r, color.g ), max( color.b, 1e-6 ) ) );
rgbm.a = ceil( rgbm.a * 255.0 ) / 255.0;
rgbm.rgb = color / rgbm.a;
return rgbm;
}
Shader "Custom/Phong Tessellation Deferred"
{
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
[NoScaleOffset][Normal] _NormalTex ("Normal (RGB)", 2D) = "bump" {}
_NormalFactor ("Normal Strength", Range(0, 2)) = 1
_Glossiness ("Smoothness", Range(0,1)) = 0.5
Shader "Custom/Tessellation cg"
{
Properties
{
_ColorMap ("Color Map", 2D) = "black" {}
_TessellationFactor ("Tessellation Factor", Range(0, 64)) = 16
}
SubShader
{
Tags {"RenderType"="Opaque"}
@bricevdm
bricevdm / StandardCurved.shader
Created June 6, 2018 00:00
Standard Unity Surface Shader modification with distance-based quadratic curvature applied in world space
Shader "Custom/StandardCurved" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
_Curvature ("Curvature", Range(0, 0.1)) = 0.01
}
SubShader {
Tags { "RenderType"="Opaque" }