Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "443eb9/Wireframe"
- {
- Properties
- {
- _WireThickness ("WireThickness", Range(0, 0.1)) = 0.05
- [HDR] _WireColor ("WireColor", Color) = (1, 1, 1, 1)
- }
- SubShader
- {
- Tags
- {
- "RenderPipeline"="UniversalPipeline"
- "Queue"="Transparent"
- "RenderType"="Transparent"
- }
- LOD 100
- Pass
- {
- ZWrite Off
- Cull Off
- Blend SrcAlpha OneMinusSrcAlpha
- HLSLPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma geometry geom
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
- #pragma multi_compile_instancing
- #pragma instancing_options renderinglayer
- CBUFFER_START(UnityPerMaterial)
- float _WireThickness;
- float4 _WireColor;
- CBUFFER_END
- #if defined(UNITY_DOTS_INSTANCING_ENABLED)
- UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
- UNITY_DOTS_INSTANCED_PROP(float, _WireThickness)
- UNITY_DOTS_INSTANCED_PROP(Color, _WireColor)
- UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
- #define _WireThickness UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float, _WireThickness)
- #define _WireColor UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(Color, _WireColor)
- #endif
- struct Attributes
- {
- float3 positionOS : POSITION;
- #if UNITY_ANY_INSTANCING_ENABLED
- UNITY_VERTEX_INPUT_INSTANCE_ID
- #endif
- };
- struct GeomToFrag
- {
- float4 positionHCS : SV_POSITION;
- float3 barycentric : TEXCOORD0;
- #if UNITY_ANY_INSTANCING_ENABLED
- UNITY_VERTEX_INPUT_INSTANCE_ID
- #endif
- };
- struct Varyings
- {
- float4 positionHCS : SV_POSITION;
- #if UNITY_ANY_INSTANCING_ENABLED
- UNITY_VERTEX_INPUT_INSTANCE_ID
- #endif
- };
- Varyings vert(Attributes IN)
- {
- Varyings OUT;
- OUT.positionHCS = TransformObjectToHClip(IN.positionOS);
- #if UNITY_ANY_INSTANCING_ENABLED
- UNITY_SETUP_INSTANCE_ID(IN);
- UNITY_TRANSFER_INSTANCE_ID(IN, OUT);
- #endif
- return OUT;
- }
- float3 barycentricColor[] = {float3(1.0, 0.0, 0.0), float3(0.0, 1.0, 0.0), float3(0.0, 0.0, 1.0)};
- [maxvertexcount(3)]
- void geom(triangle Varyings IN[3], inout TriangleStream<GeomToFrag> triangleStream)
- {
- GeomToFrag OUT;
- triangleStream.RestartStrip();
- for (int i = 0; i < 3; ++i)
- {
- OUT.positionHCS = IN[i].positionHCS;
- OUT.barycentric = barycentricColor[i];
- #if UNITY_ANY_INSTANCING_ENABLED
- UNITY_SETUP_INSTANCE_ID(IN[i]);
- UNITY_TRANSFER_INSTANCE_ID(IN[i], OUT);
- #endif
- triangleStream.Append(OUT);
- }
- }
- float4 frag(GeomToFrag IN) : SV_Target
- {
- UNITY_SETUP_INSTANCE_ID(IN);
- float3 delta = abs(ddx(IN.barycentric)) + abs(ddy(IN.barycentric));
- delta = IN.barycentric - delta;
- float closest = min(delta.x, min(delta.y, delta.z));
- float alpha = step(closest, _WireThickness);
- return float4(_WireColor.rgb, alpha);
- }
- ENDHLSL
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement