Differential D7816 Diff 25009 source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_image_lib.glsl
| Show All 18 Lines | bool node_tex_tile_lookup(inout vec3 co, sampler2DArray ima, sampler1DArray map) | ||||
| vec4 tile_info = texelFetch(map, ivec2(tile, 1), 0); | vec4 tile_info = texelFetch(map, ivec2(tile, 1), 0); | ||||
| co = vec3(((co.xy - tile_pos) * tile_info.zw) + tile_info.xy, tile_layer); | co = vec3(((co.xy - tile_pos) * tile_info.zw) + tile_info.xy, tile_layer); | ||||
| return true; | return true; | ||||
| } | } | ||||
| vec4 workbench_sample_texture(sampler2D image, vec2 coord, bool nearest_sampling) | vec4 workbench_sample_texture(sampler2D image, vec2 coord, bool nearest_sampling) | ||||
| { | { | ||||
| vec2 tex_size = vec2(textureSize(image, 0).xy); | |||||
| /* TODO(fclem) We could do the same with sampler objects. | /* TODO(fclem) We could do the same with sampler objects. | ||||
| * But this is a quick workaround instead of messing with the GPUTexture itself. */ | * But this is a quick workaround instead of messing with the GPUTexture itself. */ | ||||
| vec2 uv = nearest_sampling ? (floor(coord * tex_size) + 0.5) / tex_size : coord; | if (nearest_sampling) { | ||||
| return texture(image, uv); | /* Use texelFetch for nearest_sampling to reduce glitches. See: T73726 */ | ||||
| vec2 tex_size = vec2(textureSize(image, 0).xy); | |||||
| ivec2 uv = ivec2(floor(coord * tex_size) + 0.5); | |||||
| return texelFetch(image, uv, 0); | |||||
| } | |||||
| else { | |||||
| return texture(image, coord); | |||||
| } | |||||
| } | } | ||||
| vec4 workbench_sample_texture_array(sampler2DArray tile_array, | vec4 workbench_sample_texture_array(sampler2DArray tile_array, | ||||
| sampler1DArray tile_data, | sampler1DArray tile_data, | ||||
| vec2 coord, | vec2 coord, | ||||
| bool nearest_sampling) | bool nearest_sampling) | ||||
| { | { | ||||
| vec2 tex_size = vec2(textureSize(tile_array, 0).xy); | |||||
| vec3 uv = vec3(coord, 0); | vec3 uv = vec3(coord, 0); | ||||
| if (!node_tex_tile_lookup(uv, tile_array, tile_data)) | if (!node_tex_tile_lookup(uv, tile_array, tile_data)) | ||||
| return vec4(1.0, 0.0, 1.0, 1.0); | return vec4(1.0, 0.0, 1.0, 1.0); | ||||
| /* TODO(fclem) We could do the same with sampler objects. | /* TODO(fclem) We could do the same with sampler objects. | ||||
| * But this is a quick workaround instead of messing with the GPUTexture itself. */ | * But this is a quick workaround instead of messing with the GPUTexture itself. */ | ||||
| uv.xy = nearest_sampling ? (floor(uv.xy * tex_size) + 0.5) / tex_size : uv.xy; | if (nearest_sampling) { | ||||
| /* Use texelFetch for nearest_sampling to reduce glitches. See: T73726 */ | |||||
| vec3 tex_size = vec3(textureSize(tile_array, 0)); | |||||
| uv.xy = floor(uv.xy * tex_size.xy) + 0.5; | |||||
fclem: i feel this is wrong. i did not test but the Z is already non-normalized for array textures. | |||||
Done Inline ActionsYou're right. jbakker: You're right. | |||||
| return texelFetch(tile_array, ivec3(uv), 0); | |||||
| } | |||||
| else { | |||||
| return texture(tile_array, uv); | return texture(tile_array, uv); | ||||
| } | } | ||||
| } | |||||
| uniform sampler2DArray imageTileArray; | uniform sampler2DArray imageTileArray; | ||||
| uniform sampler1DArray imageTileData; | uniform sampler1DArray imageTileData; | ||||
| uniform sampler2D imageTexture; | uniform sampler2D imageTexture; | ||||
| uniform float imageTransparencyCutoff = 0.1; | uniform float imageTransparencyCutoff = 0.1; | ||||
| uniform bool imageNearest; | uniform bool imageNearest; | ||||
| uniform bool imagePremult; | uniform bool imagePremult; | ||||
| Show All 26 Lines | |||||
i feel this is wrong. i did not test but the Z is already non-normalized for array textures.