<!DOCTYPE refentry [ <!ENTITY % mathent SYSTEM "math.ent"> %mathent; ]>

<!-- Converted by db4-upgrade version 1.1 -->

<refentry xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="texture">
    <info>
        <copyright>
            <year>2011-2015</year>
            <holder>Khronos Group</holder>
        </copyright>
    </info>
    <refmeta>
        <refentrytitle>texture</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>texture</refname>
        <refpurpose>retrieves texels from a texture</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Declaration</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>gvec4 <function>texture</function></funcdef>
                <paramdef>gsampler2D <parameter>sampler</parameter></paramdef>
                <paramdef>vec2 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>gvec4 <function>texture</function></funcdef>
                <paramdef>gsampler3D <parameter>sampler</parameter></paramdef>
                <paramdef>vec3 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>gvec4 <function>texture</function></funcdef>
                <paramdef>gsamplerCube <parameter>sampler</parameter></paramdef>
                <paramdef>vec3 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>float <function>texture</function></funcdef>
                <paramdef>sampler2DShadow <parameter>sampler</parameter></paramdef>
                <paramdef>vec3 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>float <function>texture</function></funcdef>
                <paramdef>samplerCubeShadow <parameter>sampler</parameter></paramdef>
                <paramdef>vec4 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>gvec4 <function>texture</function></funcdef>
                <paramdef>gsampler2DArray <parameter>sampler</parameter></paramdef>
                <paramdef>vec3 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>float <function>texture</function></funcdef>
                <paramdef>sampler2DArrayShadow <parameter>sampler</parameter></paramdef>
                <paramdef>vec4 <parameter>P</parameter></paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>gvec4 <function>texture</function></funcdef>
                <paramdef>gsamplerCubeArray <parameter>sampler</parameter></paramdef>
                <paramdef>vec4 <parameter>P</parameter></paramdef>
                <paramdef>[float <parameter>bias</parameter>]</paramdef>
            </funcprototype>
            <funcprototype>
                <funcdef>float <function>texture</function></funcdef>
                <paramdef>samplerCubeArrayShadow <parameter>sampler</parameter></paramdef>
                <paramdef>vec4 <parameter>P</parameter></paramdef>
                <paramdef>float <parameter>compare</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <refsect1 xml:id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>sampler</parameter></term>
            <listitem>
                <para>
                    Specifies the sampler to which the texture from which texels will be retrieved is bound.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>P</parameter></term>
            <listitem>
                <para>
                    Specifies the texture coordinates at which texture will be sampled.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>bias</parameter></term>
            <listitem>
                <para>
                    Specifies an optional bias to be applied during level-of-detail computation.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>compare</parameter></term>
            <listitem>
                <para>
                    When present, specifies the reference for shadow comparisons.
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 xml:id="description"><title>Description</title>
        <para>
            <function>texture</function> samples texels from the texture bound to <parameter>sampler</parameter> at texture
            coordinate <parameter>P</parameter>. An optional bias, specified in <parameter>bias</parameter> is included in
            the level-of-detail computation that is used to choose mipmap(s) from which to sample.
        </para>
        <para>
            For <emphasis>shadow</emphasis> forms, when <parameter>compare</parameter> is present, it is used as
            <inlineequation><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:msub><mml:mi>D</mml:mi><mml:mi>sub</mml:mi></mml:msub></mml:math></inlineequation>
            and the array layer is specified in <code><parameter>P</parameter>.w</code>. When <parameter>compare</parameter> is
            not present, the last component of <parameter>P</parameter> is used as
            <inlineequation><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:msub><mml:mi>D</mml:mi><mml:mi>sub</mml:mi></mml:msub></mml:math></inlineequation> and the
            array layer is specified in the second to last component of <parameter>P</parameter>.
        </para>
        <para>
            For non-shadow variants, the array layer comes from the last component of <parameter>P</parameter>.
        </para>
    </refsect1>
    <refsect1 xml:id="versions"><title>Version Support</title>
        <informaltable>
            <tgroup cols="5" align="left">
                <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="funchead.xml" xpointer="xpointer(/*/*)"/>
                <tbody>
                    <row>
                        <entry>texture</entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="version.xml" xpointer="xpointer(/*/*[@role='es30']/*)"/>
                    </row>
                    <row>
                        <entry>texture (gSamplerCubeArray, samplerCubeArrayShadow)</entry>
                        <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="version.xml" xpointer="xpointer(/*/*[@role='es32']/*)"/>
                    </row>
                </tbody>
            </tgroup>
        </informaltable>
    </refsect1>
    <refsect1 xml:id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>texelFetch</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>texelFetchOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureGrad</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureGradOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureLod</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureLodOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProj</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProjGrad</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProjGradOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProjLod</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProjLodOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureProjOffset</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>textureSize</refentrytitle></citerefentry>
        </para>
    </refsect1>
    <refsect1 xml:id="Copyright"><title>Copyright</title>
        <para>
            Copyright <trademark class="copyright"/> 2011-2015 Khronos Group.
            This material may be distributed subject to the terms and conditions set forth in
            the Open Publication License, v 1.0, 8 June 1999.
            <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://opencontent.org/openpub/">http://opencontent.org/openpub/</link>.
        </para>
    </refsect1>
</refentry>
