Applying materials at runtime to .ac and .awd models causes them to lose smooth shading

Software: Away3D 4.x

Dolomite, Newbie
Posted: 23 June 2011 07:28 AM   Total Posts: 2

Whenever model in .ac and .awd format has a list of textures tied to it and those textures are applied on to model when parsing, certain “smooth” shading would kick in, removing all the sharp edges between neighboring polygons…This is great ...but…

When you create a bitmap or color material at runtime and apply to mesh.material it would lose that shading and would cause even very high poly models look very angular. Is there something that can prevent from such effect?

Thanks.

   

Richard Olsson, Administrator
Posted: 23 June 2011 11:09 PM   Total Posts: 1192   [ # 1 ]

I am not familiar with this issue. Any chance you can provide test models with which you are experiencing this issue, and preferably even the code that you are using to load the models and apply materials? That way we can whether it’s an anomaly in the engine or something that you are doing, and hopefully sort out the issue.

   

Dolomite, Newbie
Posted: 24 June 2011 05:09 PM   Total Posts: 2   [ # 2 ]

I’m using head.ac model from examples sources folder. The meat is in onResourceComplete (taken from cellshader example). So this would work just fine with .obj files but with .ac, yeah i get hardedges on polygons, no normals applied.

the code is:

_light3 = new DirectionalLight(-1, -1, 1);
_light3.specular = .25;
_light3.diffuse = .25;
_light3.color = 0xffffff;
_view.scene.addChild(_light3);

_loader = new Loader3D();
_loader.addEventListener(LoaderEvent.RESOURCE_COMPLETE, onResourceComplete);
_loader.load(new URLRequest(‘assets/head.ac’));

private function onResourceComplete(e:LoaderEvent):void
{
var mesh : Mesh;
var len : uint = _container.numChildren;
var material : ColorMaterial = new ColorMaterial(0xe24062 /*0xfbcbc1*/);
material.ambientColor = 0xaaaaaa; //0xdd5525;
material.specular = .25;
material.diffuseMethod = new CelDiffuseMethod(2);
material.specularMethod = new CelSpecularMethod();
CelSpecularMethod(material.specularMethod).smoothness = .2;
CelDiffuseMethod(material.diffuseMethod).smoothness = .1;
material.lights = [ _light3 ];

for (var i : uint = 0; i < len; ++i) {
  mesh = Mesh(_loader.getChildAt(i));
  mesh.material = material;
}
}

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X