What about this?the wireframe not change when add tessellation.
Unity staff is probably going to ask you do submit a bug-report, following the advice given in this document.
If you want to speed things up, it’s probably a good idea to submit that bug-report already and post its case number here for UT to pick up.
Is tessellation already available…where can i get a tessellation shader ?
As peter already mentioned, please submit a bug report for this issue and reply in here with the case #.
This shader is not supported, it compiles to the folder Not Supported under metal.
Thanks for the info. I’ve forwarded it and asked the devs for a working example.
I can’t tell much from this picture alone. But I think at the moment if you’re using iOS target in the editor, the Tessellation shader feature is not enabled for Metal Graphics emulation. The workaround is to use iOS target in the editor with emulation disabled (Edit → Graphics Emulation → No Emulation) or use standalone for experimenting.
I tried the shader in question myself in 2018.1.0b2 and didn’t see any errors.
I’d go with checking out existing Asset Store content and using shaders with tessellation that are actually built for specific purpose, along with test scene
Other than several Asset Store packages, this one was also tested http://diary.conewars.com/tessellation-melt-shader-part-3/ during development
Did you just not see errors, or did you actually see tessellation happening?
The melt shader works
And what asset store package did you test and worked well?
Interested to try some out
I’ve only been able to get UnityDistanceBasedTess to work and it doesn’t seem to be generating triangles very smoothly. Below screenshot should be one continuous surface using a height map.
Trying the builtin tessellation functions I got very spiky results. Then I tried this DX11 Tessellation Displacement | DirectX 11 | Unity Asset Store
I used the functions from that to integrate them in my current custom shaders, worked perfectly!
anything to share?
Maybe someone know what is wrong with this shader. It works on DX11 but doesn’t on Metal, and there are no errors and warnings. I was trying to copy constructions from compiled surface shader. For example have changed [domain(“tri”)] with [UNITY_domain(“tri”)] etc. But no success. Unfortunatelly I can’t use surface shader. I’m trying to port this asset to IOS/OSX: Hair Tool | Physics | Unity Asset Store
Shader "Unlit/TestTess"
{
Properties
{
_Tess ("Tessellation", Range(1,32)) = 4
_DiffuseColor ("Diffuse Color", color) = (0.5,0.5,0.5,0.5)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
Pass
{
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
CGPROGRAM
#pragma vertex VS
#pragma fragment FS
#ifdef UNITY_CAN_COMPILE_TESSELLATION
#pragma hull HS
#pragma domain DS
#endif
#pragma target 5.0
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "Tessellation.cginc"
float _Tess;
float4 _DiffuseColor;
struct APP_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct VS_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct HS_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct DS_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
#ifdef UNITY_CAN_COMPILE_TESSELLATION
struct HS_CONSTANT_OUTPUT
{
float edges[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
HS_CONSTANT_OUTPUT HSConst()
{
HS_CONSTANT_OUTPUT o;
o.edges[0] = _Tess;
o.edges[1] = _Tess;
o.edges[2] = _Tess;
o.inside = _Tess;
return o;
}
#endif
VS_OUTPUT VS (APP_OUTPUT v)
{
VS_OUTPUT o;
o.vertex = v.vertex;
o.normal = v.normal;
o.vertex = UnityObjectToClipPos(o.vertex);
return o;
}
#ifdef UNITY_CAN_COMPILE_TESSELLATION
[UNITY_domain("tri")]
[UNITY_partitioning("fractional_odd")]
[UNITY_outputtopology("triangle_cw")]
[UNITY_outputcontrolpoints(3)]
[UNITY_patchconstantfunc("HSConst")]
HS_OUTPUT HS(InputPatch<VS_OUTPUT, 3> ip, uint id : SV_OutputControlPointID)
{
HS_OUTPUT o;
o.vertex = ip[id].vertex;
o.normal = ip[id].normal;
return o;
}
[UNITY_domain("tri")]
DS_OUTPUT DS(HS_CONSTANT_OUTPUT input, OutputPatch<HS_OUTPUT, 3> ip, float3 b : SV_DomainLocation)
{
DS_OUTPUT o;
o.vertex = ip[0].vertex*b.x + ip[1].vertex*b.y + ip[2].vertex*b.z;
o.normal = ip[0].normal*b.x + ip[1].normal*b.y + ip[2].normal*b.z;
o.vertex = UnityObjectToClipPos(o.vertex);
return o;
}
#endif
fixed4 FS (DS_OUTPUT i) : SV_Target
{
float4 col = float4(1,1,1,1);
return col;
}
ENDCG
}
}
}
Does the shader work on Metal with earlier versions of Unity? If that’s the case, then you probably found a regression and it’s helpful to submit a bug-report, following the advice from this document.
It doesn’t, Tesselation on metal has been promiced from Unity 2018.
So with a few tweaks to the shader it works as expected, for the shaders that are dealing with tessellation you need to use “INTERNALTESSPOS” when sharing positional data between the shaders, also you shouldn’t be transforming to clip pos before the tessellation does it’s thing, unless you wanted that behaviour. Here’s the tweaked code for the above shader:
Shader "Unlit/TestTess"
{
Properties
{
_Tess ("Tessellation", Range(1,32)) = 4
_DiffuseColor ("Diffuse Color", color) = (0.5,0.5,0.5,0.5)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
Pass
{
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
CGPROGRAM
#pragma vertex VS
#pragma fragment FS
#ifdef UNITY_CAN_COMPILE_TESSELLATION
#pragma hull HS
#pragma domain DS
#endif
//#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "Tessellation.cginc"
float _Tess;
float4 _DiffuseColor;
struct APP_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct VS_OUTPUT
{
float4 vertex : INTERNALTESSPOS;
float3 normal : NORMAL;
};
struct HS_OUTPUT
{
float4 vertex : INTERNALTESSPOS;
float3 normal : NORMAL;
};
struct DS_OUTPUT
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
#ifdef UNITY_CAN_COMPILE_TESSELLATION
struct HS_CONSTANT_OUTPUT
{
float edges[3] : SV_TessFactor;
float inside : SV_InsideTessFactor;
};
HS_CONSTANT_OUTPUT HSConst()
{
HS_CONSTANT_OUTPUT o;
o.edges[0] = _Tess;
o.edges[1] = _Tess;
o.edges[2] = _Tess;
o.inside = _Tess;
return o;
}
#endif
VS_OUTPUT VS (APP_OUTPUT v)
{
VS_OUTPUT o;
o.vertex = v.vertex;
o.normal = v.normal;
//o.vertex = UnityObjectToClipPos(o.vertex);
return o;
}
#ifdef UNITY_CAN_COMPILE_TESSELLATION
[UNITY_domain("tri")]
[UNITY_partitioning("fractional_odd")]
[UNITY_outputtopology("triangle_cw")]
[UNITY_outputcontrolpoints(3)]
[UNITY_patchconstantfunc("HSConst")]
HS_OUTPUT HS(InputPatch<VS_OUTPUT, 3> ip, uint id : SV_OutputControlPointID)
{
HS_OUTPUT o;
o.vertex = ip[id].vertex;
o.normal = ip[id].normal;
return o;
}
[UNITY_domain("tri")]
DS_OUTPUT DS(HS_CONSTANT_OUTPUT input, OutputPatch<HS_OUTPUT, 3> ip, float3 b : SV_DomainLocation)
{
DS_OUTPUT o;
o.vertex = ip[0].vertex*b.x + ip[1].vertex*b.y + ip[2].vertex*b.z;
o.normal = ip[0].normal*b.x + ip[1].normal*b.y + ip[2].normal*b.z;
o.vertex = UnityObjectToClipPos(o.vertex);
return o;
}
#endif
fixed4 FS (DS_OUTPUT i) : SV_Target
{
float4 col = float4(1,1,1,1);
return col;
}
ENDCG
}
}
}
As for wireframe not working, we know this is an issue and are trying to find the best way to fix it as there are dragons there
Thanks alot, already find that by investigating compiled surface shader. But actually I need isoline tesselation. Do you plan to support it? Unity just crashes when I use:
[domain(“isoline”)]
[partitioning(“integer”)]
[outputtopology(“line”)]
[outputcontrolpoints(3)]
[patchconstantfunc(“HSConst”)]
before HullShader
and
[domain(“isoline”)]
before domain
We do support isoline in Unity so if this is crashing it sounds like a bug and probably is a bug with only Metal as it’s implementation is very new. Do you mind opening a bug report, this will help us track the issue and get it actioned.
Ok
Ok, I’ll report a bug. This is a shader:
Shader "Unlit/TestTess"
{
Properties
{
_Tess ("Tessellation", Range(1,32)) = 4
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 200
Pass
{
Name "FORWARD"
Tags { "LightMode" = "ForwardBase" }
CGPROGRAM
#pragma vertex VS
#pragma fragment FS
#pragma hull HS
#pragma domain DS
#pragma target 5.0
#pragma multi_compile_fwdbase
#include "UnityCG.cginc"
#include "Tessellation.cginc"
float _Tess;
struct APP_OUTPUT
{
float4 vertex : POSITION;
};
struct VS_OUTPUT
{
float4 vertex : INTERNALTESSPOS;
};
struct HS_OUTPUT
{
float4 vertex : INTERNALTESSPOS;
};
struct DS_OUTPUT
{
float4 pos : POSITION;
};
struct HS_CONSTANT_OUTPUT
{
float edges[2] : SV_TessFactor;
};
VS_OUTPUT VS (APP_OUTPUT v)
{
VS_OUTPUT o;
o.vertex = v.vertex;
return o;
}
HS_CONSTANT_OUTPUT HSConst()
{
HS_CONSTANT_OUTPUT o;
o.edges[0] = _Tess;
o.edges[1] = _Tess;
return o;
}
[domain("isoline")]
[partitioning("integer")]
[outputtopology("line")]
[outputcontrolpoints(3)]
[patchconstantfunc("HSConst")]
HS_OUTPUT HS(InputPatch<VS_OUTPUT, 3> v, uint id : SV_OutputControlPointID)
{
HS_OUTPUT o;
o.vertex = v[id].vertex;
return o;
}
[domain("isoline")]
DS_OUTPUT DS(HS_CONSTANT_OUTPUT tessFactors, OutputPatch<HS_OUTPUT, 3> vi, float2 uv : SV_DomainLocation)
{
float4 start = lerp(vi[0].vertex, vi[1].vertex, uv.x);
float4 vertex = lerp(start, vi[2].vertex, uv.y);
DS_OUTPUT o;
o.pos = UnityObjectToClipPos(vertex);
return o;
}
fixed4 FS (DS_OUTPUT i) : SV_Target
{
return fixed4(1,1,1,1);
}
ENDCG
}
}
}