Hey, thought I might post here and see if anyone has any insights as to how I might solve this. I am trying to render wireframes around 3D meshes. Here’s a visual:
I am using Vectrosity 2.1, and the above screen shot came from the XRay demo that came with the package, slightly modified. Notice the specular lit mesh material. With Vectrosity, the wireframing is spot on, but I need the mesh material as well to get the effect I want.
Anyway, if you look closely at the render, there’s quite a bit of jagginess here and there. It appears to me that there is some “Z-fighting” going on. I’m not sure what to do to get rid of it. If I could do some backface culling on the wireframes and render them over the meshes not in 3D space, I could get what I want out of it. In other words, in order to get this to work, I had to use Vectrosity’s VectorManager like so:
VectorManager.useDraw3D = true;
Any thoughts on how I might get this to work? Smooth Vecrosity lines, no jaggies?
Try making the lines a bit thicker.
–Eric
Would a slight amount of z-offset in the shader not solve this issue? Atleast then you wouldn’t need to make the lines thicker.
Hey Eric, thanks for the quick response. I’ve tried that approach as well as using different materials for the lines, no luck. If I find a solution, I’ll post as Im thinking other Vectrosity users might be interested.
JessyDL, I’ll look into this. I need to write a custom shader for the diffuse mesh anyway, perhaps an offset and/or Ztest will work (http://www.youtube.com/watch?v=f7zDKlsyu6s or http://www.youtube.com/watch?v=MlLvQxZv3h4).
Stay tuned…
Got it! A custom specular shader with the Offset function. First off, here are the results:
Jaggies are basically mitigated down to nothing. And if anyone cares, here’s the shader I used on the specular material:
Shader "Colored Specular" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
}
SubShader {
Tags { "RenderType"="Opaque" }
Offset 1, 1
LOD 400
CGPROGRAM
#pragma surface surf BlinnPhong
sampler2D _MainTex;
fixed4 _Color;
half _Shininess;
struct Input {
float2 uv_MainTex;
};
void surf (Input IN, inout SurfaceOutput o) {
fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = tex.rgb * _Color.rgb;
o.Gloss = tex.a;
o.Alpha = tex.a * _Color.a;
o.Specular = _Shininess;
}
ENDCG
}
FallBack "Specular"
}
1 Like