Download third_party/ktx-src/tests/loadtests/glloadtests/shader-based/shaders.cpp from kimjunhan/vkgs-sim: direct link, hf CLI and curl.
- Browser
- Download file 3.15 kB
-
https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/shaders.cpp
- Command line
-
hf download hf://kimjunhan/vkgs-sim/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/shaders.cpp
-
curl -L -o shaders.cpp https://huggingface.co/kimjunhan/vkgs-sim/resolve/main/third_party/ktx-src/tests/loadtests/glloadtests/shader-based/shaders.cpp
3.15 kB
| /* -*- tab-iWidth: 4; -*- */ | |
| /* vi: set sw=2 ts=4 expandtab: */ | |
| /* | |
| * Copyright 2008 HI Corporation. | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| /** | |
| * @file | |
| * @brief Shaders used by the DrawTexture and TexturedCube samples. | |
| */ | |
| const GLchar* pszVs = | |
| "layout(location = 0) in vec4 position;\n" | |
| "layout(location = 1) in vec4 color;\n" | |
| "layout(location = 2) in vec4 texcoord;\n\n" | |
| "out vec4 v_color;\n" | |
| "out vec2 v_texcoord;\n\n" | |
| "uniform highp mat4 mvmatrix;\n" | |
| "uniform highp mat4 pmatrix;\n\n" | |
| "void main(void)\n" | |
| "{\n" | |
| " mat4 mvpmatrix = pmatrix * mvmatrix;\n" | |
| " v_color = color;\n" | |
| " v_texcoord = texcoord.xy;\n" | |
| " gl_Position = mvpmatrix * position;\n" | |
| "}"; | |
| const GLchar* pszDecalFs = | |
| "precision mediump float;\n\n" | |
| "uniform sampler2D sampler;\n\n" | |
| "in vec4 v_color;\n" | |
| "in vec2 v_texcoord;\n" | |
| "out vec4 fragcolor;\n\n" | |
| "void main(void)\n" | |
| "{\n" | |
| " vec4 color = texture(sampler, v_texcoord);\n" | |
| " // DECAL\n" | |
| " fragcolor.rgb = v_color.rgb * (1.0f - color.a) + color.rgb * color.a;\n" | |
| " // No need for blending with page or screen background.\n" | |
| " fragcolor.a = 1.0f;\n" | |
| "}"; | |
| const GLchar* pszColorFs = | |
| "precision mediump float;\n\n" | |
| "in vec4 v_color;\n" | |
| "out vec4 fragcolor;\n\n" | |
| "void main(void)\n" | |
| "{\n" | |
| " fragcolor = v_color;\n" | |
| "}"; | |
| // For use when sRGB rendering is not available. Note this is really a | |
| // workaround for broken GL implementations (most) where "linear" framebuffers | |
| // are really sRGB framebuffers but since they are "linear" GL does not encode | |
| // the output of the fs to sRGB so we do it ourselves. | |
| const GLchar* pszDecalSrgbEncodeFs = | |
| "precision mediump float;\n\n" | |
| "uniform sampler2D sampler;\n\n" | |
| "in vec4 v_color;\n" | |
| "in vec2 v_texcoord;\n" | |
| "out vec4 fragcolor;\n\n" | |
| "vec3 srgb_encode(vec3 color) {\n" | |
| " float r = color.r < 0.0031308 ? 12.92 * color.r : 1.055 * pow(color.r, 1.0/2.4) - 0.055;\n" | |
| " float g = color.g < 0.0031308 ? 12.92 * color.g : 1.055 * pow(color.g, 1.0/2.4) - 0.055;\n" | |
| " float b = color.b < 0.0031308 ? 12.92 * color.b : 1.055 * pow(color.b, 1.0/2.4) - 0.055;\n" | |
| " return vec3(r, g, b);\n" | |
| "}\n\n" | |
| "void main(void)\n" | |
| "{\n" | |
| " vec4 t_color = texture(sampler, v_texcoord);\n" | |
| " vec3 lin_fragcolor;\n" | |
| " // DECAL\n" | |
| " lin_fragcolor = v_color.rgb * (1.0f - t_color.a) + t_color.rgb * t_color.a;\n" | |
| " fragcolor.rgb = srgb_encode(lin_fragcolor);\n" | |
| " // No need for blending with page or screen background.\n" | |
| " fragcolor.a = 1.0f;\n" | |
| "}"; | |
| const GLchar* pszColorSrgbEncodeFs = | |
| "precision mediump float;\n\n" | |
| "in vec4 v_color;\n" | |
| "out vec4 fragcolor;\n\n" | |
| "vec3 srgb_encode(vec3 color) {\n" | |
| " float r = color.r < 0.0031308 ? 12.92 * color.r : 1.055 * pow(color.r, 1.0/2.4) - 0.055;\n" | |
| " float g = color.g < 0.0031308 ? 12.92 * color.g : 1.055 * pow(color.g, 1.0/2.4) - 0.055;\n" | |
| " float b = color.b < 0.0031308 ? 12.92 * color.b : 1.055 * pow(color.b, 1.0/2.4) - 0.055;\n" | |
| " return vec3(r, g, b);\n" | |
| "}\n\n" | |
| "void main(void)\n" | |
| "{\n" | |
| " fragcolor.rgb = srgb_encode(v_color.rgb);\n" | |
| " fragcolor.a = v_color.a;\n" | |
| "}"; | |
| /* ----------------------------------------------------------------------------- */ | |