new ColorMaterial not shaded after applying lights

Software: Away3D 4.x

David Mosemann, Newbie
Posted: 30 August 2012 06:39 PM   Total Posts: 18

Been working on this issue pretty much all day and not getting anywhere. I’m not really sure what’s wrong so hopefully someone here can point me in the right direction.

I am importing a model as a AS3 class - exported from Prefab
I declared an array before the constructor for the lights and in the initLights function push the lights into the array. I then used LightsHelper to add the lights to the materials (all ColorMaterials) on the model and everything works fine up to that point.

Later in the Class, I have a function that changes the color of a specific mesh and again used LightsHelper to add the scene lights to the materials. The color of the material changes but no shading.

I added a few trace statements to make sure the lights were added to the array and its showing they are. So according to the code and the trace statements everything should be working fine but I’m not getting a shaded material.

Ive also tried this using a StaticLightPicker (declaring it before the constructor and initializing in initLights function) instead of LightsHelper and am getting the same results: color changes with no shading.

Any thoughts?

Thanks,
David

   

Avatar
Fabrice Closier, Administrator
Posted: 30 August 2012 09:23 PM   Total Posts: 1265   [ # 1 ]

Aside the possible issue that you describe (where we would need some code that reproduces it to comfirm and help us to fix), you say the materials are ok once you used lightHelper only.

So why do you use LightHelper again after you change the color?
The material only needs a color property to be updated, no need to update/replace the lightPicker of the material.

I do not know the engine version that you use, but there was a known invalidation issue that should be fixed by now with the material set lighPicker. Try for the sake of test, to set the material.repeat twice in your updateColor handler. (one to change the repeat boolean, a second to restore it as it was). This “stupid” test forces an invalidation internally, possibly fixing your issue on your second pass, if you would keep the code as is.

If the problem persists, please provide us a single class that reproduces the problem.

 

   

David Mosemann, Newbie
Posted: 31 August 2012 01:16 PM   Total Posts: 18   [ # 2 ]

Hi Fabrice, thanks for the quick response.

I attached a simplified version of my Class that I’m using that is reproducing the same results - changing color but no shading.

The reason I didn’t just update the color is because the material for the mesh that I want to change is also the same material for multiple other meshes in my model. So if I change the color of the material for one mesh it changes it for all the others. Hence why I need to make a new ColorMaterial, apply it to the mesh that I want to change, and then add a lightPicker.

I thought this would work… but it hasn’t been so far.. with either lightPicker or LightsHelper. The version I attached uses lightPicker.

The only way I’ve been able to get around this is to make a separate material for that particular mesh and just update the color, but in the final application the meshes will change color off of a loaded xml file so I cant anticipate which meshes will change color.

I just downloaded the latest from the dev branch on gitHub and I am getting the same results. I didn’t try your test because I didn’t fully understand it and I don’t think it directly applies because I’m not updating the color but applying a new one.

Anyway, hopefully you can point me to where I’m going wrong.

Thanks for the help,
David

 

File Attachments
MyClass.zip  (File Size: 194KB - Downloads: 168)
   

David Mosemann, Newbie
Posted: 05 September 2012 02:41 PM   Total Posts: 18   [ # 3 ]

I’m not exactly sure what I changed, but the shading is working now. I made a new class with the same content and all is good - maybe something was buggy with the file.

 

   

kochumvk, Newbie
Posted: 07 September 2012 01:04 PM   Total Posts: 17   [ # 4 ]

After applying new color material are you adding a color picker to the martial?

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X