• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
5 * Copyright 2015 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20const char* forward_tonemap_shader = ""
21    "#extension GL_OES_EGL_image_external_essl3 : require                       \n"
22    "precision highp float;                                                     \n"
23    "precision highp sampler2D;                                                 \n"
24    "layout(binding = 0) uniform samplerExternalOES externalTexture;            \n"
25    "layout(binding = 1) uniform sampler3D tonemapper;                          \n"
26    "layout(binding = 2) uniform sampler2D xform;                               \n"
27    "layout(location = 3) uniform vec2 tSO;                                     \n"
28    "#ifdef USE_NONUNIFORM_SAMPLING                                             \n"
29    "layout(location = 4) uniform vec2 xSO;                                     \n"
30    "#endif                                                                     \n"
31    "in vec2 uv;                                                                \n"
32    "out vec4 fs_color;                                                         \n"
33    "                                                                           \n"
34    "vec3 ScaleOffset(in vec3 samplePt, in vec2 so)                             \n"
35    "{                                                                          \n"
36    "   vec3 adjPt = so.x * samplePt + so.y;                                    \n"
37    "   return adjPt;                                                           \n"
38    "}                                                                          \n"
39    "                                                                           \n"
40    "void main()                                                                \n"
41    "{                                                                          \n"
42    "vec2 flipped = vec2(uv.x, 1.0f - uv.y);                                    \n"
43    "vec4 rgb = texture(externalTexture, flipped);                              \n"
44    "#ifdef USE_NONUNIFORM_SAMPLING                                             \n"
45    "vec3 adj = ScaleOffset(rgb.xyz, xSO);                                      \n"
46    "float r = texture(xform, vec2(adj.r, 0.5f)).r;                             \n"
47    "float g = texture(xform, vec2(adj.g, 0.5f)).g;                             \n"
48    "float b = texture(xform, vec2(adj.b, 0.5f)).b;                             \n"
49    "#else                                                                      \n"
50    "float r = rgb.r;                                                           \n"
51    "float g = rgb.g;                                                           \n"
52    "float b = rgb.b;                                                           \n"
53    "#endif                                                                     \n"
54    "fs_color.rgb = texture(tonemapper, ScaleOffset(vec3(r, g, b), tSO)).rgb;   \n"
55    "}                                                                          \n";
56