Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Detailed texturing

Author
Message
Kryogenik
16
Years of Service
User Offline
Joined: 22nd Sep 2009
Location: Heidelberg, Germany
Posted: 18th May 2010 22:22
Terrain has been the been pretty easy for me to make. Just open up my model and drag points around and make terrain, then add stuff to it later, but texturing it is what I don't get. At first, I had each polygon of the terrain have the same texture, making it pretty detailed, but made the whole terrain the same, and eliminated the possibility of lightmapping if I find out how to do that. Right now, I'm making bigger terrains and making giant textures for them (2048*2048), and even the giant sized terrains aren't very detailed. I saw in blitzterrain that the textures were pretty detailed using a topdown texture and a detailed texture on each polygon that is affected by the topdown one. This makes detailed terrains without having giant textures, but blitz only uses heightmaps (right?) to make terrains, and I plan on combining terrains and indoor stuff, as well having caves and stuff. Is there a way to do a blitz type of thing without being limited to heightmaps? I mean in general, like for terrains, rooms, caves whatever. Or should I just make bigger textures? Thanks in advance

Codesurge is so awesome, thanks Hyrichter.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 18th May 2010 22:41
As far as I know height maps are pretty standard for terrains. However they are no good for caves. A cave would either be just a .x, or a height mapped floor(terrain) with a .x shell for the walls and roof. Proper height mapped terrains tend to look a lot better than most peoples models too, apart from very skilled modelers, or at least very patient modelers.
You can just use a model as the floor, but will have to sort out a new way to get the ground height.That way you would at least be able to texture it in detail.
As for going larger than 2048x2048 in texture size, I would advise against as most video cards will choke. Even at that res most onboard chips will struggle.

http://s6.bitefight.org/c.php?uid=103081
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 18th May 2010 23:14
I'm confused. Are you trying to get caves or more detailed texturing of a standard terrain without caves?

For detailed texturing in addition to a standard colour map for the whole terrain you'll need an extra set of UV coordinates (which can be the same as the stage 0 coordinates initially). Then you'll be able make progress. To add an extra set of UV coordinates you'll need to use the convert object fvf command to add an extra stage and the vertexdata commands to fill the new stage with appropriate values.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 19th May 2010 00:08
@Green Gandalf, I assumed he is using a .x object for a terrain rather than an actual height mapped DB or blitz terrain. At the end of his post he mentioned caves, and I was just making the point that terrains aren't good at anything other than basic hills and such.
Never heard of the convert object fvf command before, but it sounds like it is a shader command? Sounds very complicated to me

http://s6.bitefight.org/c.php?uid=103081
Jane Doe
19
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 19th May 2010 09:42 Edited at: 19th May 2010 09:56
Quote: "Never heard of the convert object fvf command before, but it sounds like it is a shader command? Sounds very complicated to me"


Not really.

Three dimensional models are made from triangles - "polys". The polys are made from vertices; the points that make up the corners of the triangles. The verts are comprised of data.

One piece of data the verts must have (as far as I know) is the location of the vertex. If you've added limbs to the model, the limb vertex positions will be in relation to the limb position; otherwise they'll be in relation to the object position.

Another piece of data that I can't imagine a vertex not having is/are the UV coordinates. The UV coordinates determine how a texture (image) is mapped onto a 3D object. For example, let's say you place a brick wall in your level but the bricks are too big. How do you make the bricks smaller? By adjusting the UV coordinates so that the texture is repeated more times in the same space, thus making the texture - and the bricks - smaller.

So how do you map two textures onto the same object differently? You add a second set of UV coordinates with different settings. The first thing you have to do is make sure you’re using the correct Flexible Vertex Format, or FVF. There are all kinds of things you can add to your vertex data and you can pick and choose what you want. Here are some examples:

Position (XYZ) 2
Normal 16
Diffuse 64
Specular 128
One set of UV coordinates 256
Two sets of UV coordinates 512
Three sets of UV coordinates 768
Four sets of UV coordinates 1024
Five sets of UV coordinates 1280
Six sets of UV coordinates 1536
Seven sets of UV coordinates 1792
Eight sets of UV coordinates 2048

You choose the data you want and add the numbers up. So, if you want position and two sets of UV coordinates, the FVF would be 514 - 2 for position plus 512 for two sets of UV coordinates. If you wanted to add a diffuse color to that, it’d be 578. To change the FVF of the 3D model, you use the CONVERT OBJECT FVF command.

Once you have the correct FVF, you can change the UV coordinates. One thing that I found confusing in the documentation is the use of the term “texture stage.” It seems to be used to mean both the different textures that are applied to a model and the UV coordinates. These are not the same thing. You can apply several textures to a model that has only one set of UV coordinates (if they don‘t need to be different) or you can have a different set of UV coordinates for each texture. There isn’t any reason I’m aware of for having more sets of UV coordinates than textures.

To change the UV coordinates, you lock the vertex data, change it, then unlock it. Nothing will explain this better than an example:





