• 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
Florian22222

Tiling a heightmap

19 posts in this topic

Hi!
I am currently writing a heightfield class for my engine. I want to use tiles for different heights.
How can i do this? Should i sort the indexbuffer by height of the triangles and call render once for every tile?
Or is there a better way to handle this with a vertex shader?

Thank you in advance!
0

Share this post


Link to post
Share on other sites
If you use a depth buffer and opaque rendering, there's generally no need to sort your primitives by height/depth/etc... , AFAIK it's better to [u]limitate communications between CPU and GPU[/u] because of the limited bandwidth between them. The computational power of nowadays GPUs is awesome, it's better to have a more complex pipeline rather than to communicate too frequently between CPU and GPU. A draw call for each tile [i]must be avoided .[/i] You can group your primitives according to their vertex layouts and techniques and draw each group in a single draw call (at least far fewer draw calls). Nowadays,the less you have draw calls and shader constant updating, the more you can access to high performances. For example, that's why there is [i]instancing [/i](you give geometry and information about each instance to the GPU so that it can draw all geometry instances at once, so : limiting draw calls) and [i]constant buffers[/i] (a single update for a whole set of parameters, so : limiting constant updates).

I hope that can help you
Nico [img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img]
0

Share this post


Link to post
Share on other sites
My idea was to sort the primitives at the start of the program and make a draw call for each texture. Would this be efficient, if i have about 4-5 textures?
0

Share this post


Link to post
Share on other sites
Hello IceBreaker !

[quote name='IceBreaker23' timestamp='1325500351' post='4898903']
My idea was to sort the primitives at the start of the program and make a draw call for each texture. Would this be efficient, if i have about 4-5 textures?
[/quote]

My question is : Why do you need to sort your primitives ?
If your tiles are fully opaque (even alpha testing or alpha to coverage) , and you use a depth buffer, you will get perfect overlapping results even if the tiles are not sorted.
(Sorting them would [i]partially[/i] avoid to invoke the pixel shader for pixels that would be covered later in the rendering phase, but it would need extra CPU work.) Generally it's better to let the GPU eliminate the covered pixels thanks to the depth buffer rather than to sort your primitives. What's more, the depth buffer permits to display perfectly primitive intersections and "A over B, B over C, C over A" case, because it works at the pixel level.

Getting informations on the depth buffer could help I suppose ? There must be an good explanation of this in the DX SDK documentation

Nico

EDIT : I honestly don't get why sorting them at the start of the program [i]only [/i]is enought, unless your point of view is static ?
0

Share this post


Link to post
Share on other sites
You may also use texture arrays to store your landscape textures (up to 512 per texture array) or a 3d texture could work too.

These texture storage methods allow you to draw your landscape tiles in what ever order you want regardless of the number of materials. Of course, every tile needs an index to the desired texture in texture array or a coordinate to the 3d texture.

Otherwise, it is a good practice to arrange your objects by the resources they use such as material.

Cheers!
1

Share this post


Link to post
Share on other sites
If in the 3d texture there is one 2d texture for y=0 and 1 for y=1 will directx interpolate between them?
0

Share this post


Link to post
Share on other sites
[quote name='IceBreaker23' timestamp='1325506259' post='4898920']
If in the 3d texture there is one 2d texture for y=0 and 1 for y=1 will directx interpolate between them?
[/quote]

Direct3D will interpolate a 3d-texture according to the filtering mode. if you wish to interpolate between textures, the 3d texture has a limitation that the textures can only be blend with the slice above or below, which may turn out to be a huge limitation.
Otherwise you may use alpha maps (texture splatting) to blend between materials.

Cheers!
1

Share this post


Link to post
Share on other sites
I´ve used a volume texture in .dds format now.
But directx isn´t interpolating between the different textures.
Which filter should i use for interpolating? I tried D3DX_FILTER_LINEAR or D3DX_FILTER_TRIANGLE.
On the attached screenshot you can see what i get.
0

Share this post


Link to post
Share on other sites
solved with
[CODE]
m_pd3dDevice->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_LINEAR);
m_pd3dDevice->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_LINEAR);
[/CODE]

I used mip maps:
[CODE]
m_pd3dDevice->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_LINEAR);
[/CODE]
[attachment=6589:terrain_mipmaps.png]
But the problem is that there aren´t created mip maps for every texture.
The mipmaps are an interpolation of all 4 textures and that looks like the attached screen.
0

