2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0 */
|
2021-06-28 08:50:09 +02:00
|
|
|
|
|
|
|
|
#include "gpu_testing.hh"
|
|
|
|
|
|
|
|
|
|
#include "GPU_shader.h"
|
|
|
|
|
|
|
|
|
|
namespace blender::gpu::tests {
|
|
|
|
|
|
|
|
|
|
static void test_compile_builtin_shader(eGPUBuiltinShader shader_type, eGPUShaderConfig sh_cfg)
|
|
|
|
|
{
|
|
|
|
|
GPUShader *sh = GPU_shader_get_builtin_shader_with_config(shader_type, sh_cfg);
|
|
|
|
|
EXPECT_NE(sh, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_compile_builtin_shader(eGPUBuiltinShader shader_type)
|
|
|
|
|
{
|
|
|
|
|
test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(shader_type, GPU_SHADER_CFG_CLIPPED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void test_shader_builtin()
|
|
|
|
|
{
|
|
|
|
|
GPU_shader_free_builtin_shaders();
|
|
|
|
|
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_UNIFORM_COLOR);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_SMOOTH_COLOR);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_DEPTH_ONLY);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA);
|
|
|
|
|
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_TEXT, GPU_SHADER_CFG_DEFAULT);
|
2021-09-23 15:53:38 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_KEYFRAME_SHAPE, GPU_SHADER_CFG_DEFAULT);
|
2021-06-28 08:50:09 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_SIMPLE_LIGHTING, GPU_SHADER_CFG_DEFAULT);
|
EEVEE & Viewport: Add a built-in shader called 3D_IMAGE, and expose to the python API
Adds an example python script to the documentation for the 3D_IMAGE shader.
The **use-case** is to draw textures with 3D vertex positions, in XR views as well as non-XR views (in a simpler manner).
**Testing**: I've tested that this compiles and works on my Macbook (with the example python script included in this change). I don't have access to a Windows or Linux machine right now, but this change doesn't look platform-specific and no new glsl shaders have been added or edited by this change. I'll try to get access to a Windows machine, but if someone does have one, I'd be really grateful if they could try this change. Thanks!
**Problem addressed**: The existing 2D_IMAGE shader (exposed in the python API) gets near-clipped when drawn in the
XR view, regardless of the near-clip settings. Additionally, the 2D_IMAGE shader only accepts 2D
positions for the image vertices, which means drawing textures in 3D requires providing
2D coordinates and then pushing a transform-rotate-scale matrix to the GPU, even for
non-XR (i.e. WINDOW) views. The 3D_IMAGE shader is simpler: it accepts 3D vertex positions, and doesn't require
any additional work by the scripter.
**Workaround**: The current workaround is to use custom shaders in the python script.
**Non-intrusive change**: No new glsl shaders were added. This change just bundles two existing shaders: the vertex shader used
by the 3D_IMAGE_MODULATE_ALPHA shader, and the fragment shader used by the 2D_IMAGE shader.
Reviewed By: #eevee_viewport, jbakker
Differential Revision: https://developer.blender.org/D14832
2022-05-09 08:07:28 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_IMAGE, GPU_SHADER_CFG_DEFAULT);
|
2022-09-06 11:23:05 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_IMAGE_COLOR, GPU_SHADER_CFG_DEFAULT);
|
2021-06-28 08:50:09 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_DESATURATE_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_CHECKER, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_DIAG_STRIPES, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR,
|
|
|
|
|
GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_FLAT_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA,
|
|
|
|
|
GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA,
|
|
|
|
|
GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR,
|
|
|
|
|
GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR,
|
|
|
|
|
GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_GPENCIL_STROKE, GPU_SHADER_CFG_DEFAULT);
|
2022-01-10 12:22:06 +01:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_AREA_BORDERS, GPU_SHADER_CFG_DEFAULT);
|
2021-06-28 08:50:09 +02:00
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_BASE, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_BASE_INST, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_WIDGET_SHADOW, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_NODELINK, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
test_compile_builtin_shader(GPU_SHADER_2D_NODELINK_INST, GPU_SHADER_CFG_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_TEST(shader_builtin)
|
|
|
|
|
|
|
|
|
|
} // namespace blender::gpu::tests
|