In the example, a plain is made and the FVF is changed to 514 (position with two sets of UV coordinates). The vertex data is then locked and the UV coordinates are set for both sets of UV coordinates (I‘m trying not to use the term “texture stage”). Setting the UV coordinates for the first set (0) wasn’t necessary, since that’s the default; but I thought it made the example more clear. Note that the numbering for both UV coordinate sets and texture layers begin with zero. The textures were then applied using the SET BLEND MAPPING ON command. If you were going to use a shader, you’d just use the TEXTURE OBJECT command then apply the shader.

You can’t really see it in the picture, but the sand texture is tiled five times across and five times down while the light map is only applied once.

Anticipating one question, there are six vertices in a DBPro plain object because the verts aren’t welded. See the diagram.

Hopefully, this will give you an idea of how to apply a detail texture to your terrain. If you have any questions, just post them here.

Good luck.

- Jane

Edit: You wouldn't have to apply the textures using the TEXTURE OBJECT command, if you're using a shader, if the textures are specified in the shader.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th May 2010 15:23
That's got to be one of the best answers I've ever seen on these boards. I have been trying to get my head around FVF and this helps a lot. Nice work Jane!

Kryogenik
16
Years of Service
User Offline
Joined: 22nd Sep 2009
Location: Heidelberg, Germany
Posted: 19th May 2010 18:24
@DVader I use Sparky's right now, so ground height isn't an issue. I didn't think about the high texture res slowing things down though, which makes sense.
@Green Gandalf I meant applying better texture detail, but mentioned I would use caves and stuff so people wouldn't just say blitzterrain and not tell me anything, you know what I mean?
@Jane Doe Wow, nice example. I didn't even know I would need convert object fvf, thanks for the info. I do have a couple questions though.
1. Does the vertex order matter when applying the u and v coords (it probably does). Would the texture come out differently if I changed the vertex numbers in the set vertexdata uv thing from ascending to descending, if that makes sense?
2. Does this only work for a single polygon at a time, or do you get the corner vertices and then the uv thing does the stuff inbetween?
3. This is a dumb question, but is there a command to pinpoint a vertex, or can you find it in the modeler?
4. Would this only work for squares, or do you just change the u2 and v2 in some way when working with rectangles or whatever? Or is my brain messed up
5. There are like 26 blend modes for set blend mapping on. Some of them are self explanatory, but some aren't. Like, what does D3DTOP_LERP mean?
My bad for all the questions, I'm a noob with vertex and uv commands and stuff. Anyway, thanks for the responses, guys.

Codesurge is so awesome, thanks Hyrichter.
Jane Doe
19
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 20th May 2010 10:18 Edited at: 20th May 2010 10:19
UV coordinates 0.0, 0.0 refer to the upper-left corner of the texture. 1.0, 1.0 refer to the lower-right corner. Each vertex has the coordinates of the image at that point. The rasterizer fills in the poly with pixels from the texture using these points as a reference. A value higher than 1.0 will cause the texture to repeat, or tile.

The diagram below shows how a four-tile eight-poly object might be textured with different UV coordinate schemes. The top example shows the texture being applied once, because the UV coordinate range is from 0.0 to 1.0. The second example shows the texture tiled, because the UV coordinates go above 1.0. The third example shows only a portion of the texture being applied, because the UV coordinates only go up to 0.4. The bottom example shows the texture flipped horizontally, because the U coordinates go from 1.0 to 0.0 from right to left.



Kryogenik,

1. It doesn't make any difference in what order the UV coordinates are set, as long as they're set correctly.

2. I think I explained that, above. If not, let me know.

3. The vertex numbers are assigned by the modeler, if you use one to make the object. There are UV-mapping applications where you can (re-)set the UV coordinates of an existing model.

4. It works with any 3D model on which a texture is applied. The UV coordinates determine how the texture is applied to the model. If the texture on the model is messed up and you confirm that the texture is all right, it's probably the UV coordinates that are the problem.

5. I’m sorry, but the blend-mapping modes are deep dark secrets known only to the immortals, like Green Gandalf. I have a some that I use and a few I avoid, but I’m going to have to leave a detailed explanation to someone with more technical knowledge. (Difficulty understanding the blend-mapping modes is a major impetus to using shaders, in my opinion.) I can tell you that LERPing is combining two textures based on a certain percentage.

A word of caution with regard to FVFs: Don’t include any vertex data that you don’t really want to have. Adding vertex data adds data to every vertex in the model and therefore swells the amount of memory the object takes up.

That’s all for tonight. I hope this helps.

- Jane

KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 20th May 2010 18:34
Wow. Good stuff Jane.

That should be in a newsletter article.

Jane Doe
19
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 21st May 2010 07:39
Thanks. But I'm afraid I was remiss in not mentioning the SCALE OBJECT TEXTURE command. It adjusts the UV coordinates for you automatically so as to increase or decrease the size and tiling of whatever textures are using that set of UV coordinates. Still, you can do a lot more with the vertex data commands than just adjust the UV coordinates and it's good to know how things work.

- Jane

Login to post a reply

Server time is: 2026-07-25 16:21:16
Your offset time is: 2026-07-25 16:21:16