Away3d 4.1 texture Summary

Source: Internet
Author: User
Texturematerial (texture: texture2dbase = NULL, smooth: Boolean = true, repeat: Boolean = false, mipmap: Boolean = true) // texture, smooth, repeated, enable mipmap texture creates a new texturematerial.

 1. Texture

A commonly used technology in 3D computer graphics Paster rendering is calledMipmapping. To speed up rendering and reduce image aliasing, textures are processed into files consisting of a series of pre-computed and Optimized images. Such textures are called MIP map or mipmap. This technology is widely used in 3D games. "MIP" comes from Latin.Multum in parvoThe first letter indicates "small space for storing a lot of things ". Mipmap requires a certain amount of memory space and complies with wavelet compression rules ).

 

VaR floormaptexture: bitmaptexture = new bitmaptexture (New this. floormapasset (). bitmapdata); var floormap: texturematerial = new texturematerial (floormaptexture, true, true); floormap. specular = 1; // reflection floormap. lightpicker = new staticlightpicker ([param1]); // pick up the light floormap. diffusemethod = new terraindiffusemethod ([floormaptexture], new bitmaptexture (New this. floorshadowmapasset (). bitmapdata), [10]); // This is called the concave and convex texture method in 3D. floormesh = new mesh (New planegeometry (3800,380 0), floormap); // create a ground surface and paste the ground texture generated above

 

 

General textures:

1. Make various textures, such as reflection textures, concave and convex textures, etc.

2. Use lightpicker to map the light in the scenario.

3. Add the effect Paster to the Paster.

4. Generate a patch mesh and place the texture on the patch.

 

Load Model textures

VaR garageloader: loader3d = new loader3d (); // instance model loader garageloader. addeventlistener (assetevent. asset_complete, this. complete); garageloader. loaddata (New this. garageasset (), null, null); super. addchildren (this. floormesh, this. floorshadowmesh); Private function complete (Event: assetevent): void {If (event. asset. assettype = assettype. mesh) {garagemesh = event. asset as mesh; // converts the model to garagemesh. material = new texturematerial (New bitmaptexture (New this. garagemapasset (). bitmapdata), true); // map garagemesh to the loaded model. roll (180); garagemesh. geometry. scale (3); super. addchild (this. garagemesh); super. y = 188 ;}}

 

 

There are two ways to use the method class. One is to use the addmethod () method of the addultmaterialbase subclass (such as colormaterial and bitmapmaterial,
For example:

var cubeMaterial:ColorMaterial = new ColorMaterial();cubeMaterial.addMethod(new OutlineMethod());

The other method is to specify the defaultmaterialbase subclass,
For example:

var cubeMaterial:ColorMaterial = new ColorMaterial();cubeMaterial.diffuseMethod = new SubsurfaceScatteringDiffuseMethod();cubeMaterial.specularMethod = new FresnelSpecularMethod();cubeMaterial.shadowMethod = new DitheredShadowMapMethod();

In fact, the difference between the two setting methods is only the execution priority during rendering. If there is no special requirement on which method is executed first, you can use the first method to add all the methods.

The rendering priority is as follows:
Normalmethod> ambientmethod> shadowmethod> diffusemethod> specularmethod> colortransform> Other Methods Added by addmethod ()

Some common methods:

Envmapmethod
Environment texture method: To reflect the surface energy of an object to the surrounding environment (such as stainless steel and plexiglass)

// Create a skybox. You can find the six pasters by yourself. The official demo shows var cubetexture: bitmapcubetexture = new bitmapcubetexture ("6 pasters") scene. addchild (New skybox (cubetexture); // create a square var cubegeometry: cubegeometry = new cubegeometry (500); var cubematerial: coloregmaterial = new colormaterial (); cubematerial. specular = 0.8; cubematerial. alpha = 0.5; // to reflect the skybox environment, share the texture of skybox. // if you want to reflect other things, you can also use other materials, such as cubematerial. addmethod (New envmapmethod (cubetexture); var cubemesh: mesh = new mesh (cubegeometry, cubematerial); scene. addchild (cubemesh );

Fresnelspecularmethod
I don't want to explain this in a complicated way. Here is an excerpt from Baidu encyclopedia. I believe you can understand it at a glance ....
(When we stand by the lake, we look down at the water under our feet. The water is transparent and the reflection is not very strong. In the distance, you will find that the water is not transparent, and the reflection is very strong. This is the "freell effect"... from Baidu encyclopedia)
To put it bluntly, the light reflection is softer. It can be used on the surface of the lake or in combination with the SSS scattering method.

Fresnelenvmapmethod
How to map the freell Environment

Subsurfacescatteringdiffusemethod
Subsurface full scattering (SSS full scattering)
This method is used to simulate the refraction of light in a translucent object (such as human skin, grape, candle, etc)

var subsurfaceMethod:SubsurfaceScatteringDiffuseMethod = new SubsurfaceScatteringDiffuseMethod(2048, 2);subsurfaceMethod.scatterColor = 0xff7733;subsurfaceMethod.scattering = .05;subsurfaceMethod.translucency = 4;bodyMaterial.diffuseMethod = subsurfaceMethod;

Wrapdiffusemethod
Encapsulation scattering method, which is close to SSS full scattering method, but more rough

Colortransformmethod
Color Conversion method. The effect is the same as setting material. colortransform directly. The execution sequence is later than the setting of material. colortransform.
It is generally not recommended. Use material. colortransform directly unless you need to solve some special problems or bugs.

var m:ColorTransformMethod = new ColorTransformMethod();m.colorTransform = new ColorTransform(1,0,0);bodyMaterial.addMethod(m);

Colormatrixmethod
How does one convert the color matrix? You can also use it ....
But you must have some colormatrixfilter knowledge...

var matrix:Array = new Array();matrix = matrix.concat([1, 0, 0, 0, 0]); // redmatrix = matrix.concat([0, 0, 0, 0, 0]); // greenmatrix = matrix.concat([0, 0, 0, 0, 0]); // bluematrix = matrix.concat([0, 0, 0, 1, 0]); // alphavar filter:ColorMatrixFilter = new ColorMatrixFilter(matrix);var m:ColorMatrixMethod = new ColorMatrixMethod();m.colorMatrixFilter = filter;bodyMaterial.addMethod(m);

Outlinemethod
Contour method. If the texture chart is transparent in some places, but you want to know the shape of the Whole Mesh, you can use this method (this method is not affected by the texture and the valid boundary is the geometry boundary)

Rimlightmethod
Contour luminous method (the valid boundary is the visible boundary of the texture, and the transparent part is not affected by this method)

bodyMaterial.addMethod(new RimLightMethod(0xff0000));

Projectivetexturemethod
The projection material method. Imagine the effect of sunlight on the wall through the colored window glass.
Or... Heihei... if you have a sphere, you want to paste another picture on it .....

var projector:TextureProjector = new TextureProjector(photoBitmapData);projector..position = new Vector3D(0,100,0);bodyMaterial.addMethod(new ProjectiveTextureMethod(projector));

Saying... There is a bug in this product... transparent images are not supported... hope the next version can be fixed ....

Simplewaternormalmethod
Want some simple water wave effects? Use it, that is, use it!

Softshadowmapmethod
What is the bending effect when the shadow of an object is mapped to a corner? That's it.

Ditheredshadowmapmethod
Jitter shadow Method

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.