Triangle strips and texturing

Started by
4 comments, last by EvilSwan 20 years, 8 months ago
I''ve been working on a 2d tile-base rpg for some time now. I''m using triangle strips to render my world. I know that I only need to draw two vertices at a time, but here''s my question with regards to texturing: I have many different tiles ( grass, sand, etc ), so when I go to texture a tile, I need to specify 4 different tex coords to get the tile I want. If I only use 2 vertices per loop, I couldn''t do the proper texturing because 2 vertices are shared between two different tiles and need to have separate tex coords for each tile. Now after some google and gamedev searching, I found that some (all?) people make their map texture one big texture and just procedurally go through and use the tex coords in orders (essentially pasting a large texture over some terrain ) Is this the way to do things or is there a better way yet? Sorry for the long-winded question, but I wanted to give you guys as much info as possible. Thanks a lot for your help too!
Advertisement
Use the texcoord method.
Ive came across the same problem (sort of)

I have been experimenting with heightmaps and I wanted to use one big texture and map it over the landscape but havent been able to figure out how to do this.

www.gametutorials.com has a tutorial that teaches you how to render a big texture over a heightmap (which uses triangle strips) but I havent had the time to sort through the atrocious source files and copy and paste... I mean uhh... implement it into my own design.

If I were you, I''d check it out.

Good luck!
"Yes it is I, the type of egotistical fool that would dare qoute himself." -Myself
Generally, the big stretched texture is used in 3d terrain engines. The way it works is at startup, you load a heightmap (a grayscale image where white is high and black is low) and create a texture based on the heightmap (iterate over each pixel on the heightmap, if its high, choose the color of the texture pixel based on a seperate rock texture; if its low, make the pixel the same color as in a grass texture, if its in between, blend the pixel between the rock and grass pixels) and then apply this generated texture to the terrain. I believe this is called ''procedural texturing''.

Now, since you are using a 2d tile-based engine, you probably only have something like 20x15 tiles on the screen at once, which isn''t a big deal to render one at a time (not using strips). Then you could sort your poly lists by texture and go through the textures, rendering the polys that have that texture all at once, then switching to the next texture (and rendering all the polys with THAT texture all at once, and so on.) Heck, if your tiles are square, you can strip each square (rendering 4 vertexes instead of 6).
"Procedural Texturing"

sounds kewl... I''ll have to google it and search for some tuts

Thanks


Now Im gonna quit stealing EvilSwans lime-light (sorry lol)
"Yes it is I, the type of egotistical fool that would dare qoute himself." -Myself
Thanks for the info. Currently I''m using triangle strips to do the drawing, but I''m binding individual textures for each tile ( I know that''s slow and stupid, but that''s why it''s called learning ) Anyways, I think I''m gonna try and do procedural texuturing, but in 2D. I know it''s probably overkill, but it''s a good way to learn and it will be easier for me to port to 3d when I''m ready to do that. I''ve been planning on making a python map editor, so this will make me do it to make nice textures. Thanks for all your help.

This topic is closed to new replies.

Advertisement