Scott Richmond Posted September 7, 2011 Share Posted September 7, 2011 I'm currently working on a small isometric RPG concept and I'm having a bit of trouble working out how I'll do the terrain. What I'm working with is basically a 3D matrix database of cubes that make up the map. To draw the terrain I'm currently going to render out a big mesh from the data, which I've got sorted. But I'm unsure how I'm going to blend together the various terrain types. I've done some limited research and found a few nice articles: http://www.m4x0r.com/blog/2010/05/blending-terrain-textures/ How would I apply this to LE? Has anyone had any previous experience with this? Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
gamecreator Posted September 7, 2011 Share Posted September 7, 2011 I admit I haven't done this yet but have you already tried generating an alphamap, saving it, then loading it with LoadTerrainAlphamap? BlendTerrainTexture might be helpful too. Quote Link to comment Share on other sites More sharing options...
Scott Richmond Posted September 7, 2011 Author Share Posted September 7, 2011 Hrm. I'm not using the LE 'terrain' stuff - I don't use a heightmap. I generate a vertex mesh myself. Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
gamecreator Posted September 7, 2011 Share Posted September 7, 2011 Ah, I misunderstood. Maybe you could generate LE terrain instead but I have nothing other than that. Quote Link to comment Share on other sites More sharing options...
paramecij Posted September 7, 2011 Share Posted September 7, 2011 What kind of mesh are you generating? Quote Link to comment Share on other sites More sharing options...
Scott Richmond Posted September 7, 2011 Author Share Posted September 7, 2011 Just a polygonal mesh. I iterate over my terrain matrix, get the 'outside shell' and place all the vertex's I need and draw polys over them. It works really well, but I have as yet worked out how to texture such a mesh in LE. Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
paramecij Posted September 8, 2011 Share Posted September 8, 2011 I think the easiest way would be to make a texture atlas (big texture that contains smaller textures), and when you generate your mesh, just assign appropriate uv's to each quad (1quad = 1 cell from the texture atlas) .. let's say you make your big texture 2048x2048 and use 256x256 for ground texture tiles, this allows for 64 different textures, enough resolution for isometric view i think and enough room for you to make all the additional transition tiles you need.. and it's good for performance also Quote Link to comment Share on other sites More sharing options...
Scott Richmond Posted September 8, 2011 Author Share Posted September 8, 2011 Thanks for your input Paramecij. Are you suggesting I manually create transitions between all the different types of tiles? I do not like the sound of that at all. Surely there is a more modern approach - The article I linked in the original post sounds really nice. Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
paramecij Posted September 8, 2011 Share Posted September 8, 2011 Sure there's a more modern approach, I think Aily created and posted something on the forum you should check out.. what is best depends on what you want.. Maybe I'm way off here, but when you said small isometric rpg with map made from cubes, I was thinking maps looking along the lines of this (quick google search): and suggested to build a texture like this: (notice how the transition between sand and pebble is made (tile 14), you just draw a simple mask around a layer - which you can reuse on other types and have all transitions done in minutes) ..since you have a way of generating/placing cubes (an editor?), and you may already have some type or material or some other property you could set a tile ID to them, then when you generate your mesh it would be trivial to calculate uvs from the cubes ground type.. not much to implement really, and manual painting will took less time then debugging any other solution .. but the real benefit is that you would have your terrain rendered in one draw call using just one texture, with traditional terrain splatting method you'd have 5 types (..yeah you can do more but it's not as elegant) ..I can get more in depth with the method like in the article you linked to.. it would help if I could see how you imagined your levels to look like Quote Link to comment Share on other sites More sharing options...
Scott Richmond Posted September 8, 2011 Author Share Posted September 8, 2011 The map matrix is made up of tiles/blocks. So at its heart I suppose its minecraft, if you want a visual reference. However I'm running it through an algorithm that outputs the surface and smooths it. So the output is a polygonal volume. I then need to paint it. I just got a reply from Josh regarding this and he said the following: This feature is not supported. However, it's simply a matter of writing a shader that combines two textures based on vertex color. I've seen an example someone posted of this in action, but I don't remember where. You might look in the old forum if you can't find it here:http://www.leadwerks.com/forum/ Blending between an arbitrary number of textures is a much more difficult proposition; well not just difficult, but impossible, due to the limited number of texture units you have to use. As Josh mentions, surely this work has been done before? If not for LE specifically but in shaders in use elsewhere? Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
flachdrache Posted September 8, 2011 Share Posted September 8, 2011 You could write an "alphaRamp" shader which blends the textures based on the vertexcolor alpha value, which means 25% rockTexture, 50% sandTexture, 75% grass1Texture, 100% grass2Texture - while blending happens in between. You could do that based on terrain height too, by setting its vertex color in the range of Y using rgb - as above. Here is how i have done that in the pixelshader of my "ScarletFever" engine ... float4 pixel = tex2D(IN.mask, IN.baseCoord); float4 color0 = float4(0, 0, 0, 0); if(pixel.r) { float4 skinRock = tex2D(IN.texRock, IN.tCoord) * pixel.r; color0 += skinRock; } if(pixel.g) { float4 skinGrass = tex2D(IN.texGrass, IN.tCoord) * pixel.g; color0 += skinGrass; } if(pixel. { float4 skinSnow = tex2D(IN.texSnow, IN.tCoord) * pixel.b; color0 += skinSnow; } if(pixel.a) { float4 skinDirty = tex2D(IN.texDirty, IN.tCoord) * pixel.a; color0 += skinDirty; } OUT.col = color0; ... i have never done that but messing up the inRGB sampler with a perlin noise filter could add some additional variation. PS: the early version, in my XNA engine, was heavily based on these tutorials. hth Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
flachdrache Posted September 8, 2011 Share Posted September 8, 2011 However, So at its heart I suppose its minecraft, if you want a visual reference if you use indeed cubes i might would try to have pre defined sets of textured cubes and use a position(s) texture to arange the already textured cubes properly. Quote AMD 64 X2 Dual 5k - 4GB - XFX GForce9800GT - nv196.21 - WinXP Sp3 zBrush4R2 - Silo2Pro - Unwrap3DPro - Gile - MaPZone2.5 Xxploration FPS in progress ... Link to comment Share on other sites More sharing options...
paramecij Posted September 8, 2011 Share Posted September 8, 2011 As I said, It has been done before (search the forums), and even LE uses this method for it's terrain texturing.. but writing a shader is not that hard.. you can paint mesh vertices with colors to control blending, each channel of this vertex color being used as a 0-255 alpha value, or you can paint a texture with this information and map this whole texture onto your mesh via a second UV channel or by manualy calculating uvs (easy if you have a grid like mesh) .. you can use one texture as base that tiles over the whole mesh, then you can use RGBA channels to blend 4 additional textures on top of the base one - a total of 5 different terrain types.. since you can have a map with tunnels and such (i think), mapping a single texture onto the mesh may not be trivial so I suggest using vertex colors on your mesh.. arbitrary number of terrain types is not impossible, you don't really blend between more than 3 types (usually just 2) at one time.. so you could break the mesh up into multiple zones that uses different texture sets ... or you could again use texture atlases, using R and G channels to specify textue1 and texture2 IDs, B channel to control the blending, this way you could have arbitrary number of 'textures' (well one or two really, but you could use morre terrain types to blend with) Quote Link to comment Share on other sites More sharing options...
Scott Richmond Posted September 9, 2011 Author Share Posted September 9, 2011 How does Dave do it here on his barracks brick walls? Quote Programmer, Modeller Intel Core i7 930 @ 3.5GHz | GeForce 480 GTX | 6GB DDR3 RAM | Windows 7 Premium x64 Visual Studio 2008 | Photoshop CS3 | Maya 2009 Website: http://srichnet.info Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.