Graphics Reference
In-Depth Information
on the primitive type; we describe this in the Chapter 7 section, Provoking
Vertex ), and that vertex value is used for all fragments in the primitive. We
can declare the output/inputs as flat shaded as follows:
// ...Vertex shader...
// Vertex shader output
flat out vec3 v_color;
// ...Fragment shader...
// Input from vertex shader
flat in vec3 v_color;
Finally, another qualifier can be added to interpolators with the
centroid keyword. The definition of centroid sampling is provided
in Chapter 11 in the section Multisampled Anti-Aliasing . Essentially,
when rendering with multisampling, the centroid keyword can be
used to force interpolation to occur inside the primitive being rendered
(otherwise, artifacts can occur at the edges of primitives). See Chapter 11,
“Fragment Operations,” for a full definition of centroid sampling. For
now, we simply show how you can declare an output/input variable with
centroid sampling:
// ...Vertex shader...
// Vertex shader output
smooth centroid out vec3 v_color;
// ...Fragment shader...
// Input from vertex shader
smooth centroid in vec3 v_color;
Preprocessor and Directives
One feature of the OpenGL ES Shading Language we have not mentioned
yet is the preprocessor. The OpenGL ES Shading Language features
a preprocessor that follows many of the conventions of a standard
C++ preprocessor. Macros can be defined and conditional tests can be
performed using the following directives:
#define
#undef
#if
#ifdef
#ifndef
#else
#elif
#endif
 
 
Search WWH ::




Custom Search