Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Texturfiltering & Mipmapping

[es] :: 3D programiranje :: Texturfiltering & Mipmapping

[ Pregleda: 1746 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

PlatFormancE

Član broj: 164022
Poruke: 1
*.11.15.vie.surfer.at.



Profil

icon Texturfiltering & Mipmapping10.06.2009. u 01:29 - pre 181 meseci
Da li neko zna kako se moze prelaziti izmedu razlicitih modova filteringa tekstura dok se vrti 3d, tj. dok igra radi. Jasno mi da kvaliteta tekstura zavisi od toga da li je ukljucen Nearest Neighbor/Bilinear ili npr. ako je MipMapping ukljucen da mogu mijenjati: Nearest Neighbor/Linear, ali mi nije jasno kako to napraviti dok igra radi. npr. pritiskom npr na f1. Sta ako level igre ima 50 tekstura ili vise, a isto tako veliki broj objekata, da li kad hocu promijenuti mod prikaza moram stopirati igru dok se level ne ucita ponovo sa teksturama promijenute kvalitete ili se moze unaprijed ucitati vise tekstura u neku listu i onda samo prebaciti na tu novu listu. uctavanje tekstura izgleda ovako:

[code ]
//ucitavanje iz 3ds fajla eksportovanog iz 3dmaxa
void Load3DS::CreateTextureRGBA(UINT textureArray[], LPSTR FileName, int textureID)
{
AUX_RGBImageRec *pImage_RGB = NULL;

if(!strFileName)
return;

pImage_RGB = auxDIBImageLoad(FileName);



unsigned char *pImage_RGBA = NULL;

if( pImage_RGB != NULL )
{
int imageSize_RGB = pImage_RGB->sizeX * pImage_RGB->sizeY * 3;
int imageSize_RGBA = pImage_RGB->sizeX * pImage_RGB->sizeY * 4;

// %%% Allocate buffer for a RGBA image
pImage_RGBA = new unsigned char[imageSize_RGBA];

int g_keyColor[3] = { 0, 0, 0 }; // Pure black is the color key to blend out
int i, j;

for( i = 0, j = 0; i < imageSize_RGB; i += 3, j += 4 )
{
// Does the current pixel match the selected color key?
if( pImage_RGB->data == g_keyColor[0]
pImage_RGB->data[i+1] == g_keyColor[1]
pImage_RGB->data[i+2] == g_keyColor[2] )
{
pImage_RGBA[j+3] = 0; // If so, set alpha to fully transparent.
}
else
{
pImage_RGBA[j+3] = 255; // If not, set alpha to fully opaque.
}

pImage_RGBA[j] = pImage_RGB->data;
pImage_RGBA[j+1] = pImage_RGB->data[i+1];
pImage_RGBA[j+2] = pImage_RGB->data[i+2];
}


glPixelStorei (GL_UNPACK_ALIGNMENT, 1);

glGenTextures( 1, &textureArray[textureID] );

glBindTexture( GL_TEXTURE_2D, textureArray[textureID] );


// %%% Here we are setting what textures to use and when. The MIN filter is which quality to show
// when the texture is near the view, and the MAG filter is which quality to show when
// the texture is far from the view.
//
// %%% The qualities are (in order from worst to best)
// GL_NEAREST
// GL_LINEAR
// GL_LINEAR_MIPMAP_NEAREST
// GL_LINEAR_MIPMAP_LINEAR
//
// %%% And if we go and use extensions, we can use Anisotropic filtering textures which are of an
// even better quality,

//OVO // %%% If MipMaping enabled switch GL_LINEAR_MIPMAP_NEAREST or GL_LINEAR_MIPMAP_LINEAR
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST);

//OVO // %%% If MipMaping disabled -> enable switch between GL_LINEAR and GL_NEAREST
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);

// %%% Here we are setting the parameter to repeat the texture instead of clamping the texture
// to the edge of our shape.
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
//OVO glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );

// %%% If MipMaping disabled -> enable glTexImage2
// %%% Here we are setting GL_RGBA for our new image data... we support Alpha transparency!
//OVO //glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, pImage_RGB->sizeX, pImage_RGB->sizeY, 0,
// GL_RGBA, GL_UNSIGNED_BYTE, pImage_RGBA );
//internal format - GL_DEPTH_COMPONENT - for rendering shadows

// %%% Generate the texture with mipmaps
gluBuild2DMipmaps( GL_TEXTURE_2D, 4, pImage_RGB->sizeX, pImage_RGB->sizeY, GL_RGBA, GL_UNSIGNED_BYTE, pImage_RGBA );
}

// %%% Free the texture
if( pImage_RGB )
{
if( pImage_RGB->data )
free( pImage_RGB->data );

free( pImage_RGB );
}

if( pImage_RGBA )
delete [] pImage_RGBA;
}

[/code]
 
Odgovor na temu

[es] :: 3D programiranje :: Texturfiltering & Mipmapping

[ Pregleda: 1746 | Odgovora: 0 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.