<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments for Salt Games</title>
	<atom:link href="http://www.saltgames.com/?feed=comments-rss2" rel="self" type="application/rss+xml" />
	<link>http://www.saltgames.com</link>
	<description>Games and Toys in Flash</description>
	<lastBuildDate>Mon, 05 Apr 2010 17:15:17 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>Comment on Introduction to Pixel Bender in Flash by Joe</title>
		<link>http://www.saltgames.com/?p=207#comment-681</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 05 Apr 2010 17:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=207#comment-681</guid>
		<description>Thanks!</description>
		<content:encoded><![CDATA[<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Introduction to Pixel Bender in Flash by Salt</title>
		<link>http://www.saltgames.com/?p=207#comment-679</link>
		<dc:creator>Salt</dc:creator>
		<pubDate>Mon, 05 Apr 2010 16:38:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=207#comment-679</guid>
		<description>Ah yes, I think you&#039;re right and your task isn&#039;t going to match up with what shaders can do.  I don&#039;t think it&#039;s possible to start a shader going again except through actionscript, and if your actionscript thread is busy crunching through XML then it&#039;s not going to be able to make that call.

Coincidentally, I&#039;ve been working on a very similar problem.  I have a game prototype that procedurally generates its own (quite large) texture and normal maps.  Even on modern machines that can take a few seconds, during which time the Flash player becomes completely unresponsive.  That&#039;s a little inconvenient, but in doing some recent &lt;a href=&quot;http://forums.tigsource.com/index.php?topic=11931.0&quot; rel=&quot;nofollow&quot;&gt;public testing&lt;/a&gt; it seems that some browser and OS combinations will crash during that unresponsive period, which makes it a serious problem. &lt;strong&gt;edit&lt;/strong&gt; I&#039;ve since discovered that it wasn&#039;t the Flash player locking up that caused the crash, but my trying to run shaders on overly large images.  Still good practice to not lock up the Flash player though!

To avoid the Flash player becoming unresponsive, I have split the heavy processing into many smaller chunks with their execution split between frames (not using any shader stuff for that, just plain old actionscript.)  I found&lt;a href=&quot;http://www.senocular.com/flash/tutorials/asyncoperations/&quot; rel=&quot;nofollow&quot;&gt; a quite detailed article&lt;/a&gt; about this approach which probably explains it better than I can.

That said, I&#039;m still getting some reported crashes.  I&#039;ve chopped up the processing into even finer chunks for a future version so hopefully that&#039;ll finally fix it.

To actually answer your question: It should be possible to keep Flash being responsive whilst also doing heavy parsing, but you&#039;ll need to rearrange your code a little so that the parsing operation can be split between multiple frames.  Shaders will probably not be much use in this case (if you were doing just heavy number crunching it would be possible to do that crunching on an asynchronous shader which would be neat.)</description>
		<content:encoded><![CDATA[<p>Ah yes, I think you&#8217;re right and your task isn&#8217;t going to match up with what shaders can do.  I don&#8217;t think it&#8217;s possible to start a shader going again except through actionscript, and if your actionscript thread is busy crunching through XML then it&#8217;s not going to be able to make that call.</p>
<p>Coincidentally, I&#8217;ve been working on a very similar problem.  I have a game prototype that procedurally generates its own (quite large) texture and normal maps.  Even on modern machines that can take a few seconds, during which time the Flash player becomes completely unresponsive.  That&#8217;s a little inconvenient, but in doing some recent <a href="http://forums.tigsource.com/index.php?topic=11931.0" rel="nofollow">public testing</a> it seems that some browser and OS combinations will crash during that unresponsive period, which makes it a serious problem. <strong>edit</strong> I&#8217;ve since discovered that it wasn&#8217;t the Flash player locking up that caused the crash, but my trying to run shaders on overly large images.  Still good practice to not lock up the Flash player though!</p>
<p>To avoid the Flash player becoming unresponsive, I have split the heavy processing into many smaller chunks with their execution split between frames (not using any shader stuff for that, just plain old actionscript.)  I found<a href="http://www.senocular.com/flash/tutorials/asyncoperations/" rel="nofollow"> a quite detailed article</a> about this approach which probably explains it better than I can.</p>
<p>That said, I&#8217;m still getting some reported crashes.  I&#8217;ve chopped up the processing into even finer chunks for a future version so hopefully that&#8217;ll finally fix it.</p>
<p>To actually answer your question: It should be possible to keep Flash being responsive whilst also doing heavy parsing, but you&#8217;ll need to rearrange your code a little so that the parsing operation can be split between multiple frames.  Shaders will probably not be much use in this case (if you were doing just heavy number crunching it would be possible to do that crunching on an asynchronous shader which would be neat.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Introduction to Pixel Bender in Flash by Joe</title>
		<link>http://www.saltgames.com/?p=207#comment-678</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 05 Apr 2010 15:59:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=207#comment-678</guid>
		<description>Thanks for the reply!!

&quot;It is possible to run a shader asynchronously which will free it completely from the actionscript thread, and allow the actionscript to keep executing at the same time.&quot;

That makes sense to me, and I&#039;ve messed around with it.  But I&#039;m starting to think that what I want to do isn&#039;t what shaders are designed to do.  Basically, I want to make a spinning progress indicator that won&#039;t stick when I ask flash to parse, for example, a giant xml file.  

But it seems that once &#039;evaluatePixel&#039; has evaluated all of the pixels in its target, it&#039;s done and you can only re-invoke it by changing a parameter, which is usually done on an enter frame basis.  So, you can&#039;t really start the pixel bender, let it run without touching it for a while and then stop it.  As I see it, that&#039;s what you&#039;d need to do to make a Shader-based preloader that didn&#039;t rely on the framerate of your swf and would never stick no matter what the actionscript thread was doing.

Does that make sense?  Can you think of a way to achieve it?</description>
		<content:encoded><![CDATA[<p>Thanks for the reply!!</p>
<p>&#8220;It is possible to run a shader asynchronously which will free it completely from the actionscript thread, and allow the actionscript to keep executing at the same time.&#8221;</p>
<p>That makes sense to me, and I&#8217;ve messed around with it.  But I&#8217;m starting to think that what I want to do isn&#8217;t what shaders are designed to do.  Basically, I want to make a spinning progress indicator that won&#8217;t stick when I ask flash to parse, for example, a giant xml file.  </p>
<p>But it seems that once &#8216;evaluatePixel&#8217; has evaluated all of the pixels in its target, it&#8217;s done and you can only re-invoke it by changing a parameter, which is usually done on an enter frame basis.  So, you can&#8217;t really start the pixel bender, let it run without touching it for a while and then stop it.  As I see it, that&#8217;s what you&#8217;d need to do to make a Shader-based preloader that didn&#8217;t rely on the framerate of your swf and would never stick no matter what the actionscript thread was doing.</p>
<p>Does that make sense?  Can you think of a way to achieve it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Introduction to Pixel Bender in Flash by Salt</title>
		<link>http://www.saltgames.com/?p=207#comment-676</link>
		<dc:creator>Salt</dc:creator>
		<pubDate>Mon, 05 Apr 2010 13:07:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=207#comment-676</guid>
		<description>Hi!
You&#039;re quite right, all of my examples are running the shader synchronously - by passing &#039;true&#039; to the shaderJob.start() call - which locks up the actionscript execution until the shader is finished.
The threaded advantage you get even from running shaders synchronously is that the execution of the shader itself is spread over several threads and so benefits from however many CPU cores the user has.  The advantage is simply that the shader itself can get executed faster, and you can get back to and unpause the actionscript thread sooner.
It is possible to run a shader asynchronously which will free it completely from the actionscript thread, and allow the actionscript to keep executing at the same time.  I&#039;ve kind of skipped over it in this article as there&#039;s a couple of odd behaviours (the unfaithful may call them bugs) which you have to deal with.  I will try to put together at least a short piece on using asynchronous shaders soon.</description>
		<content:encoded><![CDATA[<p>Hi!<br />
You&#8217;re quite right, all of my examples are running the shader synchronously &#8211; by passing &#8216;true&#8217; to the shaderJob.start() call &#8211; which locks up the actionscript execution until the shader is finished.<br />
The threaded advantage you get even from running shaders synchronously is that the execution of the shader itself is spread over several threads and so benefits from however many CPU cores the user has.  The advantage is simply that the shader itself can get executed faster, and you can get back to and unpause the actionscript thread sooner.<br />
It is possible to run a shader asynchronously which will free it completely from the actionscript thread, and allow the actionscript to keep executing at the same time.  I&#8217;ve kind of skipped over it in this article as there&#8217;s a couple of odd behaviours (the unfaithful may call them bugs) which you have to deal with.  I will try to put together at least a short piece on using asynchronous shaders soon.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Introduction to Pixel Bender in Flash by Joe</title>
		<link>http://www.saltgames.com/?p=207#comment-671</link>
		<dc:creator>Joe</dc:creator>
		<pubDate>Mon, 05 Apr 2010 05:19:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=207#comment-671</guid>
		<description>Great article!  But there&#039;s one concept that doesn&#039;t make sense to me.  The value of the separate thread, to me, is that you can render an effect even if the flash player&#039;s frame rate is choking.  But all of the examples I&#039;ve seen rely on the player&#039;s frame rate to invoke the Shader.  Won&#039;t the shader run poorly when the player is under some load that is slowing the actionscript/frame thread?  I&#039;m probably missing some concept, hope you can clarify...

Thanks!</description>
		<content:encoded><![CDATA[<p>Great article!  But there&#8217;s one concept that doesn&#8217;t make sense to me.  The value of the separate thread, to me, is that you can render an effect even if the flash player&#8217;s frame rate is choking.  But all of the examples I&#8217;ve seen rely on the player&#8217;s frame rate to invoke the Shader.  Won&#8217;t the shader run poorly when the player is under some load that is slowing the actionscript/frame thread?  I&#8217;m probably missing some concept, hope you can clarify&#8230;</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Testing out Pixel Bender by Salt</title>
		<link>http://www.saltgames.com/?p=191#comment-629</link>
		<dc:creator>Salt</dc:creator>
		<pubDate>Thu, 01 Apr 2010 01:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=191#comment-629</guid>
		<description>Hi!

I&#039;ve varied between a few methods for applying what I refer to as the &quot;light map&quot; to the unlit image.  The light map is an image that represents how each pixel is illuminated: black for no illumination, white for full illumination.  In the above example the light map is greyscale as it&#039;s using just a single white light source, but it could have varied colours.

Using Flash&#039;s built-in BlendMode.HARDLIGHT works quite well, although you may want to lower the brightness of the light map first to stop the result being blindingly white in places.

In the example here I think I am just multiplying the colours.  I do it in another custom shader to let me adjust the calculation so that a 0x7f7f7f pixel on the lightmap will result in no change to the base image.</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I&#8217;ve varied between a few methods for applying what I refer to as the &#8220;light map&#8221; to the unlit image.  The light map is an image that represents how each pixel is illuminated: black for no illumination, white for full illumination.  In the above example the light map is greyscale as it&#8217;s using just a single white light source, but it could have varied colours.</p>
<p>Using Flash&#8217;s built-in BlendMode.HARDLIGHT works quite well, although you may want to lower the brightness of the light map first to stop the result being blindingly white in places.</p>
<p>In the example here I think I am just multiplying the colours.  I do it in another custom shader to let me adjust the calculation so that a 0x7f7f7f pixel on the lightmap will result in no change to the base image.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Testing out Pixel Bender by Sean Monahan</title>
		<link>http://www.saltgames.com/?p=191#comment-546</link>
		<dc:creator>Sean Monahan</dc:creator>
		<pubDate>Mon, 22 Mar 2010 04:06:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=191#comment-546</guid>
		<description>Thanks so much for this, finding it super useful!  One question I have, how are layering the normal map over the unlit image?  Are you multiplying the images?

Nvidia&#039;s normal map plugin for Photoshop (just google &quot;nvidia normal map plugin&quot;) is also quite useful for creating normal maps.</description>
		<content:encoded><![CDATA[<p>Thanks so much for this, finding it super useful!  One question I have, how are layering the normal map over the unlit image?  Are you multiplying the images?</p>
<p>Nvidia&#8217;s normal map plugin for Photoshop (just google &#8220;nvidia normal map plugin&#8221;) is also quite useful for creating normal maps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on A Bitwise Method For Applying Tilemaps by Nick</title>
		<link>http://www.saltgames.com/?p=184#comment-377</link>
		<dc:creator>Nick</dc:creator>
		<pubDate>Thu, 04 Mar 2010 02:33:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=184#comment-377</guid>
		<description>Thanks, this is a really elegant solution - fantastic.</description>
		<content:encoded><![CDATA[<p>Thanks, this is a really elegant solution &#8211; fantastic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Testing out Pixel Bender by Salt</title>
		<link>http://www.saltgames.com/?p=191#comment-361</link>
		<dc:creator>Salt</dc:creator>
		<pubDate>Sun, 28 Feb 2010 20:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=191#comment-361</guid>
		<description>You&#039;re very kind, although there&#039;s no false modesty in my saying that there&#039;s nothing special about the shader :)

I think much of the effect is due to using a photographically generated normal map (although it does also cause some slight artefacts where there were shadows in the photo.)

Here is the source for the shader in Pixel Bender to produce a &quot;light map&quot;, which is layered over the original unlit image to create the full effect.
&lt;pre&gt;
&lt;languageVersion : 1.0;&gt;

kernel NormalMapper
&lt;   
    namespace : &quot;&quot;;
    vendor : &quot;Salt&quot;;
    version : 1;
    description : &quot;Produces a light map based on a light source&#039;s position and a given normal map.&quot;;
&gt;
{
    input image4 normalMap;
    output pixel4 result;
    
    parameter float3 lightPosition
    &lt; 
        minValue: float3(-500.0, -500.0, 0.0);
        maxValue: float3(+500.0, +500.0, 200.0);
        defaultValue: float3(60.0, 60.0, 60.0);
    &gt;;
    
    parameter float3 lightColour
    &lt;
        minValue: float3(0.0, 0.0, 0.0);
        maxValue: float3(1.0, 1.0, 1.0);
        defaultValue: float3(1.0, 1.0, 1.0);
    &gt;;

    void
    evaluatePixel()
    {
        float2 positionHere = outCoord();
                        
        float3 toLight = lightPosition;
        toLight.xy -= positionHere.xy;
        toLight = normalize(toLight);
        
        float4 normal = sampleNearest(normalMap, positionHere);
        float3 normalVector = (normal.rgb * 2.0) - 1.0;

        //if you trust that your normal map is already normalised you can skip this for a performance boost:
        normalVector = normalize(normalVector);

        float normalFactor = dot(normalVector, toLight);

        result.rgb = normalFactor * lightColour.rgb;
        result.a = 1.0;
    }
}&lt;/pre&gt;

I&#039;ve also just posted a &lt;a href=&quot;http://www.saltgames.com/?p=207&quot; rel=&quot;nofollow&quot;&gt;tutorial&lt;/a&gt; on how I implement shaders in Flash.</description>
		<content:encoded><![CDATA[<p>You&#8217;re very kind, although there&#8217;s no false modesty in my saying that there&#8217;s nothing special about the shader <img src='http://www.saltgames.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I think much of the effect is due to using a photographically generated normal map (although it does also cause some slight artefacts where there were shadows in the photo.)</p>
<p>Here is the source for the shader in Pixel Bender to produce a &#8220;light map&#8221;, which is layered over the original unlit image to create the full effect.</p>
<pre>
&lt;languageVersion : 1.0;&gt;

kernel NormalMapper
&lt;
    namespace : "";
    vendor : "Salt";
    version : 1;
    description : "Produces a light map based on a light source's position and a given normal map.";
&gt;
{
    input image4 normalMap;
    output pixel4 result;

    parameter float3 lightPosition
    &lt;
        minValue: float3(-500.0, -500.0, 0.0);
        maxValue: float3(+500.0, +500.0, 200.0);
        defaultValue: float3(60.0, 60.0, 60.0);
    &gt;;

    parameter float3 lightColour
    &lt;
        minValue: float3(0.0, 0.0, 0.0);
        maxValue: float3(1.0, 1.0, 1.0);
        defaultValue: float3(1.0, 1.0, 1.0);
    &gt;;

    void
    evaluatePixel()
    {
        float2 positionHere = outCoord();

        float3 toLight = lightPosition;
        toLight.xy -= positionHere.xy;
        toLight = normalize(toLight);

        float4 normal = sampleNearest(normalMap, positionHere);
        float3 normalVector = (normal.rgb * 2.0) - 1.0;

        //if you trust that your normal map is already normalised you can skip this for a performance boost:
        normalVector = normalize(normalVector);

        float normalFactor = dot(normalVector, toLight);

        result.rgb = normalFactor * lightColour.rgb;
        result.a = 1.0;
    }
}</pre>
<p>I&#8217;ve also just posted a <a href="http://www.saltgames.com/?p=207" rel="nofollow">tutorial</a> on how I implement shaders in Flash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Testing out Pixel Bender by Anonymous</title>
		<link>http://www.saltgames.com/?p=191#comment-356</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Sun, 28 Feb 2010 00:59:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.saltgames.com/?p=191#comment-356</guid>
		<description>This is one of the smoothest, most sublime implementations of Normal mapping using Pixel Bender that I&#039;ve seen on the net. Would it be too much to ask for a link to your source code on this?</description>
		<content:encoded><![CDATA[<p>This is one of the smoothest, most sublime implementations of Normal mapping using Pixel Bender that I&#8217;ve seen on the net. Would it be too much to ask for a link to your source code on this?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
