• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
~Helgon

Icosahedron Tessellation

8 posts in this topic

Hey, I have following problem.

I generate an Icosahedron and pass it to the tessellation stage but all i get back is just a single triangle subdivided.

Just an other question - I'm not sure if i understood it right so: I can pass a objects with a maximum CONTROL_POINT_PATCHLIST of 32 - what if the polygon i want to pass has more vertices then 32?

But back to my main problem. The vertices are passed here - i think that this should be right

[CODE]
GeometryGenerator geoGen;
GeometryGenerator::MeshData sp;
geoGen.CreateGeosphere(25, 0, sp);
vc = sp.Vertices.size();
std::vector<XMFLOAT3> vertices(sp.Vertices.size());
std::wostringstream wos;
wos << L"Vertices Count: " << sp.Vertices.size() << "\n";
OutputDebugString(wos.str().c_str());
for(int i = 0; i < sp.Vertices.size(); ++i)
{
vertices[i] = sp.Vertices[i].Position;
}
D3D11_BUFFER_DESC vbd;
vbd.Usage = D3D11_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(XMFLOAT3) * 12;
vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &amp;vertices[0];
HR(md3dDevice->CreateBuffer(&amp;vbd, &amp;vinitData, &amp;mQuadPatchVB));
[/CODE]

and the input topology is:

[CODE]
md3dImmediateContext->IASetInputLayout(InputLayouts::Pos);
md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_12_CONTROL_POINT_PATCHLIST);
[/CODE]

and the HLSL is - in fact it should work but i don't know why it just displays the first triangle.

[CODE]

#include "LightHelper.fx"

cbuffer cbPerFrame
{
DirectionalLight gDirLights[3];
float3 gEyePosW;
float gFogStart;
float gFogRange;
float4 gFogColor;
};
cbuffer cbPerObject
{
float4x4 gWorld;
float4x4 gWorldInvTranspose;
float4x4 gWorldViewProj;
float4x4 gTexTransform;
Material gMaterial;
};
// Nonnumeric values cannot be added to a cbuffer.
Texture2D gDiffuseMap;
SamplerState samAnisotropic
{
Filter = ANISOTROPIC;
MaxAnisotropy = 4;
AddressU = WRAP;
AddressV = WRAP;
};
struct VertexIn
{
float3 PosL : POSITION;
};
struct VertexOut
{
float3 PosL : POSITION;
};
VertexOut VS(VertexIn vin)
{
VertexOut vout;
vout.PosL = vin.PosL;
return vout;
}
struct PatchTess
{
float EdgeTess[3] : SV_TessFactor;
float InsideTess[1] : SV_InsideTessFactor;
};
PatchTess ConstantHS(InputPatch<VertexOut, 12> patch, uint patchID : SV_PrimitiveID)
{
PatchTess pt;
pt.EdgeTess[0] = 15;
pt.EdgeTess[1] = 15;
pt.EdgeTess[2] = 15;

pt.InsideTess[0] = 15;
return pt;
}
struct HullOut
{
float3 PosL : POSITION;
};
[domain("tri")]
[partitioning("integer")]
[outputtopology("triangle_cw")]
[outputcontrolpoints(12)]
[patchconstantfunc("ConstantHS")]
[maxtessfactor(64.0f)]
HullOut HS(InputPatch<VertexOut, 12> p, uint i : SV_OutputControlPointID, uint patchID : SV_PrimitiveID)
{
HullOut hout;
hout.PosL = p[i].PosL;
return hout;
}
struct DomainOut
{
float4 PosH : SV_POSITION;
float4 Color : COLOR;
};

[domain("tri")]
DomainOut DS(PatchTess patchTess, float3 uv : SV_DomainLocation, const OutputPatch<HullOut, 12> tri)
{
DomainOut dout;

float3 p = uv.x*tri[0].PosL + uv.y*tri[1].PosL + uv.z*tri[2].PosL;
dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.Color = float4(uv.yx, 1-uv.x, 1);

return dout;
}
float4 PS(DomainOut pin) : SV_Target
{
return pin.Color;
}
technique11 Tess
{
pass P0
{
SetVertexShader( CompileShader( vs_5_0, VS() ) );
SetHullShader( CompileShader( hs_5_0, HS() ) );
SetDomainShader( CompileShader( ds_5_0, DS() ) );
SetPixelShader( CompileShader( ps_5_0, PS() ) );
}
}
[/CODE]

