2017-02-06 19:42:52 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2017-04-28 23:58:59 +03:00
|
|
|
#ifdef WR_FEATURE_TEXTURE_EXTERNAL
|
|
|
|
// Please check https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
|
|
|
|
// for this extension.
|
|
|
|
#extension GL_OES_EGL_image_external_essl3 : require
|
|
|
|
#endif
|
|
|
|
|
2017-09-15 15:07:24 +03:00
|
|
|
#include base
|
|
|
|
|
2017-04-28 23:58:59 +03:00
|
|
|
// The textureLod() doesn't support samplerExternalOES for WR_FEATURE_TEXTURE_EXTERNAL.
|
|
|
|
// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
|
|
|
|
//
|
|
|
|
// The textureLod() doesn't support sampler2DRect for WR_FEATURE_TEXTURE_RECT, too.
|
|
|
|
//
|
|
|
|
// Use texture() instead.
|
2017-08-18 15:51:39 +03:00
|
|
|
#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT) || defined(WR_FEATURE_TEXTURE_2D)
|
|
|
|
#define TEX_SAMPLE(sampler, tex_coord) texture(sampler, tex_coord.xy)
|
2017-04-28 23:58:59 +03:00
|
|
|
#else
|
|
|
|
// In normal case, we use textureLod(). We haven't used the lod yet. So, we always pass 0.0 now.
|
|
|
|
#define TEX_SAMPLE(sampler, tex_coord) textureLod(sampler, tex_coord, 0.0)
|
|
|
|
#endif
|
|
|
|
|
2017-02-06 19:42:52 +03:00
|
|
|
//======================================================================================
|
|
|
|
// Vertex shader attributes and uniforms
|
|
|
|
//======================================================================================
|
|
|
|
#ifdef WR_VERTEX_SHADER
|
|
|
|
// Uniform inputs
|
|
|
|
uniform mat4 uTransform; // Orthographic projection
|
|
|
|
uniform float uDevicePixelRatio;
|
|
|
|
|
|
|
|
// Attribute inputs
|
|
|
|
in vec3 aPosition;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//======================================================================================
|
|
|
|
// Fragment shader attributes and uniforms
|
|
|
|
//======================================================================================
|
|
|
|
#ifdef WR_FRAGMENT_SHADER
|
2017-10-13 19:51:07 +03:00
|
|
|
// A generic uniform that shaders can optionally use to configure
|
|
|
|
// an operation mode for this batch.
|
|
|
|
uniform int uMode;
|
|
|
|
|
2017-02-06 19:42:52 +03:00
|
|
|
// Uniform inputs
|
|
|
|
|
|
|
|
// Fragment shader outputs
|
|
|
|
out vec4 oFragColor;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//======================================================================================
|
|
|
|
// Shared shader uniforms
|
|
|
|
//======================================================================================
|
2017-08-18 15:51:39 +03:00
|
|
|
#ifdef WR_FEATURE_TEXTURE_2D
|
|
|
|
uniform sampler2D sColor0;
|
|
|
|
uniform sampler2D sColor1;
|
|
|
|
uniform sampler2D sColor2;
|
|
|
|
#elif defined WR_FEATURE_TEXTURE_RECT
|
2017-04-05 05:46:17 +03:00
|
|
|
uniform sampler2DRect sColor0;
|
|
|
|
uniform sampler2DRect sColor1;
|
|
|
|
uniform sampler2DRect sColor2;
|
2017-04-28 23:58:59 +03:00
|
|
|
#elif defined WR_FEATURE_TEXTURE_EXTERNAL
|
|
|
|
uniform samplerExternalOES sColor0;
|
|
|
|
uniform samplerExternalOES sColor1;
|
|
|
|
uniform samplerExternalOES sColor2;
|
|
|
|
#else
|
2017-08-18 15:51:39 +03:00
|
|
|
uniform sampler2DArray sColor0;
|
|
|
|
uniform sampler2DArray sColor1;
|
|
|
|
uniform sampler2DArray sColor2;
|
2017-04-05 05:46:17 +03:00
|
|
|
#endif
|
2017-04-28 23:58:59 +03:00
|
|
|
|
|
|
|
#ifdef WR_FEATURE_DITHERING
|
2017-03-29 00:49:11 +03:00
|
|
|
uniform sampler2D sDither;
|
2017-04-28 23:58:59 +03:00
|
|
|
#endif
|
2017-02-06 19:42:52 +03:00
|
|
|
|
|
|
|
//======================================================================================
|
|
|
|
// Interpolator definitions
|
|
|
|
//======================================================================================
|
|
|
|
|
|
|
|
//======================================================================================
|
|
|
|
// VS only types and UBOs
|
|
|
|
//======================================================================================
|
|
|
|
|
|
|
|
//======================================================================================
|
|
|
|
// VS only functions
|
|
|
|
//======================================================================================
|