Jump to content

  • Log In with Google      Sign In   
  • Create Account


Grid tessellation size limit


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 GeneralMeliante   Members   -  Reputation: 149

Like
0Likes
Like

Posted 16 October 2012 - 03:15 PM

Hi guys!

Well sorry for the weird topic title as i don't really get the concept i`m talking about as clearly as i should.

So, i started my project on top of the sample "DetailTessellation11" from DirectxSDK and one of my intentions was to make it create a cylindrical terrain with a size of 1440 x 1653. I can use the image but it doesn't look as detailed as it should be.
Then i found this variable:
[source lang="cpp"]DWORD g_dwGridTessellation[/source]
It is used in a few functions during the program but it's main use is for creating the grid ( in this case a square with the amount of vertex of the grid equal to g_dwGridTessellation*g_dwGridTessellation ).
What i did get is that it determines the amount of vertex of the grid it's creating.

The problem:
Since I need to plot a 1440 x 1653 (or bigger) grid I changed the value of the variable and found out that it can't go over 180 and through breakpoints i have found out that this functions causes an Access violation probably because i`m overflowing a pointer or type of variable.

[source lang="cpp"] // Allocate memory for buffer of indices in system memory WORD* pIndexBuffer = new WORD [nNumIndex]; WORD* pIndex = &pIndexBuffer[0]; // Fill index buffer for ( DWORD i=0; i < dwLength; ++i ) { for ( DWORD j=0; j < dwWidth; ++j ) { *pIndex++ = (WORD)( i * (dwWidth+1) + j ); *pIndex++ = (WORD)( i * (dwWidth+1) + j + 1 ); *pIndex++ = (WORD)( (i+1) * (dwWidth+1) + j ); *pIndex++ = (WORD)( (i+1) * (dwWidth+1) + j ); *pIndex++ = (WORD)( i * (dwWidth+1) + j + 1 ); *pIndex++ = (WORD)( (i+1) * (dwWidth+1) + j + 1 ); } }[/source]
Since this variable is inside a grid creation function it's name has changed to dwLength and dwWidth.

I did some researches and i thought that could be the change from DWORD ( unsigned long) to WORD ( unsigned short ) but couldn't change it in the program for some reason.

So basically am i correct about anything?
Is this a problem with this function or I simply cannot handle that many vertex?
What can i do here? If no possible to handle that should i just make the program create several grids and stick then together?

Thank you for you time!

Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 12345

Like
0Likes
Like

Posted 16 October 2012 - 11:38 PM

The upper limits are defined by:
D3D11_HS_MAXTESSFACTOR_UPPER_BOUND (for hull shaders)
D3D11_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR
D3D11_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR
D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR
D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR

All of these are defined as 64 except D3D11_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR, which is 63.
You should not exceed D3D11_TESSELLATOR_MAX_TESSELLATION_FACTOR.


[EDIT]
Never mind; I misunderstood the problem.
[/EDIT]


L. Spiro

Edited by L. Spiro, 17 October 2012 - 10:10 AM.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 Nik02   Crossbones+   -  Reputation: 2654

Like
1Likes
Like

Posted 17 October 2012 - 12:31 AM

1440*1653 (which equals 2380320) overflows the range of a WORD (typically 0...65535) by a great margin. Have you tried to use 32-bit indices, which would raise the range to 0...232-1? The indices would then be represented as DWORD as opposed to WORD.

That said - independent of the above issue - it may be wise to spatially partition the mesh anyway, if the shading is complex enough. You probably don't see all the geometry at once, at any given moment? There is a fine balance here, though, in that the partitioning itself can use more time than you save by doing it.

Edited by Nik02, 17 October 2012 - 12:33 AM.

Niko Suni


#4 GeneralMeliante   Members   -  Reputation: 149

Like
0Likes
Like

Posted 17 October 2012 - 08:18 AM

1440*1653 (which equals 2380320) overflows the range of a WORD (typically 0...65535) by a great margin. Have you tried to use 32-bit indices, which would raise the range to 0...232-1? The indices would then be represented as DWORD as opposed to WORD.

That said - independent of the above issue - it may be wise to spatially partition the mesh anyway, if the shading is complex enough. You probably don't see all the geometry at once, at any given moment? There is a fine balance here, though, in that the partitioning itself can use more time than you save by doing it.


