Function glTexEnviv

  • A texture environment specifies how texture values are interpreted when a fragment is textured. When target is GL_TEXTURE_FILTER_CONTROL, pname must be GL_TEXTURE_LOD_BIAS. When target is GL_TEXTURE_ENV, pname can be GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR, GL_COMBINE_RGB, GL_COMBINE_ALPHA, GL_RGB_SCALE, GL_ALPHA_SCALE, GL_SRC0_RGB, GL_SRC1_RGB, GL_SRC2_RGB, GL_SRC0_ALPHA, GL_SRC1_ALPHA, or GL_SRC2_ALPHA.

    If pname is GL_TEXTURE_ENV_MODE, then params is (or points to) the symbolic name of a texture function. Six texture functions may be specified: GL_ADD, GL_MODULATE, GL_DECAL, GL_BLEND, GL_REPLACE, or GL_COMBINE.

    The following table shows the correspondence of filtered texture values ๐‘โ‚œ, ๐†โ‚œ, ๐โ‚œ, ๐€โ‚œ, ๐‹โ‚œ, ๐ˆโ‚œ to texture source components. ๐‚โ‚› and ๐€โ‚› are used by the texture functions described below.

    Texture Base Internal Format ๐‚โ‚› ๐€โ‚›
    GL_ALPHA (0, 0, 0) ๐€โ‚œ
    GL_LUMINANCE (๐‹โ‚œ, ๐‹โ‚œ, ๐‹โ‚œ) 1
    GL_LUMINANCE_ALPHA (๐‹โ‚œ, ๐‹โ‚œ, ๐‹โ‚œ) ๐€โ‚œ
    GL_INTENSITY (๐ˆโ‚œ, ๐ˆโ‚œ, ๐ˆโ‚œ) ๐ˆโ‚œ
    GL_RGB (๐‘โ‚œ, ๐†โ‚œ, ๐โ‚œ) 1
    GL_RGBA (๐‘โ‚œ, ๐†โ‚œ, ๐โ‚œ) ๐€โ‚œ

    A texture function acts on the fragment to be textured using the texture image value that applies to the fragment (see glTexParameter) and produces an RGBA color for that fragment. The following table shows how the RGBA color is produced for each of the first five texture functions that can be chosen. ๐‚ is a triple of color values (RGB) and ๐€ is the associated alpha value. RGBA values extracted from a texture image are in the range [0,1]. The subscript ๐ฉ refers to the color computed from the previous texture stage (or the incoming fragment if processing texture stage 0), the subscript ๐ฌ to the texture source color, the subscript ๐œ to the texture environment color, and the subscript ๐ฏ indicates a value produced by the texture function.

    Texture Base Internal Format Value GL_REPLACE Function GL_MODULATE Function GL_DECAL Function GL_BLEND Function GL_ADD Function
    GL_ALPHA Cแตฅ = Cโ‚š Cโ‚š undefined Cโ‚š Cโ‚š
    Aแตฅ = Aโ‚› Aโ‚šAโ‚› Aแตฅ = Aโ‚šAโ‚› Aโ‚šAโ‚›
    GL_LUMINANCE Cแตฅ = Cโ‚› Cโ‚šCโ‚› undefined Cโ‚š(1 โˆ’ Cโ‚›) + C๐‘Cโ‚› Cโ‚š + Cโ‚›
    (or 1) Aแตฅ = Aโ‚š Aโ‚š Aโ‚š Aโ‚š
    GL_LUMINANCE_ALPHA Cแตฅ = Cโ‚› Cโ‚šCโ‚› undefined Cโ‚š(1 โˆ’ Cโ‚›) + C๐‘Cโ‚› Cโ‚š + Cโ‚›
    (or 2) Aแตฅ = Aโ‚› Aโ‚šAโ‚› Aโ‚šAโ‚› Aโ‚šAโ‚›
    GL_INTENSITY Cแตฅ = Cโ‚› Cโ‚šCโ‚› undefined Cโ‚š(1 โˆ’ Cโ‚›) + C๐‘Cโ‚› Cโ‚š + Cโ‚›
    Aแตฅ = Aโ‚› Aโ‚šAโ‚› Aโ‚š(1 โˆ’ Aโ‚›) + A๐‘Aโ‚› Aโ‚š + Aโ‚›
    GL_RGB Cแตฅ = Cโ‚› Cโ‚šCโ‚› Cโ‚› Cโ‚š(1 โˆ’ Cโ‚›) + C๐‘Cโ‚› Cโ‚š + Cโ‚›
    (or 3) Aแตฅ = Aโ‚š Aโ‚š Aโ‚š Aโ‚š Aโ‚š
    GL_RGBA Cแตฅ = Cโ‚› Cโ‚šCโ‚› Cโ‚š(1 โˆ’ Aโ‚›) + Cโ‚›Aโ‚› Cโ‚š(1 โˆ’ Cโ‚›) + C๐‘Cโ‚› Cโ‚š + Cโ‚›
    (or 4) Aแตฅ = Aโ‚› Aโ‚šAโ‚› Aโ‚š Aโ‚šAโ‚› Aโ‚šAโ‚›

    If pname is GL_TEXTURE_ENV_MODE, and params is GL_COMBINE, the form of the texture function depends on the values of GL_COMBINE_RGB and GL_COMBINE_ALPHA.

    The following describes how the texture sources, as specified by GL_SRC0_RGB, GL_SRC1_RGB, GL_SRC2_RGB, GL_SRC0_ALPHA, GL_SRC1_ALPHA, and GL_SRC2_ALPHA, are combined to produce a final texture color. In the following tables, GL_SRC0_c is represented by Arg0, GL_SRC1_c is represented by Arg1, and GL_SRC2_c is represented by Arg2.

    GL_COMBINE_RGB accepts any of GL_REPLACE, GL_MODULATE, GL_ADD, GL_ADD_SIGNED, GL_INTERPOLATE, GL_SUBTRACT, GL_DOT3_RGB, or GL_DOT3_RGBA.

    GL_COMBINE_RGB Texture Function
    GL_REPLACE Arg0
    GL_MODULATE Arg0 ร— Arg1
    GL_ADD Arg0 + Arg1
    GL_ADD_SIGNED Arg0 + Arg1 โˆ’ 0.5
    GL_INTERPOLATE Arg0 ร— Arg2 + Arg1 ร— (1 โˆ’ Arg2)
    GL_SUBTRACT Arg0 โˆ’ Arg1
    GL_DOT3_RGB or GL_DOT3_RGBA 4 ร— (((Arg0แตฃ โˆ’ 0.5) ร— (Arg1แตฃ โˆ’ 0.5)) + ((Arg0๐‘” โˆ’ 0.5) ร— (Arg1๐‘” โˆ’ 0.5)) + ((Arg0๐‘ โˆ’ 0.5) ร— (Arg1๐‘ โˆ’ 0.5)))

    The scalar results for GL_DOT3_RGB and GL_DOT3_RGBA are placed into each of the 3 (RGB) or 4 (RGBA) components on output.

    Likewise, GL_COMBINE_ALPHA accepts any of GL_REPLACE, GL_MODULATE, GL_ADD, GL_ADD_SIGNED, GL_INTERPOLATE, or GL_SUBTRACT. The following table describes how alpha values are combined:

    GL_COMBINE_ALPHA Texture Function
    GL_REPLACE Arg0
    GL_MODULATE Arg0 ร— Arg1
    GL_ADD Arg0 + Arg1
    GL_ADD_SIGNED Arg0 + Arg1 โˆ’ 0.5
    GL_INTERPOLATE Arg0 ร— Arg2 + Arg1 ร— (1 โˆ’ Arg2)
    GL_SUBTRACT Arg0 โˆ’ Arg1

    In the following tables, the value Cโ‚› represents the color sampled from the currently bound texture, C๐‘ represents the constant texture-environment color, C๐‘“ represents the primary color of the incoming fragment, and Cโ‚š represents the color computed from the previous texture stage or C๐‘“ if processing texture stage 0. Likewise, Aโ‚›, A๐‘ A๐‘“ and Aโ‚š represent the respective alpha values.

    The following table describes the values assigned to Arg0, Arg1 and Arg2 based upon the RGB sources and operands:

    GL_SRCn_RGB GL_OPERANDn_RGB Argument Value
    GL_TEXTURE GL_SRC_COLOR Cโ‚›
    GL_ONE_MINUS_SRC_COLOR 1 โˆ’ Cโ‚›
    GL_SRC_ALPHA Aโ‚›
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚›
    GL_TEXTUREn GL_SRC_COLOR Cโ‚›
    GL_ONE_MINUS_SRC_COLOR 1 โˆ’ Cโ‚›
    GL_SRC_ALPHA Aโ‚›
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚›
    GL_CONSTANT GL_SRC_COLOR C๐‘
    GL_ONE_MINUS_SRC_COLOR 1 โˆ’ C๐‘
    GL_SRC_ALPHA A๐‘
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ A๐‘
    GL_PRIMARY_COLOR GL_SRC_COLOR C๐‘“
    GL_ONE_MINUS_SRC_COLOR 1 โˆ’ C๐‘“
    GL_SRC_ALPHA A๐‘“
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ A๐‘“
    GL_PREVIOUS GL_SRC_COLOR Cโ‚š
    GL_ONE_MINUS_SRC_COLOR 1 โˆ’ Cโ‚š
    GL_SRC_ALPHA Aโ‚š
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚š

    For GL_TEXTUREn sources, Cโ‚› and Aโ‚› represent the color and alpha, respectively, produced from texture stage ๐ง.

    The follow table describes the values assigned to Arg0, Arg1, and Arg2 based upon the alpha sources and operands:

    GL_SRCn_ALPHA GL_OPERANDn_ALPHA Argument Value
    GL_TEXTURE GL_SRC_ALPHA Aโ‚›
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚›
    GL_TEXTUREn GL_SRC_ALPHA Aโ‚›
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚›
    GL_CONSTANT GL_SRC_ALPHA A๐‘
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ A๐‘
    GL_PRIMARY_COLOR GL_SRC_ALPHA A๐‘“
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ A๐‘“
    GL_PREVIOUS GL_SRC_ALPHA Aโ‚š
    GL_ONE_MINUS_SRC_ALPHA 1 โˆ’ Aโ‚š

    The RGB and alpha results of the texture function are multipled by the values of GL_RGB_SCALE and GL_ALPHA_SCALE, respectively, and clamped to the range [0,1].

    If pname is GL_TEXTURE_ENV_COLOR, params is a pointer to an array that holds an RGBA color consisting of four values. Integer color components are interpreted linearly such that the most positive integer maps to 1.0, and the most negative integer maps to -1.0. The values are clamped to the range [0,1] when they are specified. C๐‘ takes these four values.

    If pname is GL_TEXTURE_LOD_BIAS, the value specified is added to the texture level-of-detail parameter, that selects which mipmap, or mipmaps depending upon the selected GL_TEXTURE_MIN_FILTER, will be sampled.

    GL_TEXTURE_ENV_MODE defaults to GL_MODULATE and GL_TEXTURE_ENV_COLOR defaults to (0, 0, 0, 0).

    If target is GL_POINT_SPRITE and pname is GL_COORD_REPLACE, the boolean value specified is used to either enable or disable point sprite texture coordinate replacement. The default value is GL_FALSE.

    Parameters

    • target: number

      Specifies a texture environment. May be either GL_TEXTURE_ENV, or GL_TEXTURE_FILTER_CONTROL.

    • pname: number

      Specifies the symbolic name of a texture environment parameter. Accepted values are GL_TEXTURE_ENV_MODE, GL_TEXTURE_ENV_COLOR, or GL_TEXTURE_LOD_BIAS.

    • params: number

      Specifies a pointer to a parameter array that contains either a single symbolic constant, single floating-point number, or an RGBA color.

    Returns void

    Summary

    set texture environment parameters

    See

    glTexEnv

Generated using TypeDoc