How does the compass masking works ?


(Svartberg.) #1

there is masking in the compass map where a square scissored out portion of the command map is masked by a spherical shader.
I was looking to mask icons in the compass against that same shader (so they won’t appear to clipfrom the sides on full zooms), but i encountered some problems :

  1. The only mentioning of such a mask method in the code was :
CG_DrawPic( sc_x, sc_y, sc_w, sc_h, cgs.media.commandCentreAutomapMaskShader );

...

if( cgs.ccLayers ) {
	trap_R_DrawStretchPic( sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[cgs.ccSelectedLayer] );
} else {
	trap_R_DrawStretchPic( sc_x, sc_y, sc_w, sc_h, s0, t0, s1, t1, cgs.media.commandCentreAutomapShader[0] );
}

The trap_R_DrawStretchPic is basically drawing a certain portion from the command map.
I tried removing the DrawPic of the MaskShader, but instead of displaying a square pic like i thought it would, it didn’t display anything - and trying to remove the DrawStretchPics displayed a black circle (the mask i presume)

  1. trying to add the CG_DrawPic() of the MaskShader and adding it before other shader DrawPic’s yielded nothing and didn’t work in any method possible (it simply displayed a black circle, (just to mention, the icons i tried masking where valid and i was able to tweak them))

  2. The MaskShader is registered in :

cgs.media.commandCentreAutomapMaskShader = trap_R_RegisterShaderNoMip( "levelshots/automap_mask" );

Opening the pak0.pk3 where the original ET media is stored yielded nothing, there is no automap_mask.tga “levelshots/”.

All help would be appreciated,
Thanks in advance


(Lanz) #2

Look in the file levelshots.shader for the actual shader “levelshots/automap_mask”.


(Svartberg.) #3

Thanks, that’s one thing. :eek2:

I still pretty much have no clue of how the masking is implemented. :eek3:


(Lanz) #4

Ok, this is just a guess because I haven’t really looked at that code, well I have been there but not bothered with that part of the code.

First off that shader file is everything, because that defines what is actually happening.

First it draws the compass mask using alphafunc ge128 which means that every pixel in the alphamap with a value of 128 or greater will be drawn leaving everything else out. Check the compass_mask.tga files alpa channel and you will find filled with circle. That’s the clipping area.

Next it draws the automap on top of that but in the same z-buffer using depthFunc equal in the shader. Wich means that it allow "other effects to be conditionally layered on top of just the opaque pixels by setting depthFunc to equal " quote from the shader manual.


(Svartberg.) #5

Yes, that’s what i came up with too (minus the big words :stuck_out_tongue: ), and that’s why i posted the problem here :
If it would really use a depthFunc on the shader, then trying to draw this mask shader before the other shader i want to mask should have worked, but it doesn’t.
Instead it draws this shader as a normal pic (and not as an alpha channel), and then the next shader on top of it.

Maybe it doesn’t work if the next image already has an alpha channel, and then it converts the maskshader to a normal rgb shader. (which would explain why nothing was displayed when i commented out the mask)

However this seems really odd for something that simple, as i remember easily doing that in opengl for example, clueless i am indeed. :???:


(bani) #6

keep in mind that while the map itself is masked, the icons are not.

you can see icons go outside the borders of the compass in etmain, something we fixed in etpro.


(Svartberg.) #7

Yeah and i have to say it was nicely done. :wink:

But for example for your icons, did you use the shader mask i just mentioned or did you use some kind of a walkaround, because as far as this shader mask goes, i didn’t find any way to use it on a shader which already has an alpha channel. :???:


(bani) #8

iirc we made all the map icons use depthfunc equal so they would obey the compass masking.

it does pose a problem for maps which use custom map icons though. since the engine doesnt let you programatically generate shaders on the fly :moo:


(Svartberg.) #9

Thanks for the help bani, that’s what i was looking for.

As for custom map graphics, i guess it’s the map makers responsibility to add the proper tags to the shader, maybe there’s a way to add a tag to customimage loads, but from my scouraging through q3 forums, it seems to be impossible without a vid restart.