Sign in to follow this  
Android_s

Problems with texture units, multipassing and glMap

Recommended Posts

Hi. I have a problem "flickering" textures in my Quake3 .bsp viewer. I am normaly using Multitexturing and the texture units to apply lightmaps on faces, but when it come to the curved faces this is not possible. Instead I'm routing all textures, includeing lightmaps, to the 1'th texture unit and multipass. This works, but it seems that when i move around the textures/lightmap sometimes flicker between different textures. I thought i knew what the problem was, i've had similar problems when not deactivating textures in the units before, but i've stared myself blind at the code and corrected anything that looked wrong...and still this bug remain. I have 2 screenshots, one faulty, and one that is correct. Thanks for your time...

Share this post


Link to post
Share on other sites
could just be z-fighting...

As for multi-texturing with glMap, how about instead of drawing directly you instead save off the xyz and uv coords and use them in a standard glDrawRangeElements (or whatever) call and setup multi-texturing as normal?

Share this post


Link to post
Share on other sites
I don't think it's Z-fighting...doesn't look like that usually do...

Hmm, do you mean saving of the coords after you've run glMap? That's the best solution I suppose, but how do i do that? I've done search about that but i've not found any way of storing them...

Is there some really special way that Q3 draw it's surfaces? I wrote a surface-class that handles any dimension you put into it, tesselate..perhaps during loading, and then uses vertex-arrays to render the surface. However this don't work. I've read that Q3 uses bezier-patches and that multiple patches share border edges...but this wouldn't really matter..or would it...

Thanks for your reply _the_phantom_...if there is a way to store those evaluators(or whatever i can store to spit out the surface) i would be happy and all problems solved [grin]

Share this post


Link to post
Share on other sites
Aww [wink]
Well, IS there a way to store the points with glMap...i would guess there isn't...

One more thing, glMap don't seem to support grids that are above XxY, if X or Y is above or equal to 9...or is it the bezier patches in Q3?

Anyway, the original question is still unanswerd and if anyone might have a clue what might be wrong please don't hesitate to post... [smile]

Share this post


Link to post
Share on other sites
youre supplying the wrong texcoords for the lightmaps on the right arched part of the map, u should be using the lm texture coords instead youre using the standard diffuse texture coords.

every vertex has 2 texcoords for the
A/ lm textiure
B/ diffuse texture

Share this post


Link to post
Share on other sites
Quote:
Original post by zedzeek
youre supplying the wrong texcoords for the lightmaps on the right arched part of the map, u should be using the lm texture coords instead youre using the standard diffuse texture coords.

every vertex has 2 texcoords for the
A/ lm textiure
B/ diffuse texture


Are there two x/y values for the different textures!? [wow]
Ok, either i've missed something serious or I must have misunderstood you...

The struct BSPVertex looks like this:

struct tBSPVertex
{
float vertices[3];
float textureCoords[2];
float lightmapCoords[2];
float normal[3];
unsigned char color[4];
};

...which clearly states the textureCoords and lmCoords has only one x/y pair each...

Anyway, here is the glMap call i make, both for the vertices and the diffuse texCoords. Note that i have completly commented out the lightmapping part and, still <sighs>, the face changes textures....


UINT stride = sizeof(tBSPVertex) / sizeof(float);

// calc evaluators
glMap2f(GL_MAP2_VERTEX_3,
0.0f, 1.0f,
stride,
pFace->size[0],
0.0f, 1.0f,
stride * pFace->size[0],
pFace->size[1],
pVertices[pFace->startVertexIndex].vertices);
glEnable(GL_MAP2_VERTEX_3);

// set up texture
glMap2f(GL_MAP2_TEXTURE_COORD_2,
0.0, 1.0f,
stride,
pFace->size[0],
0.0, 1.0f,
stride * pFace->size[0],
pFace->size[1],
pVertices[pFace->startVertexIndex].textureCoords);
glEnable(GL_MAP2_TEXTURE_COORD_2);

// set up texturing
glActiveTextureARB(GL_TEXTURE0_ARB);
gStateManager->enableState(GL_TEXTURE_2D);
gStateManager->bindTexture(pFace->textureID);

glActiveTextureARB(GL_TEXTURE1_ARB);
gStateManager->bindTexture(NULL);
gStateManager->disableState(GL_TEXTURE_2D);

// make grid and draw surf
glMapGrid2f(curveLevel, 0.0f, 1.0f, curveLevel, 0.0f, 1.0f);
glEvalMesh2(GL_FILL, 0, curveLevel, 0, curveLevel);

glDisable(GL_MAP2_VERTEX_3);
glDisable(GL_MAP2_TEXTURE_COORD_2);



Share this post


Link to post
Share on other sites
>>Are there two x/y values for the different textures!?
Ok, either i've missed something serious or I must have misunderstood you...

The struct BSPVertex looks like this:

struct tBSPVertex
{
float vertices[3];
float textureCoords[2];
float lightmapCoords[2];
float normal[3];
unsigned char color[4];
};<<

no thats correct (theres only one vertex) , though from your picture it looks like for applying the lightmaps youre using the textureCoords[2] floats instead of the lightmapCoords[2] float.

note ive never really used glMap functions (i pretesselate quake3 myself + treat the arches etc as normal meshes)

Share this post


Link to post
Share on other sites
Quote:

no thats correct (theres only one vertex) , though from your picture it looks like for applying the lightmaps youre using the textureCoords[2] floats instead of the lightmapCoords[2] float.

Ahh, hehe, I was beginning to wonder... [grin]
No I use the texCoods for textures and the lmCoords for the lightmaps, so it must be something else...

Quote:

note ive never really used glMap functions (i pretesselate quake3 myself + treat the arches etc as normal meshes)

This is what I really want, but don't have the time right now. I have algorithms to tesselate but just recently i found out that my math was slightly off...
Hmm, perhaps you have any input to give me on the texCoord tesselation when use with this methode? I were thinking of using simple linear interpolation...
Not sure of how to go around the texturing problem with the indexes i use to render the tri-strips though...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this