Jump to content

Masking an environment map ?


Recommended Posts

Could you elaborate some more about what your result is supposed to look like? Having an overlay is the simplest way of achieving this, but depending on how this is to be used (e.g. a grate?), depthFunc equal could work as well.

Link to comment

This is something I just recently learned myself and haven't tested, but read this:

 

AlphaFunc:

 

Determines the alpha test function used when rendering this map. Valid values are GT0, LT128, and GE128. These correspond to "GREATER THAN 0", "LESS THAN 128", and "GREATER THAN OR EQUAL TO 128". This function is used when determining if a pixel should be written to the framebuffer. For example, if GT0 is specified, the only the portions of the texture map with corresponding alpha values greater than zero will be written to the framebuffer. By default alpha testing is disabled.

 

 
Both alpha testing and normal alpha blending can be used to get textures that have see-through parts. The difference is that alphaFunc is an all-or-nothing test, while blending smoothly blends between opaque and translucent at pixel edges. Alpha test can also be used with depthwrite, allowing other effects to be conditionally layered on top of just the opaque pixels by setting depthFunc to equal.
 
 
So, in theory, this shader should work. Please anyone correct me if I'm wrong, it's untested.
 
textures/mapname/shadername
{
qer_editorimage textures/mapname/texturename
surfaceparm trans
{
map textures/mapname/alpha_mask
alphaFunc GE128
depthWrite
}
{
map textures/mapname/env
tcGen environment
depthFunc equal
}
{
map $lightmap
blendfunc filter
depthFunc equal
}
}
 
So, you need two images: your env map, and an alpha map (.tga with white objects in it, no transparent pixels)
Link to comment

okay will paly around with this
I want to achieve a glossy oil puddle decal for an efx file so I can scrap the lightmap I guess

EDIT: I got this , and it doesn'T look like it's working in ShaderED2...
 

gfx/newfx/puddle_decal
{
    surfaceparm    trans
    polygonOffset
    q3map_nolightmap
    {
        map gfx/newfx/puddle_mask
        alphaFunc GE128
        depthWrite
    }
    {
        map gfx/newfx/puddle
        blendFunc GL_ONE GL_ZERO
        depthFunc equal
        rgbGen lightingDiffuse
        tcMod scroll -0.05 0
    }
    {
        map gfx/newfx/puddle_env
        blendFunc GL_ONE GL_ONE
        depthFunc equal
        glow
        tcGen environment
    }
}


Link to comment

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
×
×
  • Create New...