texture splatting question

Started by
13 comments, last by Raloth 20 years, 8 months ago
Hmm that''s not the way I interpreted it. I have a chunk of 32x32 tiles, which should be 32x32x4 vertices. The reason is texcoord0 is your terrain texture and is on a 0,1 basis, while texcoord1 is on a x/32 basis. The alpha stretches over the entire section but the tile textures are repeated every tile. Bleh, I don''t know how to explain it. Maybe someone should right an article about this .
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Advertisement
Here's my writepixel function
void WritePixel(D3DLOCKED_RECT rect, BYTE **ppData, int x, int y, D3DXCOLOR pixel){	int index = (y*rect.Pitch)+(x*4);	(*ppData)[index++] = (BYTE)(pixel.b*255);	(*ppData)[index++] = (BYTE)(pixel.g*255);	(*ppData)[index++] = (BYTE)(pixel.r*255);	(*ppData)[index++] = (BYTE)(pixel.a*255);}

My chunk is 33x33 vertices and my alpha map is 32x32. The alpha map SHOULD be stretched across the entire chunk since the values for each map is determined on a per chunk basis. ie there's a 32x32 map for a 33x33 vertices chunk. The tile textures have to be repeated in-order for the terrain to work. I'm not going to draw one tile at a time.. Instead, my index buffers are split up into triangle lists for each type of texture. SO i render the geometry for a texture, apply alpha map, move on to next texture. I don't render the geometry for every texture on the list, just the first one. Maybe I should re-write it to just simply do a triangle strip across the entire chunk since multiple textures are used, but I still don't see how one texture would want to be applied over an entire 33x33 chunk.

[edited by - Chaucer on August 13, 2003 12:28:30 AM]
Thanks!
Ah! I was doing it a different way . Your way seems much better - dramatically reduces the number of vertices you need. Forget what I said! Even better is your alpha map generation, which is the one thing I can''t quite get to work,other than a really weird index buffer problem which I can ignore for now. See my other post in the DirectX forum if you think you can help. Do you mind if I base my code off of yours? (the pitch thing kind of confuses me)
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Yeah that''s fine with me. Especially if you can help me figure out the hard edge problem

Well to make it simple, you can just think of the pitch as the width of the texture. However, the pitch is not equal to the width of the texture but the width of the memory the texture is using. Maybe that didn''t make sense.

The pitch is used to find the correct spot in memory since the memory usage of a texture is not necessarily equal to the width of the texture. Luckily, you don''t have to worry about calculating the pitch or anything, since it''s done for you. You just have to say rect.Pitch the way i''ve done it when you want to specify a pixel.
Thanks!
jesterlecodeur,
so what you''re telling me is that you stretch one texture across your entire chunk? Wouldn''t this give a very low detail of the texture?
Thanks!

This topic is closed to new replies.

Advertisement