- Home /
How do you write a flexible wireframe shader with backface culling?
Hello! My First question here.
I'm working on a game concept, and I'd like to use Unity to build a working prototype, if not the completed game, but I'm stuck on how to render the game the way I'd like it to look visually. This is a question that has been asked time and again, but I haven't seen a comprehensive answer yet, so I'll see what happens here.
So I'm looking for a game that renders like a Tron game mixed with old 80's 3D vector game graphics, ala Battlezone or Star Wars arcade. Better yet, FOTONICA (http://www.fotonica-game.com/). I reached out to the author of Fotonica, and he said they built the game in Unity, and used a post processing effect (shader) to get the desired vector effect. Shader's are a bit out of my comfort zone, but I am not unwilling to dive in to CG/HLSL/Shaderlab if needed.
Additionally, I want to be able to animate the lines as textures. So, for example, if I wanted the vector lines of a sword to animate different colors in waves along the edge of the sword, I'd simply use an animated texture. Additionally, I want to add glows to my wireframe objects. Lastly, I want backface culling, or even better, phong shading to give a very dull dark matte finish to the objects so that the edge are brightly lit and colored, but the objects themselves have a sense of "weight."
I've looked at a lot of online resources (including a number of posts on Unity Answers), and even purchased the latest version of Vectrosity. This might do the trick, but when playing around with a few prototypes, seeing how hard I could push Vectrosity to render as many lines as possible, it choked a bit earlier than I would have liked. I see that in Unity 4 you can render scenes with GL.wireframe = true, but it doesn't appear to be very flexible (documentation is pretty sparse on this).
Any thoughts out there on where to begin? Any thoughts/insights/pointers/direction would be greatly appreciated. Thanks so much!
I too would like to see a definitive answer to this. I've read about a way to do this using like barycentric calculations or something like that, but never tried it our seen examples, but hey maybe check this out
http://answers.unity3d.com/questions/198467/How-to-create-VectrexVector-look-in-games-.html
one point: by wireframe + backface culling,
do you mean you want it to draw a wireframe, BUT, only for the triangle edges where the face of the tri is visible?
("backface culling" just means that the rendering pipeline understands that (of course) mesh has a front side (which it renders) and a backside (which it does not render). this is completely standard and normal on any game engine or rendering pipeline today.)
I imagine he must mean that, have a look at that game he was talking about, it does just that in unity somehow, very nicely. Any idea how its done?
Answer by Bunny83 · Mar 12, 2013 at 02:54 PM
I've added a comment to my answer on the above mentioned question. I created a sample project of the barycentric wireframe shader quite a while ago.
"So each corner of each triangle should be either (0,0) , (0,1) or (1,0)." Brilliant, i never knew the trick. How awesome.
Exactly ;) Since all the primitive geometry in Unity (cube, sphere, ...) are mapped to a single texture all coordinates are always between 0 and 1 and work pretty well with the shader.
right, what you describe even works "out of the box" with the unity menu shapes. anyway V clever
awesome, I will give this a shot today.
EDIT: I dig it, will probably put this to use soon!
Your answer
![](https://koobas.hobune.stream/wayback/20220613091104im_/https://answers.unity.com/themes/thub/images/avi.jpg)