Dynamically changing materials?

Software: Away3D 3.x

MustHave, Newbie
Posted: 22 September 2011 08:17 AM   Total Posts: 6

Hi! I have such a problem: I have a scene with some Plane’s on it all of them are using BitmapMaterial’s as textures. I need to add to these images some lines which will be shown by click & hold on some button. Scene can rotate so I think these lines must be part of the materials but I don’t know how to do such a thing. Thank you for your help.

   

Avatar
Darcey, Moderator
Posted: 23 September 2011 04:42 PM   Total Posts: 209   [ # 1 ]

Take your original bitmap material put it in photoshop or some other image editor add your lines and save it as a new file. Then use this as another bitmap material and switch them when mouse click.

D

   

Avatar
Choons, Sr. Member
Posted: 23 September 2011 07:45 PM   Total Posts: 281   [ # 2 ]

Away3D 3.6 has a composite material that lets you overlay materials in various ways using the blend modes. Check that out

Another approach would be to use Flash’s bitmapData ops to composite line into your material bitmapData.

BTW any chance for a composite material like 3.6 has being added to 4.0?

   

Avatar
Alejandro Santander, Administrator
Posted: 23 September 2011 09:59 PM   Total Posts: 414   [ # 3 ]

@Choons, that isn’t necessary in 4.x because of the approach we’ve decided to take. If you wanted a material in 3.x with a texture, phong shading and environment mapping, you could do so by compositing materials (and some struggle). In 4.x the default bitmap material already has phong shading if you add a light and for the environment map, you’d just add an envMapMethod to it.

   

Avatar
Choons, Sr. Member
Posted: 23 September 2011 10:54 PM   Total Posts: 281   [ # 4 ]

it’s not a matter of shading. Suppose you have a t-shirt configurator that allows customers to add graphics to the shirt. You need a fabric material as a base and then it’s very useful to be able to add additional material layers for the graphics. So in 3.6 you’d declare a composite material to hold all the layers- very useful and it will be a shame if composite material doesn’t make it into 4.0

   

Avatar
Alejandro Santander, Administrator
Posted: 24 September 2011 12:53 AM   Total Posts: 414   [ # 5 ]

Wouldn’t you just be affecting the base bitmap data in that case? Why do you need each layer to be a different material?

   

Avatar
Choons, Sr. Member
Posted: 24 September 2011 01:06 AM   Total Posts: 281   [ # 6 ]

to be able to scale & position graphics the CompositeMaterial used as a container for several TransformBitmapMaterial textures greatly eases the coding. Here’s a demo I made in 3.6 a while back that shows how useful CompositeMaterial is. Performance becomes an issue when adding more graphics & shading. Away3D 4.0 could handle it better. Trying to composite graphics at the bitmapData level is quite difficult to do in comparison for something like this

http://blam3d.com/demos/configtoolsdemo.html

   

Avatar
Choons, Sr. Member
Posted: 24 September 2011 01:15 AM   Total Posts: 281   [ # 7 ]

to expand on that a bit- the fabric texture works best as a repeated tile so it can be zoomable, while the graphics you generally don’t want repeat. So the only way to do it is with more than one material inside a CompositeMaterial container. Also when you position the graphic you don’t want the fabric texture to move as well

   

Avatar
Alejandro Santander, Administrator
Posted: 24 September 2011 05:59 AM   Total Posts: 414   [ # 8 ]

Well, I still think its doable without composite materials, but don’t get me wrong, I’m not saying no to composite materials at all, just analyzing what you’re suggesting. All the manipulation you are mentioning can be done at texture level. Imagine your texture composition as a sprite canvas, where you transform your objects, tiles etc. Besides, it would be inefficient to overlay so much Texture data when you could just precomposite it and then apply it. Maybe I’m wrong, just thinking.

This all started from a BTW, btw… Were are getting a bit off topic here. Could be interesting to bring more people into this discussion having it with the right title. Why don’t we continue this as a feature request?

   

Avatar
Choons, Sr. Member
Posted: 24 September 2011 06:06 AM   Total Posts: 281   [ # 9 ]

I don’t get what you mean by a ‘sprite canvas.’ My point is that it was easy to use CompositeMaterial to have mixtures of materials with repeat both off and on, and to individually scale & offset UV values for each. Sure you can do it with all kinds of matrix ops at the Flash level but it’s 10 times as hard and usually looks worse. I’ll put a feature request in. I really don’t see how you could dissent on this one- CompositeMaterial is one of 3.6’s best features

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X