Probably it's just something pretty stupid but i hope someone can help me.

Regards ~Helgon Edited by ~Helgon
0

Share this post


Link to post
Share on other sites
I think i found the mistake:

I always index the first 3 entrys but im not sure how to change it because as i learned the DomainShader is called for every vertex so I'm not sure how to calculate the indices. Maybe someone knows the answer?

[CODE]
[domain("tri")]
DomainOut DS(PatchTess patchTess, float3 uv : SV_DomainLocation, const OutputPatch<HullOut, 12> tri)
{
DomainOut dout;

float3 p = uv.x*tri[0].PosL + uv.y*tri[1].PosL + uv.z*tri[2].PosL; // <-- heres the mistake i think
dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.Color = float4(uv.yx, 1-uv.x, 1);

return dout;
}
[/CODE]
0

Share this post


Link to post
Share on other sites
Hmm.. i tried to change it in the way that i just send 3 vertices at once
[CODE]
[domain("tri")]
DomainOut DS(PatchTess patchTess, float3 uv : SV_DomainLocation, const OutputPatch<HullOut, 3> tri)
{
DomainOut dout;
float3 p = uv.x * tri[0].PosL + uv.y * tri[1].PosL + uv.z * tri[2].PosL;
dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.Color = float4(uv.yx, 1-uv.x, 1);
return dout;
}
[/CODE]
and my output changed to:

[attachment=12738:tri.png]

That's kinda normal because I just pass 12 vertices and no index buffer so its just 12 / 3 triangles .. as in the picture..

Do i have to send each vertex-triangle combination through the shader stages ? as a replacement for the missing index buffer?

I have no idea and the problem is that there is nothing on the internet. Everything i find is just f***** tessellate just a single triangle or a quad but nothing more complex :(
0

Share this post


Link to post
Share on other sites
You can build the triangle list for the isocahedron, and use 3 control points. Each input primitive is a triangle and the initial vertices are the control points. Then tessellate each triangle, and project the tessellated vertices back on to the unit sphere. The more you tessellate the better the sphere approximation.
1

Share this post


Link to post
Share on other sites
thanks for the answer. I've already realized that my whole attempt was kinda stupid. I don't just want to "sub-tessellate" the sides of the icosahedron,in fact i want to tessellate the icosahedron into a sphere.


at least i now got it to draw the icosahedron subdivided.

[attachment=12740:q.png]

but now as u said i have to kinda "drag" the points on the outline of the spehre.. how do i approach the problem? is there a formula?

already thanks

regards Edited by ~Helgon
0

Share this post


Link to post
Share on other sites
Assuming your icosahedron is centered about some coordinate system, then in that coordinate system you can project the vertex onto the unit sphere by normalizing it. To get a point on a sphere with radius R, just scale the unit vector by R.
1

Share this post


Link to post
Share on other sites
Dude.. i just tried something like that but with the normal.. its already to late haha :)

i thank you so incredible much! thanks thanks!

just if someone else ever needs it:
[CODE]
[domain("tri")]
DomainOut DS(PatchTess patchTess, float3 uv : SV_DomainLocation, const OutputPatch<HullOut, 3> tri)
{
DomainOut dout;
float3 p = uv.x * tri[0].PosL + uv.y * tri[1].PosL + uv.z * tri[2].PosL;
p = normalize(p);
dout.PosH = mul(float4(p, 1.0f), gWorldViewProj);
dout.Color = float4(uv.yx, 1-uv.x, 1);
return dout;
}
[/CODE]

[attachment=12741:s.png]
0

Share this post


Link to post
Share on other sites
Regarding the limitation on the number of the control points; you can read from buffers and textures in every shader stage to access more memory. Though the limitation of 32 control points is per patch; you can have a huge amount of these patches per draw call.
1

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  
Followers 0