ODD vertex when using autosprite2


(Wezelkrozum) #1

I’m wrestling for a month with this autosprite2 problem. Something it accidently work and sometimes I’m screwed. And now I’m screwed.

What I get is the error: shader had odd vertex autosprite2
I use the autosprite2 shadercommand and the brush (of 4 vertixes) works fine.
But the texture is screwed. It’s rotated around 30 degrees,
it bounches back at the end of the tris
and it repeats himself 3 or 4 times instead of 1 time.

(When somebody says SEARCH. I can’t search the word ODD because it’s to short)

does anyone has experience with this error?


(IndyJones) #2

i found similar thread on some solider of fortune 2 board. as far i remember the problem was with compiler. try using older/newer q3map2.

check if sprite looks okay with r_showtris.


(Wezelkrozum) #3

[QUOTE=IndyJones;193078]i found similar thread on some solider of fortune 2 board. as far i remember the problem was with compiler. try using older/newer q3map2.

check if sprite looks okay with r_showtris.[/QUOTE]

It doesn’t look ok. The squared brush in gtkradiant is changed in the game.


(IndyJones) #4

remove -meta switch and take a look.


(Wezelkrozum) #5

I didn’t compile it with “-meta switch”

This is what I see in the editor and in-game:

And this is the brush in the map-file:

// brush 8
{
( 8 8 -4 ) ( 40 8 -4 ) ( 40 0 -4 ) common/nodraw 0 0 0 0.500000 0.500000 0 13 0
( 8 0 -508 ) ( 8 8 -508 ) ( -24 8 -508 ) common/nodraw 0 0 0 0.500000 0.500000 0 13 0
( 8 0 -516 ) ( -24 0 -516 ) ( -24 0 -468 ) danceevent/light_wide_white -256 9 180 0.300000 0.500000 0 265 0  <-- this is the shader with the autosprite2 command
( -72 0 -476 ) ( -72 8 -476 ) ( -72 8 -428 ) common/nodraw 0 0 0 0.500000 0.500000 0 13 0
( -24 8 -516 ) ( 8 8 -516 ) ( 8 8 -468 ) common/nodraw 0 0 0 0.500000 0.500000 0 13 0
( 72 0 -4 ) ( 72 24 -4 ) ( 72 0 -516 ) common/nodraw 0 0 0 0.500000 0.500000 0 13 0
}

(IndyJones) #6

how did you compile then?
maybe do a workaround - make it as .ase model…


(Wezelkrozum) #7

[QUOTE=IndyJones;193088]how did you compile then?
maybe do a workaround - make it as .ase model…[/QUOTE]

I did compile it to ase model
and i did compile it to a md3model

But none of them worked

BTW I’ve found the full error:
Textures/dirpath/texturename had odd vertex count autosprite2 shader

Description:
You’re implementing a shader script that uses vertex deformations that are greater than the size of the brush you’re using it on.

So, the vertex deformation is greater than the brush? :confused:


(IndyJones) #8

… it’s not square. autosprite has to be a square brush! (32x32 etc, not 32x64).


(Wezelkrozum) #9

It doesn’t. I’ve made 30 lights with autosprite2 in it. And they all work fine. But when I change the size of the light (and no, they were not squared) it screws up.

And autosprite2 does rotate the texture around the longest ax. So It can’t be a squared brush because then it can’t chose an ax to rotate on.


(Wezelkrozum) #10

maybe you guys can uncode something like this to explain the error:

/*
=====================
Autosprite2Deform

Autosprite2 will pivot a rectangular quad along the center of its long axis
=====================
*/
int edgeVerts[6][2] = {
	{ 0, 1 },
	{ 0, 2 },
	{ 0, 3 },
	{ 1, 2 },
	{ 1, 3 },
	{ 2, 3 }
};

