<?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 on: FlatShadeMaterial.doubleSided does not seem to work as expected</title>
	<atom:link href="http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/feed" rel="self" type="application/rss+xml" />
	<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected</link>
	<description>technology, politics, armchair philosophy</description>
	<lastBuildDate>Mon, 12 Sep 2011 14:57:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Petar Zaharinov</title>
		<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/comment-page-1#comment-3326</link>
		<dc:creator>Petar Zaharinov</dc:creator>
		<pubDate>Wed, 10 Dec 2008 10:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://joshua.almirun.com/?p=151#comment-3326</guid>
		<description>flicker solution:
I am not sure if it is the best fix, but the flicker can be removed by adding below the line 
zAngle = zd * 0xff; 
the following line:
if (zAngle == 0) {zAngle = 1}</description>
		<content:encoded><![CDATA[<p>flicker solution:<br />
I am not sure if it is the best fix, but the flicker can be removed by adding below the line<br />
zAngle = zd * 0xff;<br />
the following line:<br />
if (zAngle == 0) {zAngle = 1}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/comment-page-1#comment-526</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Tue, 27 May 2008 05:57:42 +0000</pubDate>
		<guid isPermaLink="false">http://joshua.almirun.com/?p=151#comment-526</guid>
		<description>Seems LightMaps.getFlatMapArray returns an array of length 255, instead of 256.  

change LighMaps.getFlatMapArray to look like this (it returns 256 colors):

		public static function getFlatMapArray(lightColor:int, ambientColor:int, specularLevel:int):Array
		{
			var array:Array = new Array();
			var tempmap:BitmapData = new BitmapData(256,1,false,0);
			var s:Sprite = new Sprite();
			var m:Matrix = new Matrix();
			m.createGradientBox(256,1,0,0,0)
			s.graphics.beginGradientFill(GradientType.LINEAR, [lightColor,ambientColor],[1,1],[0,255],m);
			s.graphics.drawRect(0,0,256,1);
			s.graphics.endFill();
			tempmap.draw(s);
			
			var i:int = 256;
			while(--i &gt; -1){
				array.push(tempmap.getPixel(i,0));
			}
			
			return array;
		}


Should probably lodge this with papervision team...</description>
		<content:encoded><![CDATA[<p>Seems LightMaps.getFlatMapArray returns an array of length 255, instead of 256.  </p>
<p>change LighMaps.getFlatMapArray to look like this (it returns 256 colors):</p>
<p>		public static function getFlatMapArray(lightColor:int, ambientColor:int, specularLevel:int):Array<br />
		{<br />
			var array:Array = new Array();<br />
			var tempmap:BitmapData = new BitmapData(256,1,false,0);<br />
			var s:Sprite = new Sprite();<br />
			var m:Matrix = new Matrix();<br />
			m.createGradientBox(256,1,0,0,0)<br />
			s.graphics.beginGradientFill(GradientType.LINEAR, [lightColor,ambientColor],[1,1],[0,255],m);<br />
			s.graphics.drawRect(0,0,256,1);<br />
			s.graphics.endFill();<br />
			tempmap.draw(s);</p>
<p>			var i:int = 256;<br />
			while(&#8211;i &gt; -1){<br />
				array.push(tempmap.getPixel(i,0));<br />
			}</p>
<p>			return array;<br />
		}</p>
<p>Should probably lodge this with papervision team&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/comment-page-1#comment-524</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Tue, 27 May 2008 03:33:57 +0000</pubDate>
		<guid isPermaLink="false">http://joshua.almirun.com/?p=151#comment-524</guid>
		<description>If you look at lines 46/47 the dot product is scaled by 255 (0xFF) and then used to look up a color in the _colors array (see line 30 for that).   Do a trace on zAngle and you should be able to figure out wtf is going on....</description>
		<content:encoded><![CDATA[<p>If you look at lines 46/47 the dot product is scaled by 255 (0xFF) and then used to look up a color in the _colors array (see line 30 for that).   Do a trace on zAngle and you should be able to figure out wtf is going on&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua Mostafa</title>
		<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/comment-page-1#comment-523</link>
		<dc:creator>Joshua Mostafa</dc:creator>
		<pubDate>Tue, 27 May 2008 02:16:57 +0000</pubDate>
		<guid isPermaLink="false">http://joshua.almirun.com/?p=151#comment-523</guid>
		<description>Thanks for the quickfix! Nice one, I will try that out.

Yes that flicker is annoying isn&#039;t it. I see it also.</description>
		<content:encoded><![CDATA[<p>Thanks for the quickfix! Nice one, I will try that out.</p>
<p>Yes that flicker is annoying isn&#8217;t it. I see it also.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Al</title>
		<link>http://joshua.almirun.com/tech/3d/flatshadematerialdoublesided-does-not-seem-to-work-as-expected/comment-page-1#comment-522</link>
		<dc:creator>Al</dc:creator>
		<pubDate>Tue, 27 May 2008 01:49:17 +0000</pubDate>
		<guid isPermaLink="false">http://joshua.almirun.com/?p=151#comment-522</guid>
		<description>Think your right...

Looking at lines 42 and 43 of FlatShadeMaterial....

42 does a dot-product of the face normal with the light
43 checks to see if light is &#039;behind&#039; if it is clamps the dot to 0

quick fix is to change line 43 to:
if(zd &lt; 0){zd = -zd;};

That seems to work.  Might want to put in the doubleSided check.

Also, is it just me or does it flicker black when normal is aligned with the light?</description>
		<content:encoded><![CDATA[<p>Think your right&#8230;</p>
<p>Looking at lines 42 and 43 of FlatShadeMaterial&#8230;.</p>
<p>42 does a dot-product of the face normal with the light<br />
43 checks to see if light is &#8216;behind&#8217; if it is clamps the dot to 0</p>
<p>quick fix is to change line 43 to:<br />
if(zd &lt; 0){zd = -zd;};</p>
<p>That seems to work.  Might want to put in the doubleSided check.</p>
<p>Also, is it just me or does it flicker black when normal is aligned with the light?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

