"A Detail texture is a small, fine pattern which is faded in as you approach a surface, for example wood grain, imperfections in stone, or earthly details on a terrain. They are explicitly used with the Diffuse Detail shader. "
This is what I’d like to do.
I’ve gone through the entire HOWTO and created the material containing the main terrain texture, and a detail texture as a “diffuse detail” shader. I can apply my shader successfully to a polygon plane GameObject, and I see both the main terrain texture and the detail texture overlaying it.
But I can’t for the life of me figure out how to attach my ground material to my heightfield-generated terrain object (created with Terrain → Create Terrain, and then Import Heightmap - Raw…).
Surely there must be something I’m missing! Any help would be appreciated. Thanks in advance.
The terrain system uses its own shader; it’s not something you can just add another shader to and have it work, sorry. However, you can convert a heightmap to a regular mesh and apply your material to that.
Also you don’t need a detail shader as you basically can make the texture as detailed as you want, no need to fake with a detail texture on top of a low detail “base texture”
How would this work for extra-large terrain heightmaps? I’ve already got a texture that’s 2048x2048, which is 1:1 on my 2048x2048 terrain. It looks terrible. The detail is much needed.
I don’t think a texture file of 20480 x 20480 is practical, for example, and that would only give a 10:1 detail as compared with the heightfield.
In fact, I think I remember seeing something like a 4096x4096 maximum for texture files on import, which would mean such a texture is totally impossible.
Dreamora is refering to using a splat map and then tiling repeating terrain textures. You can set the tiling so that the texture looks correct when viewed up close.
Repeating textures would effectively preclude using any sort of terrain generation tool like L3DT, Terragen, etc., as those tools create a single texture that varies from end to end. The whole point of those tools is that they are NOT repetitive and uniform, but rather more natural looking.
The terrain shader actually has the function of detail textures built-in, sort of. At a given distance (whatever you set the base map distance to), the usual textures are replaced with a base color instead. This isn’t as good as a correctly-done detail texture/low-res base texture combo, but it’s the same general idea.
Understood. That is the difference between Terragen/L3DT and real time applications like Unity. There are methods / techniques that can be used, both for the tiled textures and splat map, that will make the tiling virtually invisible to the average viewer. A bump and specular map on the terrain would also help, but those aren’t currently available.
Thats actually a given thing.
You can’t get good visuals, no mather what you do, because you get a single texture stretched over a whole terrain, just that your texture is restricted to realistic sizes (2048x2048 as max normally if you want it to run on enough hardware at good performance), unlike the rendering targeted applications that generate them which don’t have any actual texture at all (they generate the pixel during rendertime from procedural data).
My guess is that you might not fully understand the concepts behind the splatmap blending yet. You paint with several textures onto the terrain which are blended at realtime, creating a large amount of variation, its not a single repeating texture. The same approach is used by any technology that allows you to generate game usable terrain data (L3DT for example which allows you to export the resulting splat maps).
And the texture you use to paint can be any size basically, giving you more detail at far lower repetition counts if you use larger “paint textures”
Detail texture by the way don’t help you to hide the “DX7 class” terrain texture details you will get from a single texture stretch approach. Thats why this approach was phased out when Shader Model 2 was widespread enough to do the combination in realtime without the single texture pixel desity limit (it still does pratically the same thing, just that it now has an unlimited pixel density instead of a fixed texel size of terrainsize/texturesize). Without that dynamic blending, it still looks like a large washed out clump of nothing, a detail texture will only try to hide that fact.
For a reference how your approach would look like, you can check out about any DX7 / DX8 / early DX9 game with terrains. Unity actually can give you a feel for it as well if you set the graphics emulation back to dx7 with a dynamically painted terrain. thats the kind of visual quality you will get
The main reason for importing a heightmap based terrain is for large terrains. But large terrains need two frames of reference: one for the “big picture” and one for the details. If detail textures can’t be applied to heightmap terrains then it cripples the main use for imported terrains.
L3DT is capable of creating tiles for the terrain texture, but I don’t think that’s possible to use either. It seems like the Unity terrain requires the texture to either come in all as one piece, or you have to hand-paint it. Or did I miss some other way to bring in terrain textures?
And follow the link to .Tom’s website. There’s a tutorial on how to use Terragen rendered textures for a Unity terrain. He also sells some scripts that facilitate the process that might interest you.
it should be a 8 bit per channel / 32 bit total png file (ARGB) as using 4 textures for the 4 channels would be a total performance overkill. each of these alpha maps containts the informations to blend 4 textures.
Should you have these textures and thus have 21+ textures spread over your terrain then I’m sorry to say but you will have to redo your terrain for realtime usages, which means at max 2 splat maps per terrain unless you want high end machines only (in which case it would be a max of 3-4 splat maps).
Each splat map means another pass for the terrain to render, already 2 will bog down anything below higher end GPU (8600GT / 9600GT are what you can see as must have then).
Thanks dreamora, I can create the 4-channel alpha maps as you suggest. However I still don’t know how to actually apply them to my terrain once I get them into Unity. Can you explain further?
Sorry to revive this thread, but the original question on how to combine larger textures with smaller detail textures on Unity terrain is still a relevant one.
Since a few years have passed since the original question, the terrain functions are now more documented and changing the shader used for the terrains is easy (just edit the built in shader and place it in the project). However, I can’t seem to access the code used to build the basemap texture that is used when further away? This doesn’t seem to be based on the same shader? Any hints on where to look?
To add to the discussion and to explain why I think this is relevant:
While splat mapping using smaller textures often yield good results, an even better approach is to use the large base texture map generated by 3rd party terrain software and combine it with smaller detail maps. I do want to retain the color of the larger non-repeating terrain texture as it looks much better from a bit further away, and use the smaller repeating textures for when up close.
It would be great if the Unity terrain shading would evolve to support this approach as well, perhaps allowing a setting for each texture dictating it’s blend mode (multiply, normal, etc.).
Again, many thanks in advance for any tips on how to access the code used to build the basemap texture!
Cheers,
Dan