Jump to content
  • Advertisement
Sign in to follow this  
KaiserJohan

DX11 Strange tessellation pattern

Recommended Posts

Am trying a basebones tessellation shader and getting unexpected result when increasing the tessellation factor. Am rendering a group of quads and trying to apply tessellation to them.

OutsideTess = (1,1,1,1), InsideTess= (1,1)

tess1.thumb.png.ae2ae3d6ec1d4f567cb44f7d6cc2eb0f.png

OutsideTess = (1,1,1,1), InsideTess= (2,1)

tess2.thumb.png.5507781b7622138dba482b0bc5593566.png

I expected 4 triangles in the quad, not two. Any idea of whats wrong?

Structs:

struct PatchTess
{
	float mEdgeTess[4] : SV_TessFactor;
	float mInsideTess[2] : SV_InsideTessFactor;
};

struct VertexOut
{
	float4 mWorldPosition : POSITION;
	float mTessFactor : TESS;
};

struct DomainOut
{
	float4 mWorldPosition : SV_POSITION;
};

struct HullOut
{
	float4 mWorldPosition : POSITION;
};

Hull shader:

PatchTess PatchHS(InputPatch<VertexOut, 3> inputVertices)
{
	PatchTess patch;

	patch.mEdgeTess[ 0 ] = 1;
	patch.mEdgeTess[ 1 ] = 1;
	patch.mEdgeTess[ 2 ] = 1;
	patch.mEdgeTess[ 3 ] = 1;
	
	patch.mInsideTess[ 0 ] = 2;
	patch.mInsideTess[ 1 ] = 1;

	return patch;
}

[domain("quad")]
[partitioning("fractional_odd")]
[outputtopology("triangle_ccw")]
[outputcontrolpoints(4)]
[patchconstantfunc("PatchHS")]
[maxtessfactor( 64.0 )]
HullOut hull_main(InputPatch<VertexOut, 3> verticeData, uint index : SV_OutputControlPointID)
{
	HullOut ret;

	ret.mWorldPosition = verticeData[index].mWorldPosition;

	return ret;
}

 

Domain shader:

[domain("quad")]
DomainOut domain_main(PatchTess patchTess, float2 uv : SV_DomainLocation, const OutputPatch<HullOut, 4> quad)
{
	DomainOut ret;

	const float MipInterval = 20.0f;

	ret.mWorldPosition.xz = quad[ 0 ].mWorldPosition.xz * ( 1.0f - uv.x ) * ( 1.0f - uv.y )
		+ quad[ 1 ].mWorldPosition.xz * uv.x * ( 1.0f - uv.y )
		+ quad[ 2 ].mWorldPosition.xz * ( 1.0f - uv.x ) * uv.y
		+ quad[ 3 ].mWorldPosition.xz * uv.x * uv.y ;
	ret.mWorldPosition.y = quad[ 0 ].mWorldPosition.y;
	ret.mWorldPosition.w = 1;

	ret.mWorldPosition = mul( gFrameViewProj, ret.mWorldPosition );

	return ret;
}

 

Any ideas what could be wrong with these shaders?

Share this post


Link to post
Share on other sites
Advertisement

I has been a long time since I touched graphics, but if I remember correctly OutsideTess tells how to split edges, while InsideTess tells how to split inside surface (quad in this case).

Using output OutsideTess = (1,1,1,1), InsideTess= (2,1) essentially tells it to split 1 quad into 3 triangles, but have only 4 vertices in total. That's quite impossible so it doesn't make anything sensible. Try using OutsideTess = (2,2,2,2), InsideTess= (2,2).

Share this post


Link to post
Share on other sites

Still wierd sadly. Must be something wrong with the shaders but I cant figure out why? The vertex/index buffers must be legit as per first screenshot is fine... 

asd.thumb.png.f62302477955697836abd00f5e9a4712.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!