Skip to content

Instantly share code, notes, and snippets.

@oneandonlyoddo
oneandonlyoddo / luminance of a pixel
Last active November 15, 2019 16:09
luminance of a pixel
/*
"The colors are not evenly interpreted by our eyes."
source: https://cs.stackexchange.com/questions/11876/how-do-i-compute-the-luminance-of-a-pixel
*/
float luminance(float r, float g, float b){
return (r * 0.3) + (g * 0.59) + (b * 0.11);
}
// Unity Shader Doc https://docs.unity3d.com/Manual/SL-ShaderPrograms.html
// Unity Shader Doc https://docs.unity3d.com/Manual/SL-Reference.html
Shader "Custom/Test/foo shader" {
//Variables
Properties{
// float, 2D (Texture), color etc.
_MainTexture("Main Color (RGB)", 2D) = "white" {}
_Color("Color", Color) = (1,1,1,1)