static void Autosprite2Deform( void ) {
	int		i, j, k;
	int		indexes;
	float	*xyz;
	vec3_t	forward;

	if ( tess.numVertexes & 3 ) {
		ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count", tess.shader->name );
	}
	if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) {
		ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count", tess.shader->name );
	}

	if ( backEnd.currentEntity != &tr.worldEntity ) {
		GlobalVectorToLocal( backEnd.viewParms.or.axis[0], forward );
	} else {
		VectorCopy( backEnd.viewParms.or.axis[0], forward );
	}

	// this is a lot of work for two triangles...
	// we could precalculate a lot of it is an issue, but it would mess up
	// the shader abstraction
	for ( i = 0, indexes = 0 ; i < tess.numVertexes ; i+=4, indexes+=6 ) {
		float	lengths[2];
		int		nums[2];
		vec3_t	mid[2];
		vec3_t	major, minor;
		float	*v1, *v2;

		// find the midpoint
		xyz = tess.xyz[i];

		// identify the two shortest edges
		nums[0] = nums[1] = 0;
		lengths[0] = lengths[1] = 999999;

		for ( j = 0 ; j < 6 ; j++ ) {
			float	l;
			vec3_t	temp;

			v1 = xyz + 4 * edgeVerts[j][0];
			v2 = xyz + 4 * edgeVerts[j][1];

			VectorSubtract( v1, v2, temp );
			
			l = DotProduct( temp, temp );
			if ( l < lengths[0] ) {
				nums[1] = nums[0];
				lengths[1] = lengths[0];
				nums[0] = j;
				lengths[0] = l;
			} else if ( l < lengths[1] ) {
				nums[1] = j;
				lengths[1] = l;
			}
		}

		for ( j = 0 ; j < 2 ; j++ ) {
			v1 = xyz + 4 * edgeVerts[nums[j]][0];
			v2 = xyz + 4 * edgeVerts[nums[j]][1];

			mid[j][0] = 0.5f * (v1[0] + v2[0]);
			mid[j][1] = 0.5f * (v1[1] + v2[1]);
			mid[j][2] = 0.5f * (v1[2] + v2[2]);
		}

		// find the vector of the major axis
		VectorSubtract( mid[1], mid[0], major );

		// cross this with the view direction to get minor axis
		CrossProduct( major, forward, minor );
		VectorNormalize( minor );
		
		// re-project the points
		for ( j = 0 ; j < 2 ; j++ ) {
			float	l;

			v1 = xyz + 4 * edgeVerts[nums[j]][0];
			v2 = xyz + 4 * edgeVerts[nums[j]][1];

			l = 0.5 * sqrt( lengths[j] );
			
			// we need to see which direction this edge
			// is used to determine direction of projection
			for ( k = 0 ; k < 5 ; k++ ) {
				if ( tess.indexes[ indexes + k ] == i + edgeVerts[nums[j]][0]
					&& tess.indexes[ indexes + k + 1 ] == i + edgeVerts[nums[j]][1] ) {
					break;
				}
			}

			if ( k == 5 ) {
				VectorMA( mid[j], l, minor, v1 );
				VectorMA( mid[j], -l, minor, v2 );
			} else {
				VectorMA( mid[j], -l, minor, v1 );
				VectorMA( mid[j], l, minor, v2 );
			}
		}
	}
}

It’s from the tr_shade_calc.c file


(Wezelkrozum) #11

Maybe a combination of shadercommands caused the problem?
So here is the shaderfile:

textures/danceevent/light_wide_white
{
	qer_editorimage textures/danceevent/light_wide_white.tga
	qer_trans 0.5
	surfaceparm trans
	surfaceparm nonsolid
	surfaceparm nomarks
	surfaceparm nolightmap 
	nopicmip
	nomipmaps
	cull none
	deformVertexes autosprite2	


	{
		map textures/danceevent/light_wide_white.tga
		blendFunc GL_ONE GL_ONE
		tcMod scale .5 .25
	}
}

Some more knowledge:
Cull none caused the 2 triangles. But without cull none it is just one triangle in stead of a square.

Maybe some coder of Splashdamage does know whats going on here?


(S14Y3R) #12

I tried your shader and it works fine here. It looked like your editor example with showtris on. autosprite2 doesn’t like square brushes, that’s for sure. Have tried compiling with a different q3map2 version?


(Wezelkrozum) #13

I found out that the map to md3 compiler (ET Model Tool 2.5.0) does cause this error. It’s when I compile it to a model. Are there some other map to md3 compilers you guys know?


(IndyJones) #14

i can make a md3 for you, if you export your brush as obj (gtk 1.5).


(Wezelkrozum) #15

If you make it this way it’s useless: http://www.splashdamage.com/forums/showthread.php?t=8907&page=2
Because they say you must make a md3 to avoid autosprite errors, but I still get them.

But you can try it. I’ll send you a downloadlink via pm.


(IndyJones) #16

no, i was going to use milkshape.

btw i used ase model on italy with autosprite texture (not autosprite2). worked fine. maybe you are above the limit now… ?


(Wezelkrozum) #17

Your model didn’t work. The texture repeats more times, the nodraw shader changed in the black/orange texture and autosprite2 is screwed again.


(IndyJones) #18

try this ase (the file size is ca 10 kb smaller than yours)
http://strony.it-net.pl/~pliki/temp/temp.rar


(Wezelkrozum) #19

[QUOTE=IndyJones;193114]try this ase (the file size is ca 10 kb smaller than yours)
http://strony.it-net.pl/~pliki/temp/temp.rar[/QUOTE]

I don’t know what you did. But now it’s flipping like hell:mad:. It’s even more screwed.


(IndyJones) #20

nothing… just recompiled the .map and converted to .ase :smiley: