<?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>publicreative lab &#187; shaders</title>
	<atom:link href="http://lab.publicreative.com/tag/shaders/feed/" rel="self" type="application/rss+xml" />
	<link>http://lab.publicreative.com</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 15:59:54 +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>PV3D with AS3DMod and Shaders</title>
		<link>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/</link>
		<comments>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 19:45:40 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[AS3DMod]]></category>
		<category><![CDATA[Papervision]]></category>
		<category><![CDATA[shaders]]></category>

		<guid isPermaLink="false">http://lab.publicreative.com/?p=30</guid>
		<description><![CDATA[<script type="text/javascript" src="http://lab.publicreative.com/wp-includes/js/jquery/jquery.js"></script><script type="text/javascript" src="http://lab.publicreative.com/wp-content/plugins/pb-embedflash/js/sbadapter/shadowbox-jquery.js"></script><script type="text/javascript" src="http://lab.publicreative.com/wp-content/plugins/pb-embedflash/js/shadowbox.js"></script><script type="text/javascript"><!--
window.onload = function() {var options ={assetURL:'',loadingImage:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/css/images/loading.gif',flvPlayer:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/swf/mediaplayer.swf',animate:true,animSequence:'wh',overlayColor:'#000',overlayOpacity:0.9,overlayBgImage:'http://lab.publicreative.com/wp-content/plugins/pb-embedflash/css/images/overlay-85.png',listenOverlay:true,autoplayMovies:true,showMovieControls:true,resizeDuration:0.35,fadeDuration:0.35,displayNav:true,continuous:false,displayCounter:true,counterType:'default',viewportPadding:20,handleLgImages:'resize',initialHeight:160,initialWidth:320,enableKeys:true,keysClose:['c', 'q', 27],keysPrev:['p', 37],keysNext:['n', 39],handleUnsupported:'',text: {cancel:'Cancel',loading: 'loading',close:'<span class="shortcut">C</span>lose',next:'<span class="shortcut">N</span>ext',prev:'<span class="shortcut">P</span>revious',errors:{single: 'You must install the <a href="{0}">{1}</a> browser plugin to view this content.',shared: 'You must install both the <a href="{0}">{1}</a> and <a href="{2}">{3}</a> browser plugins to view this content.',either: 'You must install either the <a href="{0}">{1}</a> or the <a href="{2}">{3}</a> browser plugin to view this content.'}}};Shadowbox.init(options);}
--></script>This was my first attempt at using the AS3DMod Library so you can see where the previously posted example came from.
I&#8217;ve also added gouraud shading to make it a little more interesting.
Click image to open:
(Please open the article to see the flash file or player.)

Here is the source:

package
&#123;
	import com.as3dmod.ModifierStack;
	import com.as3dmod.modifiers.Perlin;
	import com.as3dmod.plugins.pv3d.LibraryPv3d;
&#160;
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import [...]]]></description>
			<content:encoded><![CDATA[<p>This was my first attempt at using the <a href="http://code.google.com/p/as3dmod/">AS3DMod</a> Library so you can see where the previously posted example came from.</p>
<p>I&#8217;ve also added gouraud shading to make it a little more interesting.</p>
<p><strong>Click image to open:</strong></p>
<p><small>(Please open the article to see the flash file or player.)</small></p>
<p><span id="more-30"></span><br />
<strong>Here is the source:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3 actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span>
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.ModifierStack;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.modifiers.Perlin;
	<span style="color: #0033ff; font-weight: bold;">import</span> com.as3dmod.plugins.pv3d.LibraryPv3d;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Bitmap</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">Loader</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageAlign</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageQuality</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span>.<span style="color: #004993;">StageScaleMode</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">Event</span>;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.lights.PointLight3D;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.BitmapMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.shaders.GouraudShader;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.materials.shaders.ShadedMaterial;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.objects.primitives.Plane;
	<span style="color: #0033ff; font-weight: bold;">import</span> org.papervision3d.view.BasicView;
&nbsp;
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;600&quot;</span>, <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;400&quot;</span>, <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#000000&quot;</span>, <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;31&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> PublicFlag extends BasicView
	<span style="color: #000000;">&#123;</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;assets/flagLogo.gif&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #6699cc; font-weight: bold;">var</span> Flag<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _plane<span style="color: #000000; font-weight: bold;">:</span>Plane;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _mod<span style="color: #000000; font-weight: bold;">:</span>ModifierStack;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _perlin<span style="color: #000000; font-weight: bold;">:</span>Perlin;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _xPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _yPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _targXPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _targYPhaseVal<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = 0;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _light<span style="color: #000000; font-weight: bold;">:</span>PointLight3D;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> PublicFlag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">super</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>, <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">init</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">scaleMode</span> = <span style="color: #004993;">StageScaleMode</span>.<span style="color: #004993;">NO_SCALE</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">align</span> = <span style="color: #004993;">StageAlign</span>.<span style="color: #004993;">TOP_LEFT</span>;
			<span style="color: #004993;">stage</span>.<span style="color: #004993;">stageFocusRect</span> = <span style="color: #0033ff; font-weight: bold;">false</span>;
&nbsp;
			_light = <span style="color: #0033ff; font-weight: bold;">new</span> PointLight3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			_light.z = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">100</span>;
			_light.<span style="color: #004993;">y</span> = <span style="color: #000000; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">100</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> logo<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Bitmap</span> = <span style="color: #0033ff; font-weight: bold;">new</span> Flag<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">Bitmap</span>;
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> shader<span style="color: #000000; font-weight: bold;">:</span>GouraudShader = <span style="color: #0033ff; font-weight: bold;">new</span> GouraudShader<span style="color: #000000;">&#40;</span> _light , 0xffffff , 0x555555 , <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #6699cc; font-weight: bold;">var</span> mat<span style="color: #000000; font-weight: bold;">:</span>ShadedMaterial = <span style="color: #0033ff; font-weight: bold;">new</span> ShadedMaterial<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> BitmapMaterial<span style="color: #000000;">&#40;</span> logo.<span style="color: #004993;">bitmapData</span><span style="color: #000000;">&#41;</span> , shader<span style="color: #000000;">&#41;</span>;
			mat.doubleSided = <span style="color: #0033ff; font-weight: bold;">true</span>;
			_plane = <span style="color: #0033ff; font-weight: bold;">new</span> Plane<span style="color: #000000;">&#40;</span> mat , logo.<span style="color: #004993;">width</span> , logo.<span style="color: #004993;">height</span> , <span style="color: #000000; font-weight:bold;">12</span>, <span style="color: #000000; font-weight:bold;">8</span><span style="color: #000000;">&#41;</span>;
			_plane.useOwnContainer = <span style="color: #0033ff; font-weight: bold;">true</span>;
&nbsp;
			camera.fov=<span style="color: #000000; font-weight:bold;">34</span>;
			scene.<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span> _plane <span style="color: #000000;">&#41;</span>;
&nbsp;
			modify<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
			startRendering<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> modify<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			 _mod = <span style="color: #0033ff; font-weight: bold;">new</span> ModifierStack<span style="color: #000000;">&#40;</span> <span style="color: #0033ff; font-weight: bold;">new</span> LibraryPv3d<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> , _plane <span style="color: #000000;">&#41;</span>;
&nbsp;
			_perlin = <span style="color: #0033ff; font-weight: bold;">new</span> Perlin<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">3</span><span style="color: #000000;">&#41;</span>;
			_perlin.setFalloff<span style="color: #000000;">&#40;</span> 0 , <span style="color: #000000; font-weight:bold;">1</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
			_mod.addModifier<span style="color: #000000;">&#40;</span> _perlin <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Event</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
		 	_xPhaseVal = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseX</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageWidth</span>;
		 	_plane.rotationY <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">160</span><span style="color: #000000; font-weight: bold;">*</span>_xPhaseVal<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">-</span>_plane.rotationY<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
		 	_yPhaseVal = <span style="color: #000000;">&#40;</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">mouseY</span> <span style="color: #000000; font-weight: bold;">-</span> <span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #004993;">stage</span>.<span style="color: #004993;">stageHeight</span>;
		 	_plane.rotationX <span style="color: #000000; font-weight: bold;">+</span>= <span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">100</span> <span style="color: #000000; font-weight: bold;">*</span> _yPhaseVal<span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">-</span> _plane.rotationX<span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight:bold;">10</span>;
&nbsp;
			_mod.<span style="color: #004993;">apply</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">super</span>.onRenderTick<span style="color: #000000;">&#40;</span>event<span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://lab.publicreative.com/2009/01/pv3d-with-as3dmod-and-shaders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
