Skip to main content
1-Visitor
March 29, 2021
Question

How to display model by Wireframe in Vuforia Studio

  • March 29, 2021
  • 1 reply
  • 2436 views

I want to display the model by Wireframe in Vuforia Studio.
According to PTC's confirmation, it does not support wireframes, and there are no plans to support it in the future.
I want to use Shader for wireframe display. Does anyone know a sample or how to make it?

I've already tried XrayShader, but my client wants a full wireframe display

 

Best Regards.

Takahiro

1 reply

17-Peridot
March 29, 2021

Hello Takahiro,

 

This behavior doesn't exist in Vuforia Studio.

 

The only possible that I see is to use a custom shader to draw a wireframe.

It might be possible to port this GLSL shader into Vuforia Studio GLSL shader :

https://github.com/rreusser/glsl-solid-wireframe

 

Best regards,

Samuel

1-Visitor
April 1, 2021

Thank you for presenting the information
I'm trying, but I haven't done it yet.
The TML text of Vuforia Studio only describes the vertex shader and fragment shader. Is this feasible?

 

It is the content that I am trying variously
I'm aiming for a look similar to a wireframe, but it's a little different.

 

 

okuno_takahiro_0-1617239113773.png

<script name="testShader2" type="x-shader/x-fragment">
precision mediump float;
varying vec4 vertexCoord;
void main() {
float sinx = sin(400.0 * vertexCoord.x);
float siny = sin(400.0* vertexCoord.y);
float alpha = step(0.85, 1.0 - abs(sinx*siny));
vec3 black= vec3(0.0);
gl_FragColor = vec4(black,alpha);
}
</script>
<script name="testShader2" type="x-shader/x-vertex">
attribute vec4 vertexPosition;
varying vec4 vertexCoord;
uniform mat4 modelViewProjectionMatrix;
void main() {
gl_Position = modelViewProjectionMatrix * vertexPosition;
vertexCoord = gl_Position;
}

 

okuno_takahiro_1-1617239205101.png

<script name="Xray" type="x-shader/x-fragment">
 precision mediump float;
varying vec3 P;
varying vec3 N;
varying vec3 I;

varying vec3 vViewSpaceVert;
varying vec3 vViewVector;
varying vec3 vNorm;
 uniform float r;
 uniform float g;
 uniform float b;

 uniform float thre;
 uniform float opa1;
 uniform float opa2;

 const float edgeFalloff = 0.8;
 const float intensity = 1.0;
 const float ambient = 0.2;
 
 void main() {
 vec4 color = vec4(r,g,b,1.0);
 float opacity = abs(dot(normalize(-N), normalize(-I)));

opacity = abs(opacity);
 // gl_FragColor = opacity * color;
if(opacity<thre)
{
gl_FragColor = vec4(r,g,b,opa1);
gl_FragColor.a=opa1;
}
else
{
gl_FragColor = vec4(1.0,1,1,opa2);
gl_FragColor.a=opa2;
}
 }
 </script>

<script name="Xray" type="x-shader/x-vertex">
 attribute vec3 vertexPosition;
 attribute vec3 vertexNormal;
 
 varying vec3 I;
 varying vec3 N;
 
 uniform mat4 modelViewProjectionMatrix;
 uniform mat4 modelViewMatrix;
 uniform mat4 normalMatrix;
 
 void main() {
 vec4 vp4 = vec4(vertexPosition,1.0);
 vec4 P = modelViewMatrix * vp4;
 I = P.xyz - vec3(0);
 N = vec3(normalMatrix * vec4(vertexNormal,0.0));
 gl_Position = modelViewProjectionMatrix * vp4;
 }

</script>
17-Peridot
April 1, 2021

Hello Okuno Takahiro,

 

Yes, I think it is possible.

After looking in more details the source code of wireframe shader, I have tried to import it in Vuforia Studio.

Please find Project attached.

But it doesn't work for the moment.

It seems something is wrong in fragment shader.

 

It needs more work to have this effect work fine.

 

Best regards,

Samuel