<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mike R :: R ekim &#187; Overlay</title>
	<atom:link href="http://www.rekim.com/tag/overlay/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rekim.com</link>
	<description>Mike Robinson</description>
	<lastBuildDate>Sat, 27 Jan 2024 18:04:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Making a Sprite shader in Unity with colour applied as overlay</title>
		<link>https://www.rekim.com/2017/07/05/making-a-sprite-shader-in-unity-with-colour-applied-as-overlay/</link>
		<comments>https://www.rekim.com/2017/07/05/making-a-sprite-shader-in-unity-with-colour-applied-as-overlay/#comments</comments>
		<pubDate>Wed, 05 Jul 2017 21:04:43 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Unity]]></category>
		<category><![CDATA[Overlay]]></category>
		<category><![CDATA[Shaders]]></category>

		<guid isPermaLink="false">http://www.rekim.com/?p=266</guid>
		<description><![CDATA[Hello, First post on here in years&#8230;.. I wanted to get the sprite colour in Unity to be applied using a Photoshop style overlay layer mode. I found this page here that lists the calculations for all the Photoshop blend &#8230; <a href="https://www.rekim.com/2017/07/05/making-a-sprite-shader-in-unity-with-colour-applied-as-overlay/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
First post on here in years&#8230;..</p>
<p>I wanted to get the sprite colour in Unity to be applied using a Photoshop style overlay layer mode.</p>
<p>I found this page here that lists the calculations for all the Photoshop blend modes</p>
<p><a title="Photoshop blend mode calculations" href="http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html">http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html</a></p>
<p>It has a cool space background as well which is a bonus.</p>
<p>Anyway. With that I created a new shader using the default sprite shader and used the following in the fragment shader.</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">fixed4 c = SampleSpriteTexture (IN.texcoord);// * IN.color;<br />
c.r = (step(0.5f,c.r)*(1-(1-2*(c.r-0.5))*(1-IN.color.r))) + (step(c.r,0.5f)*(2*c.r)*IN.color.r);<br />
c.g = (step(0.5f,c.g)*(1-(1-2*(c.g-0.5))*(1-IN.color.g))) + (step(c.g,0.5f)*(2*c.g)*IN.color.g);<br />
c.b = (step(0.5f,c.b)*(1-(1-2*(c.b-0.5))*(1-IN.color.b))) + (step(c.b,0.5f)*(2*c.b)*IN.color.b);<br />
c.rgb *= c.a;<br />
return c;</div></div>
<p>With that you can create a grey scale image with highlights and shadows and tint it.</p>
<p><img src="https://image.ibb.co/e2Kaea/Screenshot_2017_07_05_21_55_24.png" alt="overlay coloured balls" /></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.rekim.com/2017/07/05/making-a-sprite-shader-in-unity-with-colour-applied-as-overlay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
