Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 20 Jul 2012
Offline Last Active Jul 01 2015 01:53 PM

Topics I've Started

Multiple Texture Parameter Penalty ?

10 June 2015 - 11:02 AM



Just wondered if there was a penaly for passing textures to my shader in four seperate textures or is it measurably faster to pass as a single (larger) texture ? I am miles away from exhausting my texture registers so have the "room" to take either approach.


I have buffered all my effectParameters, and am only updating my shader parameters when something has changed, and as I think I've read that "changing one value is roughly the same cost as changing multiple values, so if you do need to change a value, do them all". On that basis I am leaning toward keeping my textures in seperate Texture2D and avoiding the slight complexity of making a texture atlas with associated margin mipmap problems.


Please be aware I'm still stuck in Dx9 XNA4 territory, but I dont think that makes a difference from reading around the subject.





"Nested" Instanced Models

24 May 2015 - 03:40 PM

I am looking for a technique to render my Tree models in an efficient way. The model has 4-5000 vertexes but repeats these for a maximum of 20,000 vertexes using Model transforms (one for each tree limb). I think I would normally use hardware instancing to render these efficiently without lots of separate render calls. However I have many trees, and each of these is already hardware instanced (position, rotation). Using XNA4 I cannot combine hardware instances "to multiply them up" as it seems to support only one instance buffer per call.


I can repeat the model transforms into an array, and then repeat all that for the 30-40 visible trees, to form a large dynamic instance buffer but I wonder whether this is any more efficient than baking in the transforms into the model (even though the model would then be 20,000 vertexes in size).


With a hardware instance approach to rendering complex meshes, is it better to bake-in the model transforms and use the only available hardware instance stream to repeat the whole mesh, or is it better to using the hardware instance stream to render the one mesh efficiently, and the do repeated render calls for each of the visible trees ? (I am using Imposters to view large numbers of trees but want to push out the transition distance to prevent popping, which is why I am considering rendering more tree meshes than I've done before).


Any advice greatly appreciated.





Imposter Transitioning to Mesh

23 May 2015 - 06:59 AM

I have a hobby grade landscape engine which I continue to tinker with but I'm having a problem making the transition of my tree imposters to 3D mesh work acceptably. My tree meshes are 4-5000 vertexes and I have a sprite sheet of 64 2D images of the tree, each rotated around the vertical axis. The sprite sheet is 2048x2048. For imposter (billboard) rendering I use hardware instancing and calculate the correct sprite sheet offsets in the shader.


This allows me to render many trees in an acceptable performance, and then render my 3D meshes when the viewer is within a specific distance. However I get a real problem in transitioning between the imposter and the mesh - its a clear jump, and the difference between the rotation of the 3D mesh and the "coarser" rotation of the 64 samples is also very visible.


My question is what technique is used to

1) Align the mesh against the possible 64 pre-sampled rotations that I have billboards for to prevent the two being out of line when I transition.

2) transition from imposter to 3D such that I don't get a jump.


My tree meshes are converted from Collada files obtained through Sketchup - I don't have an artistic bone in my body and as its a hobby I don't have the money to spend on a professional vegetation mesh pack. The quality of the meshes isn't that relevant though, as its the transition that I'm concerned with and not the overall quality of the scene.


Any suggestions gladly taken; I did search around for "Imposter Transitions" but didn't find anything helpful.



Heightmap Tiling - Aligning with multiple geometry fragments.

03 July 2014 - 06:43 AM



I've got a successul implementation of a terrain (using something similar to Geo Clip Mapping) but am slightly stuck when it comes to assigning the heightmap textures to a particular tile or clipmap region.


The GPU Gems papers on this aren't specific about how you render a "chopped up" heightmap onto the geometry - I have broken down my heightmap texture into lots of smaller tiles (256x256) with teach tile contributing to a coarser level tile, something like how a mip map works. When I come to render my geometry I can calculate how many tiles, and of what scale, I need to pass to the shader (along with the appropriate matrix to provide the UV coordinate mapping from the geometry to the heightmap).


My problem comes with the count of heightmap textures I would need to pass in - I'm using XNA4 so have a limited number of texture slots, and besides, using a lot of textures just for my heights seems a waste. I've tried making my geometry chunk boundaries (which dont have any T-junctions) align with the texture sizes (i.e. one texture of one specific size per geometry chunk) but I get sampling discontinuities along the borders between the geometry chunks - but this isnt my main area of ignorance ( I am thinking that to get accurate heightmap tesselation the heigthmap for any geometry chunk must cover more than that geometries footprint (i.e. the texture is slightly bigger than the surface area in world terms) to prevent edge-sampling artefacts )


I am missing something here - given that my geometry is static with respect to the camera, and just has its position translated to be camera centric, aligning my heighmap texture chunks with a  nominal geometry grid still will require me to pass in multiple heightmap texture chunks to a single geometry pass - this isn't what the examples indicate I should be doing. If this were the case I'd be seeing examples with dynamic texture creation to create geometry aligned heightmap textures, or some examples passing multiple heightmap textures to the shader (a maximum of four would be required to cover a single geometry pass - assuming the geometry aligns with none of the heightmap world locations exactly).


Can anyone give me a clue as to how to properly align my heightmap texture chunks with the geometry pass - do I need to dynamically create a single texture out of those which overlap my geometry (every pass :-( ) or is there some better way of doing this.





World Space point in Bounding Box, in Shader

30 March 2014 - 10:18 AM



Can someone help unjam my coders-block please ? I have a point in world space in my Pixel Shader and want to check if it lies within a bounding box (or conceptually any bounding mesh). Whats the quickest way of doing this check ? In 2D C# I'm used to taking an arbitrary line from a point and counting the number of times it crosses a line that makes up a containing polygon - it seems to me there must be an analogy for this in 3D that counts how many times my projected line crosses a plane making up the containing polygon (an odd count means I'm "inside", but an even count means I'm outside, as does a zero count). I'm doing this check for a lot of pixels so it can't be an expensive call.


I have searched around the phrases ("point in bounding box","point in mesh") and it does give me a lot of collision based solutions, but I'm already inside a shader so they dont seem appropriate. It seems like something I should just "get" but I can't seem to visualise it.


Thanks in advance,




PS Just in case I'm going at this completely the wrong way, the problem occurs where I'm trying to "layer" a landscape feature over a previously rendered landscape mesh. I'm using a bounding cube that intersects the landscape, and back-calculating the world position of each pixel that is rendered on the surface of the cube, using the inverse projection matrix and the depth buffer to construct the world space of the pixel. Once I have the world space pixel, I want to check to see if it fell within the bounding volume - in which case I should render my texure (river, road, field etc) otherwise the viewer should see the previously rendered landscape.