Download movies or not download movies?.
Away3D.com
   
 
Quality dvd movies, buy movies online and download movies!!!
rulururu

post Tutorial: How to use the fog filter

April 16th, 2008

Filed under: AWAY3D — Fabrice Closier @ 10:59 am

fog1

This tutorial shows you how to use the fog filter using the Away3D 2.0 library or higher.

A little word on the fog filter,
The simulation of a saturated atmosphere created by the fog filter is not only there to enhance the graphical look of a scene, it’s also a very good way of improving the rendering performance of your project. At it’s heart, the fog filtering processes a depth filter as well. In other words, according to your fog filter maxZ property, all faces at a distance greater than this value are not processed by the renderer. The fog filter reaches a 100% alpha value at this given depth value, which equates to a solid 100% color. Note that a ZDepth filter class is also available if you do not wish to use the fog but benefit from the depth filtering.

FogFilter properties

- minZ the nearest distance from the camera, this value represents where the fog should start

- maxZ the furthest distance from the camera, this value represents where the fog should end

- subdivisions the fog is composed of a series of layers inserted in the view between the rendered triangles – this property sets the number of layers. The alpha values set internally are graduated according to this value.

- material at this time of development the fog filter supports only solid colors like the ColorMaterial class. This is where you set your color information
by default the filter has a white color set.

How to implement the fog filter into your code

	//create a new material
	var fogMaterial:ColorMaterial = new ColorMaterial(0xBCC687);

	//create a new fogfilter using the material
	var fog:FogFilter = new FogFilter({minZ:6500,
									   maxZ:13200,
									   subdivisions:20,
									   material:fogMaterial});

	//create a renderer using the filter
	var basicrenderer:IRenderer = new BasicRenderer(fog);

	//create a view using the renderer
	_view = new View3D({scene:new Scene3D(),
						renderer:basicrenderer});

	_view.x = stage.stageWidth / 2;
	_view.y = stage.stageHeight / 2;
	addChild(_view);

The images below should give you an idea of the way it works

fog2
In this case if this elevation were to be 1000×1000, minZ would be set at 200, and the maxZ at 900

fog3
Here it could be something like minZ 400 and maxZ 550

fog4
And here we would have something like minZ 10 and maxZ 500

this images above are displaying a subdivision of 7. Feel free to experiment with more layers, since the look and feel is highly dependent on the way the layers blend with each other, the amount of faces in between, and their respective sizes on screen.

Popularity: 2% [?]

2 Comments »

  1. Great tutorial, and very helpful, and beautiful illustrated. I’ve read about fog before but never really understood it so well until I read this.

    One thing, however, I’ve tried using your code from this tutorial, but for some reason my test example seems to ignore the filter. I’ve performed a trace in the onEnterFrame function to verify that the filter and materials were added, I can see them in the trace messages as I would expect, but no matter what I set the filter mixZ/maxZ to, nothing changes (I’ve tried minZ/maxZ of 10/20, which should black out my screen as my camera is 1000 units from the object).

    I’ve also tried adding the filter to an array and replacing basicRenderer.filters with this array. No change, the filter appears to be added as view.renderer.filters.* properties all seem to be correct in the trace method (using the appropriate casting as necessary to do the trace).

    Any thoughts on troubleshooting this kind of problem? I’m using version 3.3, flash 10 and all the latest downloads.

    Comment by David Parks THAILAND — June 20, 2009 @ 9:42 am

  2. Great tutorial. Thank you for making it that simple.

    My question is, would it be possible to make fog appears in certain sections of the scene? I think it would be useful for things like going inside water or going up into clouds.

    Comment by guzu SAUDI ARABIA — August 9, 2009 @ 4:14 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

ruldrurd
   
 
Hair drug test and herbal detox products. Visit drug detox website for more details on cannabis and marijuana drug detox.
FireStats iconPowered by FireStats
Powered by WordPress, Web Design by Laurentiu Piron
Entries (RSS) and Comments (RSS)




rmvb player and mkv codec