Created
June 21, 2013 07:19
-
-
Save ialex32x/5829466 to your computer and use it in GitHub Desktop.
Unity3D shader scrabble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
uniform sampler2D _Ramp; | |
uniform half4 _Color; | |
struct v2f { | |
float4 pos : SV_POSITION; | |
float4 uv : TEXCOORD0; | |
}; | |
v2f vert (appdata_base v) { | |
v2f o; | |
o.pos = mul (UNITY_MATRIX_MVP, v.vertex); | |
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); | |
o.uv = float4( dot(viewDir,v.normal), 0.5, 0.0, 1.0 ); | |
return o; | |
} | |
half4 frag(v2f v) : COLOR { | |
return tex2D(_Ramp, v.uv.xy) * _Color; | |
} | |
ENDCG | |
*/ |
Author
ialex32x
commented
Jun 21, 2013
// *****************
// compute luminance
// *****************
float3 rgb2lum = float3(0.30, 0.59, 0.11);
luminance = dot(col.rgb, rgb2lum);
// *****************
// TRANSFORM_TEX
// *****************
define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment