21.06.2014 Views

GLSL Spec

GLSL Spec

GLSL Spec

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

8 Built-in Functions<br />

Syntax<br />

genType fwidth (genType p)<br />

Description<br />

Returns the sum of the absolute derivative in x and y<br />

using local differencing for the input argument p, i.e.,<br />

abs (dFdx (p)) + abs (dFdy (p));<br />

8.12.2 Interpolation Functions<br />

Built-in interpolation functions are available to compute an interpolated value of a fragment shader input<br />

variable at a shader-specified (x, y) location. A separate (x, y) location may be used for each invocation of<br />

the built-in function, and those locations may differ from the default (x, y) location used to produce the<br />

default value of the input.<br />

For all of the interpolation functions, interpolant must be an input variable or an element of an input<br />

variable declared as an array. Component selection operators (e.g., .xy) may not be used when specifying<br />

interpolant. If interpolant is declared with a flat or centroid qualifier, the qualifier will have no effect on<br />

the interpolated value. If interpolant is declared with the noperspective qualifier, the interpolated value<br />

will be computed without perspective correction.<br />

Syntax<br />

float interpolateAtCentroid (float interpolant)<br />

vec2 interpolateAtCentroid (vec2 interpolant)<br />

vec3 interpolateAtCentroid (vec3 interpolant)<br />

vec4 interpolateAtCentroid (vec4 interpolant)<br />

Description<br />

Return the value of the input interpolant sampled at a<br />

location inside the both the pixel and the primitive<br />

being processed. The value obtained would be the<br />

same value assigned to the input variable if declared<br />

with the centroid qualifier.<br />

float interpolateAtSample (float interpolant,<br />

int sample)<br />

vec2 interpolateAtSample (vec2 interpolant,<br />

int sample)<br />

vec3 interpolateAtSample (vec3 interpolant,<br />

int sample)<br />

vec4 interpolateAtSample (vec4 interpolant,<br />

int sample)<br />

Return the value of the input interpolant variable at<br />

the location of sample number sample. If<br />

multisample buffers are not available, the input<br />

variable will be evaluated at the center of the pixel.<br />

If sample sample does not exist, the position used to<br />

interpolate the input variable is undefined.<br />

float interpolateAtOffset (float interpolant,<br />

vec2 offset)<br />

vec2 interpolateAtOffset (vec2 interpolant,<br />

vec2 offset)<br />

vec3 interpolateAtOffset (vec3 interpolant,<br />

vec2 offset)<br />

vec4 interpolateAtOffset (vec4 interpolant,<br />

vec2 offset)<br />

Return the value of the input interpolant variable<br />

sampled at an offset from the center of the pixel<br />

specified by offset. The two floating-point<br />

components of offset, give the offset in pixels in the x<br />

and y directions, respectively. An offset of (0, 0)<br />

identifies the center of the pixel. The range and<br />

granularity of offsets supported by this function is<br />

implementation-dependent.<br />

154

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!