Share this post


Link to post
Share on other sites
I think you should be able to create mip maps for a volume texture in the program you used to create the volume texture.
[left]D3DTEXF_LINEAR Should be correct filtering mode.[/left]

It seems that there may be device based limitations on the volume textures. Some devices may not support volume texture mip maps and all blending modes may not be implemented.

It starts to feel like bad idea to use a volume texture.

[left][color=#000000][size=2]Cheers![/size][/color][/left]
1

Share this post


Link to post
Share on other sites
I used Directx Texturing Tool. I can create mip maps but the lower i get in the mip map level the less mip maps are there.
For example:
I use 4 textures and 9 mip map levels:
first level: 4 maps
second level: 2 maps
third level and below: only 1 map. And this is the bug, but how can i improve this?
1

Share this post


Link to post
Share on other sites
[quote name='IceBreaker23' timestamp='1325519392' post='4898960']
And this is the bug, but how can i improve this?
[/quote]

Hi, actually I think that this is the expected behavior and one other point against using volume textures for terrain texturing.

I can see that you are using d3d9 level hardware and that you may not use texture arrays. The effect you show on your screen shots may be done easily with separated textures too and you may expand the technique to use texture splatting later for example.

Thank you for your efforts.

Best regards!
0

Share this post


Link to post
Share on other sites
Can´t this be done with volume textures? I only want to reduce the flicker of terrain parts far away from the camera when moving. Isn´t there any possibility to remove this?
Should i use geometry shader for this?(I dunno if shader model 3 supports this)

It just had been so easily with a volume texture. :(

Thank you and i hope you can help me!
0

Share this post


Link to post
Share on other sites
[quote]Should i use geometry shader for this?(I dunno if shader model 3 supports this)[/quote]
No and no.

You can use a mip mapped texture atlas but it's not easy to get right and you'll end up wasting some texture space. Also if you going to use displacement mapping, texture atlas will become really expensive. A multipass technique might be the best choice.
0

Share this post


Link to post
Share on other sites
So should i use a vertexshader to determine which 2 textures i should use and set it?
You said a multipass technique should be the best choice. Should i use one for interpolation between dirt&grass, one for interpolation between grass&stone, etc.
Please don´t throw in some names of techniques cause I am not familiar with them, and wikipedia alone doesn´t seem to help me with this.
I know what a multipass technique is, but I don´t know what should this technique do?

Thank you ;)
I hope you´ll explain it to me
0

Share this post


Link to post
Share on other sites
In a multi-pass technique you would render one texture per pass with additive blending and use an alpha-map or some other indication to define the alpha value of the pixel drawn. Research texture splatting (kauna already mentioned it), there are a lot of good resources about it.

Btw: You can do the same in a single pass by reading all terrain materials in the same pass. You'll potentially have more texture look-ups this way though.
1

Share this post


Link to post
Share on other sites
Using vertex and pixel shaders will give you more freedom about how to manage the blending between textures. I strongly suggest to use them.

Depending on your graphics hardware, you may perform pretty many texture look ups per pixel without loss of performance.For example, at this moment I do something like 14 texture lookups (2 alpha, 4 base texture, 4 detail texture, 4 normal) per pixel in my terrain shader and it doesn't slow down that much.

Simple splatting pixel shader (D3D11) goes something like this (the code won't work directly)

float4 Alpha = Alphatexture.Sample(sampler,Tex.xy); //Read 4 alpha values from a rgba texture

float4 Color1 = Texture1.Sample(sampler,Tex.xy); //read diffuse texture 1
float4 Color2 = Texture2.Sample(sampler,Tex.xy); //read diffuse texture 2
float4 Color3 = Texture3.Sample(sampler,Tex.xy); //read diffuse texture 3
float4 Color4 = Texture4.Sample(sampler,Tex.xy); //read diffuse texture 4

float4 FinalColor = lerp(Color1,Color2,Alpha.r);
FinalColor = lerp(FinalColor,Color3,Alpha.g);
FinalColor = lerp(FinalColor,Color4,Alpha.b);


This code blends 4 textures based on the values stored in the alpha texture. 1 alpha texture is enough for blending 5 texture maps actually.
There is a way to blend 8 textures with 1 RGBA-map, but that's a different story.

Good luck!
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