This website uses cookies. By clicking Accept, you consent to the use of cookies.
Click Here
to learn more about how we use cookies.
Accept
Reject
Browse
VR Forums
Announcements
Get Help
Talk VR
VR Experiences
International
Off-Topic
Developer Forums
Unity Development
Unreal Development
Meta Spatial SDK Development
Mobile Development
Web Development
OpenXR Development
General VR & MR Development
PCVR/Link Development
Quest Development
Accessibility Development
Developer Dashboard Feedback
SDK Development
Tool Feedback
Other VR Development
MVPs
Creator Forum
Getting Started
Events & Competitions
Community Resources
Creator Questions & Discussions
What I'm Building
Events Calendar
Help
Sign In
cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Search instead for
Did you mean:
Meta Community Forums
Developer
Quest
wireframe shader issue only in Quest 2 [Unity]
Options
Subscribe to RSS Feed
Mark Topic as New
Mark Topic as Read
Float this Topic for Current User
Bookmark
Subscribe
Mute
Printer Friendly Page
wireframe shader issue only in Quest 2 [Unity]
Carpy
Honored Guest
Options
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
10-15-2020
10:16 AM
So I have a wireframe shader that is working correctly in Quest 1 and multiple other platforms, however, in Quest 2 only one eye renders.
Could anyone assist?, this of course only happens in multi-view (single pass) rendering
here is the code:
Shader "Custom/WireframeTest"
{
Properties
{
_DispTex("Disp Texture", 2D) = "gray" {}
_Displacement("Displacement", Range(0, 1.0)) = 0.3
_Offset("Offset", Vector) = (0,0,0,0)
_WireColor("WireColor", Color) = (1,0,0,1)
_Color("Color", Color) = (1,1,1,1)
[Enum(Off,0,Back,1,Front,2)] _ShowBackfaces("Cull", Int) = 1
}
SubShader
{
Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
ZTest Less
ZWrite Off
CGPROGRAM
#include "UnityCG.cginc"
#pragma target 5.0
#pragma vertex vert
#pragma geometry geom
#pragma fragment frag
#pragma multi_compile UseVertexColor_ON UseVertexColor_OFF
half4 _WireColor, _Color;
struct appdata {
float4 vertex : POSITION;
float4 color: COLOR;
float4 tangent : TANGENT;
float3 normal : NORMAL;
float2 texcoord : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2g
{
float4 pos : SV_POSITION;
float4 color: COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct g2f
{
float4 pos : SV_POSITION;
float4 color: COLOR;
float2 uv : TEXCOORD0;
float3 dist : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};
sampler2D _DispTex;
float _Displacement;
float4 _Offset;
v2g vert(appdata v)
{
v2g OUT;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, OUT);
float d = tex2Dlod(_DispTex, float4(v.texcoord1.x + _Offset.x, v.texcoord1.y + _Offset.y, 0, 0)).r * _Displacement;
v.vertex.xyz += v.normal * d;
OUT.pos = UnityObjectToClipPos(v.vertex);
OUT.color = v.color;
OUT.uv = v.texcoord; // The UVs aren't used in this shader but are included in case you want to use them.
return OUT;
}
[maxvertexcount(3)]
void geom(triangle v2g IN[3], inout TriangleStream<g2f> triStream)
{
UNITY_SETUP_INSTANCE_ID(IN[0]);
UNITY_SETUP_INSTANCE_ID(IN[1]);
UNITY_SETUP_INSTANCE_ID(IN[2]);
float2 WIN_SCALE = float2(_ScreenParams.x / 1.5, _ScreenParams.y / 1.5);
// Frag position
float2 p0 = WIN_SCALE * IN[0].pos.xy / IN[0].pos.w;
float2 p1 = WIN_SCALE * IN[1].pos.xy / IN[1].pos.w;
float2 p2 = WIN_SCALE * IN[2].pos.xy / IN[2].pos.w;
// Barycentric position
float2 v0 = p2 - p1;
float2 v1 = p2 - p0;
float2 v2 = p1 - p0;
// Triangles area
float area = abs(v1.x*v2.y - v1.y * v2.x);
g2f OUT;
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
OUT.pos = IN[0].pos;
OUT.color = IN[0].color;
OUT.uv = IN[0].uv;
OUT.dist = float3(area / length(v0),0,0);
triStream.Append(OUT);
OUT.pos = IN[1].pos;
OUT.color = IN[1].color;
OUT.uv = IN[1].uv;
OUT.dist = float3(0,area / length(v1),0);
triStream.Append(OUT);
OUT.pos = IN[2].pos;
OUT.color = IN[2].color;
OUT.uv = IN[2].uv;
OUT.dist = float3(0,0,area / length(v2));
triStream.Append(OUT);
}
half4 frag(g2f IN) : COLOR
{
// Distance of frag from triangles center
float d = min(IN.dist.x, min(IN.dist.y, IN.dist.z));
// Fade based on dist from center
float I = exp2(-1 * d*d);
#if UseVertexColor_OFF
return lerp(_Color, _WireColor, I);
#else
return lerp(_Color * IN.color, _WireColor * IN.color, I);
#endif
}
ENDCG
}
}
FallBack "Transparent/VertexLit"
}
wireframe shader unity quest 2
All forum topics
Previous Topic
Next Topic
1 REPLY
1
EndritP
Honored Guest
Options
Mark as New
Bookmark
Subscribe
Mute
Subscribe to RSS Feed
Permalink
Print
Report Inappropriate Content
11-05-2020
08:08 AM
I don't know about your problem but I'm also having a shader issue (only in quest 2)
Post Reply
Related Content
Quest 3 + Unity 6 + Meta MR Utility Kit: Avatar incorrectly occludes real objects in PassthroughReli
in
Unity Development
yesterday
Questions about build issues
in
Unity Development
01-03-2025
360 Video Streaming Performance on Quest 2 and Quest 3
in
Meta Spatial SDK Development
12-18-2024
Meta Avatar lightning problem
in
Unity Development
11-29-2024
Environment Depth could not be retrieved! Please ensure the following:
in
Unity Development
11-27-2024