Thank you very much!
I did change the index buffer to be 32-bit and the WORD to DWORD on the grid creation, now i can get values bigger then 180 but, as you said, it gets a lot slower ( i'm using a 500 x 500 just as tryouts ).
What would you recommend for a performance boost? creating partitions of the cylinder instead of trying to do it all? the thing is that i use a texture for heightmap i would have to cut it to keep the heights.

The main point of my program is to keep the heightmap as perfect as the texture required. That is why i'm trying to keep the grid with the same amount of vertex of the heightmap texture.

#5 Nik02   Crossbones+   -  Reputation: 2654

Like
0Likes
Like

Posted 17 October 2012 - 10:05 AM

If your target hardware supports shader model 5, you can use a combination of a pre-tessellated cylinder and hardware tessellation to arrive at the needed resolution.

In the CPU side, you could divide the width and height resolutions by 64, and on the GPU tessellate the coarser geometry by factors of 64 to get the effective target resolution.

BUT consider this: do you actually need that kind of actual geometry resolution, or would a bump-map + displacement approximation be enough for the visual effect? The latter is a very common approach.

Regarding spatial partitioning, you could divide the cylinder surface to 4 separate sectors (and the possible cylinder caps as two more), and render only those that are within the view volume and that are actually facing the view. If you use more complex visibility culling logic, there is a greater chance that the visibility determination and increased device call count takes more time than just rendering the whole dataset at once. If you have heavy shaders, you can justify for heavier visibility determination too.

Edited by Nik02, 17 October 2012 - 10:13 AM.

Niko Suni


#6 GeneralMeliante   Members   -  Reputation: 149

Like
0Likes
Like

Posted 31 October 2012 - 07:33 AM

Hi Nik02, well i did try to make but what happens now, after the modification to DWORD from WORD is that the tessellation bugs the visual creating little holes between triangles its very weird.
So i couldn't make the variation of using less cpu by dividing it size and tessellation gpu because of the problem above. the image below demonstrate the issue:
Using a 180 value for height and width with 8 tessellation only to see the bugged effect:

solid:
https://dl.dropbox.com/u/51198194/Trabalho/dividedby64solid.PNG
wireframe:
https://dl.dropbox.com/u/51198194/Trabalho/dividedby64wireframe.PNG

And for a 1653x1440 without tessellation it takes a lot of time to load and gets a really bad fps, shouldn't it get higher values when not looking to all the cylinder? how can i improve on this two subjects, load time and fps rate?

solid tube:
https://dl.dropbox.com/u/51198194/Trabalho/Tubesolid.PNG
wireframe:
https://dl.dropbox.com/u/51198194/Trabalho/TubeWireframe.PNG

Thanks, sorry for late response, thank you very much for your attention!

#7 Nik02   Crossbones+   -  Reputation: 2654

Like
0Likes
Like

Posted 01 November 2012 - 03:15 AM

If you use GPU tessellation here, are you absolutely sure that the edge tessellation factors (as computed by the hull shader's constant evaluation function) are consistent with regard to their actual position as related to their adjacent geometry? And that the tessellation algorithm (as specified by the corresponding attribute of the hull shader function) is one that produces consistent results (as in integer factors)?

Load time can be improved by using smaller vertex buffers.

Drawing performance is dependent on many other things as well. Each drawn primitive takes a certain amount of overhead (like vertex shaders and tessellator) regardless of whether or not they end up covering any pixels on the render target; in addition, each pixel (or fragment of pixel) drawn takes time, and the more complex logic is specified in the shaders to draw those, the longer it takes. There are also the matters of register pressure, resource waiting, bus bandwith...

Do profile your application with a GPU profiler (search for these) to gain understanding where your bottleneck is; after you've done this, it becomes possible to try to fix it.

Finally, FPS is a very poor measurement of relative performance. You should instead measure milliseconds per frame, it linearly corresponds to the time taken by all the ops for a given frame. FPS is a reciprocal of that.

Edited by Nik02, 01 November 2012 - 03:17 AM.

Niko Suni


#8 Nik02   Crossbones+   -  Reputation: 2654

Like
0Likes
Like

Posted 01 November 2012 - 03:34 AM

There is also a precision limit regarding the tessellator outputs.

Do you do excessive scaling in the domain shader? If you do, consider moving the scaling to vertex shader.

Niko Suni


#9 GeneralMeliante   Members   -  Reputation: 149

Like
0Likes
Like

Posted 05 November 2012 - 11:49 AM

Ok, keeping up with the idea of making less vertex and compensating it with tessellation there was the bug, but i managed to pin point the problem, it'`s something with the density based algorithm without it works perfectly, so by that i made the texture be something like a 72 x 83 and added a 20x tessellation and i get pretty good geometry except in regions of holes that the tessellation tries making more triangles based on the base text but a few parts of it are clipped after.
so look at the little spikes that appeared is there a way to make this better?

https://dl.dropbox.com/u/51198194/Trabalho/spikes.PNG




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS