diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-09-14 10:46:30 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-09-14 10:48:45 +0300 |
commit | c6210f9bacdb3d8b7ba05f29136ac6f9c8f643d7 (patch) | |
tree | 631a273532339776056a9cd18c43a2190cb41c76 /source/blender/draw/engines/image/shaders/engine_image_frag.glsl | |
parent | 9bc1d7a6deea8f401d727e80f42a04482c29bcef (diff) |
DrawManager: Resolve Assert in Image Engine
Tiled texture uses different texture structure than normal textures.
Normally we add dummy textures and use them, but I found it cleaner to
have 2 shaders and use the correct shader.
Diffstat (limited to 'source/blender/draw/engines/image/shaders/engine_image_frag.glsl')
-rw-r--r-- | source/blender/draw/engines/image/shaders/engine_image_frag.glsl | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/source/blender/draw/engines/image/shaders/engine_image_frag.glsl b/source/blender/draw/engines/image/shaders/engine_image_frag.glsl index 5c5d9362dfc..a79f4915c4d 100644 --- a/source/blender/draw/engines/image/shaders/engine_image_frag.glsl +++ b/source/blender/draw/engines/image/shaders/engine_image_frag.glsl @@ -5,12 +5,14 @@ #define SIMA_DRAW_FLAG_APPLY_ALPHA (1 << 1) #define SIMA_DRAW_FLAG_SHUFFLING (1 << 2) #define SIMA_DRAW_FLAG_DEPTH (1 << 3) -#define SIMA_DRAW_FLAG_TILED (1 << 4) -#define SIMA_DRAW_FLAG_DO_REPEAT (1 << 5) +#define SIMA_DRAW_FLAG_DO_REPEAT (1 << 4) +#ifdef TILED_IMAGE uniform sampler2DArray imageTileArray; uniform sampler1DArray imageTileData; +#else uniform sampler2D imageTexture; +#endif uniform bool imgPremultiplied; uniform int drawFlags; @@ -25,6 +27,7 @@ in vec2 uvs; out vec4 fragColor; +#ifdef TILED_IMAGE /* TODO(fclem) deduplicate code. */ bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map) { @@ -50,26 +53,26 @@ bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map) co = vec3(((co.xy - tile_pos) * tile_info.zw) + tile_info.xy, tile_layer); return true; } +#endif void main() { vec4 tex_color; /* Read texture */ - if ((drawFlags & SIMA_DRAW_FLAG_TILED) != 0) { - vec3 co = vec3(uvs, 0.0); - if (node_tex_tile_lookup(co, imageTileArray, imageTileData)) { - tex_color = texture(imageTileArray, co); - } - else { - tex_color = vec4(1.0, 0.0, 1.0, 1.0); - } +#ifdef TILED_IMAGE + vec3 co = vec3(uvs, 0.0); + if (node_tex_tile_lookup(co, imageTileArray, imageTileData)) { + tex_color = texture(imageTileArray, co); } else { - vec2 uvs_clamped = ((drawFlags & SIMA_DRAW_FLAG_DO_REPEAT) != 0) ? - fract(uvs) : - clamp(uvs, vec2(0.0), vec2(1.0)); - tex_color = texture(imageTexture, uvs_clamped); + tex_color = vec4(1.0, 0.0, 1.0, 1.0); } +#else + vec2 uvs_clamped = ((drawFlags & SIMA_DRAW_FLAG_DO_REPEAT) != 0) ? + fract(uvs) : + clamp(uvs, vec2(0.0), vec2(1.0)); + tex_color = texture(imageTexture, uvs_clamped); +#endif if ((drawFlags & SIMA_DRAW_FLAG_APPLY_ALPHA) != 0) { if (!imgPremultiplied && tex_color.a != 0.0 && tex_color.a != 1.0) { |