diff options
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl | 22 | ||||
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_effect_dof.c | 2 |
2 files changed, 14 insertions, 10 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl index 899ada852f9..c1c1c264f42 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_effect_dof_frag.glsl @@ -108,18 +108,22 @@ layout(location = 1) out vec2 outCocs; void main() { - ivec4 texel = ivec4(gl_FragCoord.xyxy) * 2 + ivec4(0, 0, 1, 1); + vec4 texel = vec4(gl_FragCoord.xyxy) * 2 + vec4(0, 0, 1, 1); + texel = (texel + 0.5) / vec4(textureSize(sceneColorTex, 0).xyxy); - vec4 color1 = texelFetch(sceneColorTex, texel.xy, 0); - vec4 color2 = texelFetch(sceneColorTex, texel.zw, 0); - vec4 color3 = texelFetch(sceneColorTex, texel.zy, 0); - vec4 color4 = texelFetch(sceneColorTex, texel.xw, 0); + /* Using texelFetch can bypass the mip range setting on some platform. + * Using texture Lod fix this issue. Note that we need to disable filtering to get the right + * texel values. */ + vec4 color1 = textureLod(sceneColorTex, texel.xy, 0.0); + vec4 color2 = textureLod(sceneColorTex, texel.zw, 0.0); + vec4 color3 = textureLod(sceneColorTex, texel.zy, 0.0); + vec4 color4 = textureLod(sceneColorTex, texel.xw, 0.0); vec4 depths; - vec2 cocs1 = texelFetch(inputCocTex, texel.xy, 0).rg; - vec2 cocs2 = texelFetch(inputCocTex, texel.zw, 0).rg; - vec2 cocs3 = texelFetch(inputCocTex, texel.zy, 0).rg; - vec2 cocs4 = texelFetch(inputCocTex, texel.xw, 0).rg; + vec2 cocs1 = textureLod(inputCocTex, texel.xy, 0.0).rg; + vec2 cocs2 = textureLod(inputCocTex, texel.zw, 0.0).rg; + vec2 cocs3 = textureLod(inputCocTex, texel.zy, 0.0).rg; + vec2 cocs4 = textureLod(inputCocTex, texel.xw, 0.0).rg; vec4 cocs_near = vec4(cocs1.r, cocs2.r, cocs3.r, cocs4.r) * MAX_COC_SIZE; vec4 cocs_far = vec4(cocs1.g, cocs2.g, cocs3.g, cocs4.g) * MAX_COC_SIZE; diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index abbca0988d4..f8223945a31 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -286,7 +286,7 @@ void workbench_dof_cache_init(WORKBENCH_Data *vedata) psl->dof_down2_ps = DRW_pass_create("DoF DownSample", DRW_STATE_WRITE_COLOR); DRWShadingGroup *grp = DRW_shgroup_create(downsample_sh, psl->dof_down2_ps); - DRW_shgroup_uniform_texture(grp, "sceneColorTex", txl->dof_source_tx); + DRW_shgroup_uniform_texture_ex(grp, "sceneColorTex", txl->dof_source_tx, GPU_SAMPLER_DEFAULT); DRW_shgroup_uniform_texture(grp, "inputCocTex", txl->coc_halfres_tx); DRW_shgroup_call_procedural_triangles(grp, NULL, 1); } |