Hi guys and gals, I’ve looked around but can’t seem to find any info on whether it’s possible to have the main camera render in wireframe mode? I did find some stuff on Unity Pro but that doesn’t help me
I’d quite like to do some cool retro stuff, a la Battlezone.
If you had read the whole thread you would have noticed that the shaderlab syntax has changed (this thread is quite old). At the second page there is a post with the corrected line-material.
Hey guys, I prefer c# so I rewrote and uhm changed the script a bit
it renders every line two times so now you can choose, which line of the triangles to render, which gives some kind of random but faster mesh, quite interesting too.
using UnityEngine;
using System.Collections;
public class wireframe : MonoBehaviour {
public bool render_mesh_normaly = true;
public bool render_lines_1st = false;
public bool render_lines_2nd = false;
public bool render_lines_3rd = false;
public Color lineColor = new Color (0.0f, 1.0f, 1.0f);
public Color backgroundColor = new Color (0.0f, 0.5f, 0.5f);
public bool ZWrite = true;
public bool AWrite = true;
public bool blend = true;
public float lineWidth = 3;
public int size = 0;
private Vector3[] lines ;
private ArrayList lines_List ;
public Material lineMaterial ;
//private MeshRenderer meshRenderer;
/*
████████ ▄▀▀■ ▀▀█▀▀ ▄▀▀▄ █▀▀▄ ▀▀█▀▀
████████ ▀■■▄ █ █■■█ █▀▀▄ █
████████ ■▄▄▀ █ █ █ █ █ █
*/
void Start () {
//meshRenderer = gameObject.GetComponent<MeshRenderer>();
if (lineMaterial == null) {
lineMaterial = new Material ("Shader \"Lines/Colored Blended\" {" +
"SubShader { Pass {" +
" BindChannels { Bind \"Color\",color }" +
" Blend SrcAlpha OneMinusSrcAlpha" +
" ZWrite on Cull Off Fog { Mode Off }" +
"} } }");
/*lineMaterial = new Material ("Shader \"Lines/Colored Blended\" {" +
"SubShader { Pass {" +
" Blend SrcAlpha OneMinusSrcAlpha" +
" ZWrite Off Cull Front Fog { Mode Off }" +
"} } }");*/
}
lineMaterial.hideFlags = HideFlags.HideAndDontSave;
lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
lines_List = new ArrayList();
MeshFilter filter = gameObject.GetComponent<MeshFilter>();
Mesh mesh = filter.mesh;
Vector3[] vertices = mesh.vertices;
int[] triangles = mesh.triangles;
for (int i = 0; i+2 < triangles.Length; i+=3)
{
lines_List.Add(vertices[triangles*]);*
lines_List.Add(vertices[triangles[i + 1]]);*
lines_List.Add(vertices[triangles[i+ 2]]);*
}*
//lines_List.CopyTo(lines);//arrays are faster than array lists*
Beautiful. Just beautiful. Thank you so much. Going for a Tron-esque 80's sci fi lo-fi look for my title menu and this works great on making vectorized-looking models after I lowered their poly counts.
Does this still work in Unity 4.6? I tried adding this script on my object but nothing happens.. no error either. I tried on Unity3d built-in Cube object and also on cubes I generated programmatically. I make sure this script is executed last by adding it last in the component window. Any clue?
I got it working in unity 4.6 with the following changes: public Material lineMaterial ; -- >remove "public" (don't want to set this manually, it never works- at least with MY materials) cut the line: GL.Color(lineColor); paste it under BOTH: GL.Begin(GL.LINES); and GL.Begin(GL.QUADS);
Thanks, I'll check it out. I didn't realise you could use it for pre-existing models, too. Very cool. Now I just have to raise the cash...lol. Is there a demo so I can check it out properly? I have to spend wisely, being a game student. LOL.
Just checked out the online demos... VERY NICE! I think I'll have to purchase when I can afford it ;-) Let's hope my first game sells so I can! LOL. This is EXACTLY what I want ;-)
@POLYGAMe: there are various demos on the Vectrosity page. If you mean a demo of the actual product, that's not really feasible. 99% of people who've bought it like it though. If it doesn't work for you, I'll give you a refund. It probably won't take long to find $20 worth of beer cans to recycle. ;)
Hi Eric... got sidetracked by new game project, which is selling quite well, so decided to buy your plugin. Does it support Unity 3.5? I have noticed that these scripts no longer do... Cheers!
If you don’t mind having a fixed black colour for the triangles, you can use the inbuilt VR/SpatialMapping/Wireframe shader, available from 2017 onwards.
On standard displays, this will draw a wireframe on top of black triangles. On AR displays like HoloLens, the triangles will be transparent, leaving the wireframe.
The advantage of this approach is that there are no external dependencies and it works in seconds with any MeshFilter. I often use it for debugging procedural mesh generation scripts.
For those who have pro and wander into this question, it looks like there's an implementation available [here.][1] [1]: http://forum.unity3d.com/threads/8814-Wireframe-3D
– Chris-DActually the GL class works also with the indy version. I'm not sure if it's a bug since the docs states it's pro only but i used it a lot in the editor and also in <a href="http://dl.dropbox.com/u/7761356/UnityAnswers/Web/CrazyNormals/WebPlayer.html">indy-webbuilds</a>.
– Bunny83I got one of the scripts working but it only displays black lines :( Can't seem to change it...
– POLYGAMeIf you had read the whole thread you would have noticed that the shaderlab syntax has changed (this thread is quite old). At the second page there is a post with the corrected line-material.
– Bunny83Thanks, Bunny! I don't know how I missed that! All working sweet, now :)
– POLYGAMe