md2 texturing

Started by
28 comments, last by Endar 18 years, 5 months ago
When you scale an image, say 308x193, does it have to be to the closest power of 2, or do you scale both of them up to the next power of 2?

Edit:: So should the scaled size be 256x256 or 512x256?

Edit2:: Or does it not matter as long as you scale them both the same way?

[Edited by - Endar on November 7, 2005 12:36:42 AM]
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Advertisement
Quote:Original post by Endar
When you scale an image, say 308x193, does it have to be to the closest power of 2, or do you scale both of them up to the next power of 2?

Edit:: So should the scaled size be 256x256 or 512x256?

Edit2:: Or does it not matter as long as you scale them both the same way?


I think it doesn't matter.

Btw try to flip your texture horizontally or vertically and both. I had this problem also, untill I figured to set the UV coordinates correctly.
Okay, so, currently, I'm scaling them both up.

How do I flip the texture? Do I actually use a gl call, or is this something like just doing:
m_vertexList.u = 1 - ((float)stPtr.s / (float)width);m_vertexList.v = 1 - ((float)stPtr.t / (float)height);


Does this flip it both horizontally and vertically?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Quote:Original post by Endar
Okay, so, currently, I'm scaling them both up.

How do I flip the texture? Do I actually use a gl call, or is this something like just doing:
m_vertexList.u = 1 - ((float)stPtr.s / (float)width);m_vertexList.v = 1 - ((float)stPtr.t / (float)height);


Does this flip it both horizontally and vertically?


I think that works, yes. You can also try to flip it in an image-editing application.
I have this for my md2 loader

the ReadShort are s and t accordingly.

header.skinwidth and header.skinheight are dimention of the texture in pixels

//un compress them to temp array    kbo.u = (float)ReadShort(&file) / header.skinwidth;    kbo.v = (float)ReadShort(&file) / header.skinheight - 1;//and now I put them into ready to use form	for(i = 0; i < header.num_face; i++)	{		// A side		tbo[cnt].u = kbo[fbo.auv].u;		tbo[cnt++].v = kbo[fbo.auv].v;		// B side		tbo[cnt].u = kbo[fbo.buv].u;		tbo[cnt++].v = kbo[fbo.buv].v;		// C side		tbo[cnt].u = kbo[fbo.cuv].u;		tbo[cnt++].v = kbo[fbo.cuv].v;	}
Quote:Original post by DMINATOR
header.skinwidth and header.skinheight are dimention of the texture in pixels


The size after the texture has been scaled, or the size before the texture has been scaled?
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
it is size in pixels the texture has. If you scale texture proportionally then it doesn't matter.

-DMINATOR

The MD2 file has the texture coords in range 0-1 or 0 - texturesize ?

The texture coordinates don't have too much to do with the actual texture size in OpenGl (or DX). That is, I can use high detail textures or low resolution textures without touching the texture coordinates.

I can imagine that scaling the coords screw up the texturing.
Okay, well, I'm no longer scaling the actual coords that I'm using to calculate the coords from the shorts.

Here is what it currently looks like, and I've tried flipping the texture using the "1 - " at the beginning of the u and v calculations, tried both individually, at the same time, and none, and I'm always getting similar variations on what is in the picture.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Please post how are you filling vertex array and how are you rendering it.

-DMINATOR

This topic is closed to new replies.

Advertisement