Automatic Texture Type Detection

While in GLSL 100 you'd get a color from a texture by using the appropriate methods, such as texture2D, in GLSL 300 ES, shaders automatically detect the type based on the sampler type in use. For example, consider the following in GLSL 100:

uniform sampler2D uSome2DTexture;
uniform samplerCube uSomeCubeTexture;

void main(void) {
vec4 color1 = texture2D(uSome2DTexture, ...);
vec4 color2 = textureCube(uSomeCubeTexture, ...);
}

This would be updated to the following in GLSL 300 ES:

uniform sampler2D uSome2DTexture;
uniform samplerCube uSomeCubeTexture;

void main(void) {
vec4 color1 = texture(uSome2DTexture, ...);
vec4 color2 = texture(uSomeCubeTexture, ...);
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.186.164