Main | API | Shaders (SBO) | getTexturePixelColour


getTexturePixelColour(x, y, texture);

Samples a colour value from a texture.


x - [Float]

The x coordinate of the texture. Range 0.0 - 1.0

y - [Float]

The y coordinate of the texture. Range 0.0 - 1.0

texture - [Reference]

The texture reference that should be sampled from. This is one of the eight texture references that texture buffers can be bound to. These are: TEXTURE_0, TEXTURE_1, TEXTURE_2, TEXTURE_3, TEXTURE_4, TEXTURE_5, TEXTURE_6, TEXTURE_7.


Color - [Integer]

The 32-Bit colour value for the pixel that was sampled.


This is the function used within shaders to sample from a texture. It takes in an x and y value that is in the range 0.0 to 1.0, along with a reference to the texture it is sampling. It then returns the colour of the closest pixel to the coordinate given. This function is supplied by WR_Core and not the main WebRender interface, and should be called on the render reference that is passed to the shader. See the textures page and tutorial 3 for more information.

Do not pass negative coordinates into this function. WebRender is designed to convert interpolated u, v values into the positive range when the shader is setup correctly. Negative values will break the sampling function and either crash the application or run extremely slowly.

See more detailed information about textures here.

See more detailed information about shaders here.

Additional Notes