Wireframe Material ever ever ever?

Software: Away3D 4.x

Choons, Sr. Member
Posted: 18 September 2011 07:27 PM   Total Posts: 281

one of the most surprising missing features to new users I should think. I’ve seen it done using AGAL


look toward bottom for Furqan’s post

he had a great demo up but it looks like he never updated it for the new player

also there’s this



Alejandro Santander, Administrator
Posted: 20 September 2011 01:33 AM   Total Posts: 414   [ # 1 ]

Hey Choons,

I created a wireframe material in my Minimole experiments using PB3D: http://www.lidev.com.ar/minimole/

There is a runtime bug but it still should work. I haven’t recompiled that one for the latest FP.

I based my implementation in a technique pretty much like the one exposed in that paper you show. It works very well, but hasn’t been taken into Away3D for several reasons. The most significant is that shaders don’t have access to neighboring vertices, so you have to pass data about neighbors to each vertex, meaning that the mesh that will receive a wireframe material must be pre-processed by injecting such data into the shader’s data flow. This is hard to implement generically in the engine without complicating other stuff. This solution is a pretty custom situation, i.e, easy to resolve in a small engine but complicated to implement in a large, flexible and efficient engine like Away3D. This is why we have not implemented this solution yet. It’s a pitty because I do love wireframe. Minimole is on Github, you can see how it’s done there in case you want to dig in the topic.

Perhaps we are mistaken and this is worth some further discussion.


Choons, Sr. Member
Posted: 20 September 2011 02:12 AM   Total Posts: 281   [ # 2 ]

thx for the reply, Alejandro. I’m still learning how to do things at the AGAL level so I really don’t have the full picture of how Away3D is using shaders. Furqan pulled it off by realizing that edges would lack a color component. He wrote

“was looking at an image of triangle which had red green and blue assigned to each of the vertex so I wondered what the difference is between an edge pixel and the pixel inside this triangle and it struck me (the edge pixel lacks one of the components either red green or blue) so I used this idea to write the shader.”

I don’t know if he also needed the neighbor info injected in as you mention, but it sounds to me like he only had to evaluate pixels by themselves for color components. The shader code is on that forum post link

Seems to me no wireframe capability in a 3D engine is a pretty big missing feature?


Alejandro Santander, Administrator
Posted: 20 September 2011 02:24 AM   Total Posts: 414   [ # 3 ]

Yeah, I also used vertex coloring in my implementation in order to detect edges.

I agree that it is an important feature, I was just expressing that the current solution feels a bit messy and hacky. If I have a chance tho, I’ll try to implement it, but with the large todo list we have it probably won’t happen until its is really needed by someone in a particular practical situation.

This would be most likely for 3D editor like apps, and for now most people will be targeting more game stuff than that. If you think about it, it is very rare to see wireframes in a game.


Choons, Sr. Member
Posted: 20 September 2011 02:30 AM   Total Posts: 281   [ # 4 ]

ah I see. Yeah wireframe is mainly for development/debugging. It doesn’t seem like a priority until things aren’t working right. Then it’s a big priority wink


Alejandro Santander, Administrator
Posted: 20 September 2011 02:37 AM   Total Posts: 414   [ # 5 ]

Yes, it is VERY useful for debugging, I agree. I have often done very weird things in 4.x to be able to see those little triangles face to face, hehe.

I also think this is a must have. Lets see who else agrees with us…


Choons, Sr. Member
Posted: 20 September 2011 03:07 AM   Total Posts: 281   [ # 6 ]

“very weird things in 4.x to be able to see those little triangles”  <—HAHA! me too. Exactly. Yeah let’s see what the rest of the folks think as well.


EFFalcon, Jr. Member
Posted: 20 September 2011 06:33 AM   Total Posts: 44   [ # 7 ]

i went hunting for this a few weeks ago, so yeah, i’d certainly find it useful.


theMightyAtom, Sr. Member
Posted: 20 September 2011 06:23 PM   Total Posts: 669   [ # 8 ]

The wireframe material works fine for my test purposes. Surprised no-one mentioned it…

(choose wireframe and change segments)


Choons, Sr. Member
Posted: 20 September 2011 06:38 PM   Total Posts: 281   [ # 9 ]

WireframeMapGenerator ? I had a post a while back asking for how to use that. Nobody ever answered it. Care to enlighten us, Pete?


Alejandro Santander, Administrator
Posted: 20 September 2011 07:28 PM   Total Posts: 414   [ # 10 ]

Yeah, that is useful for sure, but not an actual wire frame since it is bitmap based, i.e. not vector like or resolution independent. It seems to join vertices in uv space and create an image, which is then used as a texture.

@theMightyAtom, is that in the Away3D 4.x lib now, where, how do you use it?


theMightyAtom, Sr. Member
Posted: 20 September 2011 07:36 PM   Total Posts: 669   [ # 11 ]

It’s been there forever, as far as I remember.
Check out the class here:


You send it a mesh and you get back a bitmapdata you can use in a BitmapMaterial. It may not be vector, but for seeing your triangles, it’s good enough.


Alejandro Santander, Administrator
Posted: 20 September 2011 07:45 PM   Total Posts: 414   [ # 12 ]

Good to know! thx

I guess this will do for now raspberry


Choons, Sr. Member
Posted: 20 September 2011 08:14 PM   Total Posts: 281   [ # 13 ]

yeah I knew it was there, but like I said, I couldn’t figure out how to use it. Another example of something useful that isn’t obvious how to use (unless you’re Atomic raspberry)


Choons, Sr. Member
Posted: 26 September 2011 01:09 AM   Total Posts: 281   [ # 14 ]

wow- just tried out the WireframeMapGenerator on a cylinder primitive and it looks really screwball. Using the HoverDragController reveals other strange things like it becoming really badly pixelated when zooming back. I was hoping this would be a good solution for wireframe but it looks like it has some major problems. Here’s the code I used:

var wire_mat:BitmapMaterial = new BitmapMaterial();
cylinder_1 = new Cylinder(); // declared globally before
wire_mat.bitmapData = WireframeMapGenerator.generateSolidMap(cylinder_1 as Mesh, 13421772, 2, 16777215, 0, 1024, 1024);
cylinder_1.material = wire_mat;

EDIT: OK I figured out if you set topClosed & bottomClosed to false and give the fillAlpha a value of 1 it works MUCH better


John Brookes, Moderator
Posted: 26 September 2011 11:12 AM   Total Posts: 732   [ # 15 ]

Its because the UVs for the top and bottom are overlaid the UVs for the sides.
would be better as separate UV shells.

Draw the bitmap from the wireframe generator thang to the stage to see.



Away3D Forum

Member Login