Created
December 18, 2013 20:16
-
-
Save v21/8029204 to your computer and use it in GitHub Desktop.
An implementation of Photoshop's "Screen" blend mode for Unity3D.
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
Shader "Sunspots" { | |
Properties { | |
_MainTex ("Texture1 (RGB)", 2D) = "white" {} | |
_Color ("Main Color", Color) = (1,1,1,1) | |
} | |
Category { | |
Tags {"RenderType"="Opaque" "Queue"="Transparent"} | |
Lighting Off | |
BindChannels { | |
Bind "Color", color | |
Bind "Vertex", vertex | |
Bind "Texcoord", Texcoord | |
} | |
//screen 1 - (1 - a) * (1 - b) | |
SubShader { | |
Pass { | |
ZWrite Off | |
Cull Off | |
Blend One One | |
BlendOp Sub | |
SetTexture [_MainTex] { | |
constantColor (1,1,1,1) | |
Combine constant | |
} | |
} | |
Pass { | |
ZWrite Off | |
Cull Off | |
Blend Zero OneMinusSrcColor | |
BlendOp Add | |
SetTexture [_MainTex] { | |
constantColor [_Color] | |
Combine texture * constant | |
} | |
} | |
Pass { | |
ZWrite Off | |
Cull Off | |
Blend One One | |
BlendOp Sub | |
SetTexture [_MainTex] { | |
constantColor [_Color] | |
} | |
SetTexture [_MainTex] { | |
constantColor (1,1,1,1) | |
Combine constant, previous | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment