<?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>labs.hellokeita.com &#187; PixelBender</title>
	<atom:link href="http://labs.hellokeita.com/category/pixelbender/feed/" rel="self" type="application/rss+xml" />
	<link>http://labs.hellokeita.com</link>
	<description>Yet another labs blog</description>
	<lastBuildDate>Thu, 01 Dec 2011 20:14:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to use custom Shaders in Astro(Flash 10)</title>
		<link>http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/</link>
		<comments>http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/#comments</comments>
		<pubDate>Mon, 19 May 2008 17:04:54 +0000</pubDate>
		<dc:creator>keita</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Astro]]></category>
		<category><![CDATA[PixelBender]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/</guid>
		<description><![CDATA[Here is a simple example using the sample exposure shader that comes with the Adobe&#8217;s PixelBender tutorial.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Shader_1477371512"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/shader/Shader.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/shader/Shader.swf"
			name="fm_Shader_1477371512"
			width="400"
			height="300">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
(Moving the mouse from horizontally will change the exposure value)
Firstly, you need the PixelBenderToolkit(http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit).
I used the Exposure sample code from Adobe&#8217;s Pixel Bender tutorial (http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit:Tutorial)
[code lang="cpp"]

  kernel NewFilter
  <  [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a simple example using the sample exposure shader that comes with the Adobe&#8217;s PixelBender tutorial.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Shader_646312910"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/shader/Shader.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/shader/Shader.swf"
			name="fm_Shader_646312910"
			width="400"
			height="300">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
(Moving the mouse from horizontally will change the exposure value)</p>
<p>Firstly, you need the PixelBenderToolkit(<a href="http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit" target="_blank">http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit</a>).</p>
<p>I used the Exposure sample code from Adobe&#8217;s Pixel Bender tutorial (<a href="http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit:Tutorial" target="_blank">http://labs.adobe.com/wiki/index.php/Pixel_Bender_Toolkit:Tutorial</a>)</p>
<p>[code lang="cpp"]<br />
<languageversion><br />
  kernel NewFilter<br />
  <  namespace : "your namespace";<br />
    vendor : "your vendor";<br />
    version : 1;<br />
    description : "your description";<br />
  ><br />
  {<br />
    input image4 src;<br />
    output pixel4 dst;<br />
    parameter float exposure<br />
    <<br />
      minValue:float(-0.5);<br />
      maxValue:float(0.5);<br />
      defaultValue:float(0.0);<br />
    >;<br />
    void<br />
    evaluatePixel()<br />
    {<br />
      float4 inputColor = sampleNearest(src, outCoord());<br />
      dst.rgb = pow(inputColor.rgb, float3(1.0 - exposure));<br />
      dst.a = inputColor.a;<br />
    }<br />
  }<br />
[/code]</p>
<p>On PixelBender Toolkit, you can export it as Byte Code Filter for Flash from the File menu.</p>
<p>Exporting it, you will have a .pbj file to be loaded as ByteArray from Flash just like this.</p>
<p>[code lang="actionscript"]<br />
var urlLoader:URLLoader = new URLLoader();<br />
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;<br />
urlLoader.addEventListener(Event.COMPLETE, urlLoaderComplete);<br />
urlLoader.load(new URLRequest("exposure.pbj"));<br />
[/code]</p>
<p>And after that, creating a Shader instance, and also the ShaderFilter to be applied on a DisplayObject.</p>
<p>[code lang="actionscript"]<br />
private function urlLoaderComplete(ev:Event):void<br />
{<br />
  shader = new Shader(ev.currentTarget.data as ByteArray);<br />
  shaderFilter = new ShaderFilter(shader);<br />
  filters = [shaderFilter];<br />
}<br />
[/code]</p>
<p>Once you have the shader instance, you can change the shader parameters by doing the following.<br />
[code lang="actionscript"]</p>
<p>shader.data.exposure.value = [0.5];</p>
<p>filters = [shaderFilter]; //re-applying the filter</p>
<p>[/code]</p>
<p>Easy huh?</p>
<p><a href="http://labs.hellokeita.com/files/shader/Shader.zip">Here is all the source from this little tutorial.</a></p>
<p>Enjoy.</p>
<p>(update. Just because Zeh said to)<br />

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TwirlShader_1108974839"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/files/shader/TwirlShader.swf" />
	<param name="bgcolor" value="#ffffff" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/files/shader/TwirlShader.swf"
			name="fm_TwirlShader_1108974839"
			width="400"
			height="300">
		<param name="bgcolor" value="#ffffff" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object><br />
One more example using the <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&amp;loc=en_us&amp;extid=1536021" target="_blank">TwirlFilter</a> created by Elba Sobrino.<br />
Works the same way, move the mouse along the image.</p>
<a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/&ztz=How to use custom Shaders in Astro(Flash 10)'><img src='http://labs.hellokeita.com/wp-content/plugins/hexosearch-button/logo16x16.png' width='16' height='16' border='0' style='padding:0px 5px 0px 0px;vertical-align:middle' alt='Vote in HexoSearch' title='Vote in HexoSearch' /></a> <span style='vertical-align:middle'><a href='http://www.hexosearch.com/se/submit.aspx?zlvz=2&zqz=&zurlz=http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/&ztz=How to use custom Shaders in Astro(Flash 10)'>Vote</a></span>]]></content:encoded>
			<wfw:commentRss>http://labs.hellokeita.com/2008/05/20/how-to-use-custom-shaders-in-astroflash-10/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

