Bumpmap using EnvMapMaterial

Wednesday, November 19th, 2008 | examples

OooOOoOOhh pretty.


source

package
{
	import flash.display.Bitmap;
	import flash.filters.BlurFilter;
	import flash.geom.Point;
 
	import gs.TweenMax;
	import gs.easing.Quad;
 
	import org.papervision3d.lights.PointLight3D;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.materials.shaders.EnvMapShader;
	import org.papervision3d.materials.shaders.ShadedMaterial;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class BumpMapDemo extends BasicView
	{
 
		[Embed(source="assets/3138-bump.jpg")]
		private var envAsset:Class;
 
		[Embed(source="assets/3138.jpg")]
		private var bumpMapAsset:Class;
 
		public function BumpMapDemo()
		{
			var headerText:headerContainer = new headerContainer();
			headerText.header.text = "Bumpmap Demo: Textures from FilterForge";
			addChild(headerText);
 
			var light:PointLight3D = new PointLight3D();
			light.z = -500;
 
			var envBitmap:Bitmap = new envAsset();
			var bumpMapBitmap:Bitmap = new bumpMapAsset();
			//smooth it out
			bumpMapBitmap.bitmapData.applyFilter(bumpMapBitmap.bitmapData, bumpMapBitmap.bitmapData.rect, new Point(0,0), new BlurFilter(3,3,3));
 
			var bitmapMaterial:BitmapMaterial = new BitmapMaterial(bumpMapBitmap.bitmapData);
 
			var envMapShader:EnvMapShader = new EnvMapShader(light, envBitmap.bitmapData, envBitmap.bitmapData, 0, bumpMapBitmap.bitmapData);
			var material:ShadedMaterial = new ShadedMaterial(bitmapMaterial, envMapShader);
 
			//a nice round sphere
			var sphere:Sphere = new Sphere(material, 500, 18, 18);
			scene.addChild(sphere);
 
			startRendering();
 
			TweenMax.to(sphere, 10, {localRotationY:360, localRotationX:180, yoyo:true, ease:Quad.easeInOut});
		}
	}
}

Tags:

  • I'm happy when reading through your site with up-to-date information! thanks alot and hope that you'll publish more site that are based on this website.

  • Great post on Bumpmap using EnvMapMaterial. You made certain good points there. I loved it lot. .

  • Great articles Thank you for making this type of awesome publish that is really perfectly written.Keep up it

  • nice

  • Good Port!

blog comments powered by Disqus

Search

Recommended Books

Speaking at FITC Toronto

 

November 2008
M T W T F S S
    Dec »
 12
3456789
10111213141516
17181920212223
24252627282930

Preferred Video Tutorial Resolution

  • 1024x768 (53%, 85 Votes)
  • 1280x1024 (15%, 24 Votes)
  • 1920x1080 (15%, 24 Votes)
  • 800x600 (13%, 20 Votes)
  • 480x320 (4%, 6 Votes)
  • 640x480 (0%, 2 Votes)

Total Voters: 160

Loading ... Loading ...