Graphics Reference
In-Depth Information
texture. However, when filtering a depth texture, we want the filtering to
occur after we sample the depth value and compare to the current depth
(or reference value). If filtering were to occur before comparison, then we
would be averaging values in the depth texture, which does not provide
the correct result. PCF provides the correct filtering, such that each depth
value sampled is compared to the reference depth and then the results of
those comparisons (0 or 1) are averaged together.
The GL_TEXTURE_COMPARE_MODE defaults to GL_NONE , but when it is
set to GL_COMPARE_REF_TO_TEXTURE , the r -coordinate in the ( s , t , r )
texture coordinate will be compared with the value of the depth texture.
The result of this comparison then becomes the result of the shadow
texture fetch (either a value of 0 or 1, or an averaging of these values
if texture filtering is enabled). The comparison function is set using
GL_TEXTURE_COMPARE_FUNC , which can set the comparison function to
GL_LEQUAL , GL_EQUAL , GL_LESS , GL_GREATER , GL_EQUAL , GL_NOTEQUAL ,
GL_ALWAYS , or GL_NEVER. More details on shadow mapping are covered
in Chapter 14, “Advanced Programming with OpenGL ES 3.0.”
Texture Formats
OpenGL ES 3.0 offers a wide range of data formats for textures. In fact, the
number of formats has greatly increased from OpenGL ES 2.0. This section
details the texture formats available in OpenGL ES 3.0.
As described in the previous section Texture Objects and Loading Textures ,
a 2D texture can be uploaded with either an unsized or sized internal
format using glTexImage2D . If the texture is specified with an unsized
format, the OpenGL ES implementation is free to choose the actual
internal representation in which the texture data is stored. If the texture is
specified with a sized format, then OpenGL ES will choose a format with
at least as many bits as is specified.
Table 9-4 lists the valid combinations for specifying a texture with an
unsized internal format.
If the application wants more control over how the data is stored internally,
then it can use a sized internal format. The valid combinations for sized
internal formats with glTexImage2D are listed in Tables 9-5 to 9-10. In the last
two columns, “R” means renderable and “F” means filterable. OpenGL ES 3.0
mandates only that certain formats be available for rendering to or filtering
from. Further, some formats can be specified with input data containing more
bits than the internal format. In this case, the implementation may choose to
convert to lesser bits or use a format with more bits.
 
 
Search WWH ::




Custom Search