Lots of Single Surface Questions

Blitz3D Forums/Blitz3D Beginners Area/Lots of Single Surface Questions

Nexus6(Posted 2012) [#1]
Hi Guys,

First off, apologies for the long list of questions, im still trying to get my head around all this single surface stuff.

1. is there a method to tile a texture on a single surface quad? I have a tile based road map and there are stretches of road without any intersections, i would like to make one long quad to reduce the poly count, but if I cant tile the texture, then I would need to create several textures, one for each possible road length.
2. I know this is a subjective question, but how many surfaces is too many, and whats a good ball park figure for surfaces v polys. At present my whole map 64x64 is one surface.
3. Is there a method to apply entityblend / textureblend to individual quads of the same surface.
4. If i reduce the camera range, my FPS increase even though the same number of polys are drawn. Why is that?
5. Is there a plugin for any of the popular 3D modellers that will export vertex data. Trying to model anything other than a square is a pain in the a$$ and so hard to visualise.
6. Can a mesh thats been created with the addvertex, addtriangle commands be lightmapped. I was hoping that when ive finished, i could have a look at YAL and see if i could implement it.
7. The Addvertex command docs mention a second U V set, how do i use this.

I did warn you that it was a long list :) but I have tried to find the answers before I posted here.

"I will be ignoring rude ppl" That kid makes me laugh so much.

Thanks Guys


Ross C(Posted 2012) [#2]
1. Yeah you can tile a texture. There are a few methods actually. If your single surface quads only has one texture, and it fills the entire texture (it's not a tilemap type layout), you simply adjust your UV co-ords to go from 0 at one corner to 3 or 4 or 5 or however many times you wish it to tile.

If you are putting multiple textures onto the one texture, you can stretch the road texture along the width of the texture, and will still be able to tile it, but only in one direction

2. You won't be able to fit much more than a 128 x 128 (if you are having a square, powers of two based size) When it comes to making things single surface, I tend to only use single surface for things that are static. Having lots of spheres in single surface, and moving them all about maybe more time consuming looping through every vertex to move them. It all depends on the hardware your running the code on too.

3. No, unfortunetly not. I have posted in the Blitz3d section of the forum, regarding blending individual surfaces of the same mesh together. It seems to work just like multiple textures on the one mesh (it may be the same behind the scenes anyway) You still have control of the vertex alpha though, so you can have each quad at a different transparency. You will run into z-ordering problems with the order the vertices/triangles are drawn though. Some may be drawn before others, even though they are closer to the screen.

4. I'm not sure. This maybe a graphics card optimisation? Maybe it's because nothing is actually being drawn, or maybe it's a texture related thing? Hopefully someone more knowledgable than I will come along and answer that one.

5. You could either, manually read file and load the vertex data this way via the .b3d format, or load the mesh in, then loop through the mesh and read all the vertex co-ords and UV's.

6. There's no reason why it can't. I believe it will use the secondary UV set, so best to keep that free. On a side note, I could never get YAL to work properly. I'm guessing it's an operator error though, as I found it very complex.

7. VertexTexCoords() has an optional flag you can set to add the secondary UV co-ords. You may need to use the TextureCoords() command to set the texture to gets it's UV co-ords from the 1st or 2nd set.

Hopefully some of that helps. I'm doing my own single surface stuff just now with a tilemap, so you caught me at the right time!

Last edited 2012

Last edited 2012


Yasha(Posted 2012) [#3]
Hum, ninja'd. Oh well...


1. Yes, if you scale the texture down. This however will affect all uses of the texture in question, so probably won't be easily applied to your case. You can probably afford to spend the polys to just add more quads to the road.

2. More than about 25 surfaces onscreen at once is too many? (Old information, I haven't pressed this in some time) Your surfaces should be broken up so that they are on screen or not. A surface out of the field of view of the camera won't be drawn at all, and therefore cost nothing; but lots of surfaces in view mean more uploads. So the balance you're trying to find is to keep the number of surfaces in view low, but to also try to make sure all or most of the polys for a surface are actually being drawn, not wasted offscreen.

3. No.

4. Other things than drawing. Your system may be testing against fewer objects (that still needed to be tested even though they ended up not being drawn); or perhaps the better precision for the things that are being shown makes it easier to draw them.

5. Eh? B3D can load standard model formats, you know. Importers for other popular ones in the code archives.

6. Yes. Lightmapping is just a particular use for texturing. You need to know how to use and blend multiple texture layers, and the second set of UV coords, but otherwise it's nothing special.

7. ...oh, right. Well, each vertex can have two sets of UVs. Which one is used to draw a texture is controlled by the texture, not the surface, using the TextureCoords command (so you will generally want to set this to 1 for lightmaps, to use the lightmap coord set; but feel free to use either however you please).

8. Yes, hilarious.


Nexus6(Posted 2012) [#4]
Thanks Ross/Yasha, that really helped me out. The only thing I didn't understand was Ross's explanation to Q1.

I have a texture with multiple textures on it, the road texture is in the top left corner and is currently textured like this -

v0 = AddVertex(surface,0+x,0+y,0,0,.5)
v1 = AddVertex(surface,1+x,0+y,0,0,0)
v2 = AddVertex(surface,0+x,-1+y,0,.5,.5)
v3 = AddVertex(surface,1+x,-1+y,0,.5,0)

AddTriangle surface,v0,v1,v2
AddTriangle surface,v2,v1,v3

0,0 at one corner to .5,.5 at the other corner. if i increase the .5,.5 to 1,1 or greater, then it will simply place the whole texture onto the quad, and display part of the texture i dont want mapped.

Thanks again.


Adam Novagen(Posted 2012) [#5]
More than about 25 surfaces onscreen at once is too many? (Old information, I haven't pressed this in some time)
I would contend this depending on the number of polygons per surface. Currently I have no trouble whatsoever with a few hundred surfaces, but each one is only a simple four-vertex quad.


Yasha(Posted 2012) [#6]
I have a texture with multiple textures on it


Then the answer to question 1 becomes a simple "no"; you'll need to add more polygons.

Moving the UVs and scaling the texture do essentially the same thing (the UV coords are multiplied by the texture's transform matrix before drawing). If you have multiple images on one texture object, then doing either will put those other images into the area requested for drawing on your mesh. Subimages on a texture are purely a conceptual thing, and the system can't distinguish between them.