Texture Image node with "Extend" and Math "Wrap" creating artifacts. #112559

Open
opened 2023-09-19 10:16:33 +02:00 by vincentnl · 8 comments

System Information
Operating system: W10 x64
Graphics card: GTX750

Blender Version
Broken: 3.6.3, c8c6f62cf3, September 11, 01:59:02,
Worked: No

If texture node use "Extend" parameter, then "Wrap" math node, it does introduce a transparent line on edges of each image repetition.

Based on attached .blend file.

Image 1:
https://i.imgur.com/ZPBLnrA.png

Image 2:
https://i.imgur.com/pc0nXiE.png

**System Information** Operating system: W10 x64 Graphics card: GTX750 **Blender Version** Broken: 3.6.3, c8c6f62cf3a3, September 11, 01:59:02, Worked: No If texture node use "Extend" parameter, then "Wrap" math node, it does introduce a transparent line on edges of each image repetition. Based on attached .blend file. Image 1: https://i.imgur.com/ZPBLnrA.png Image 2: https://i.imgur.com/pc0nXiE.png
vincentnl added the
Priority
Normal
Status
Needs Triage
Type
Report
labels 2023-09-19 10:16:34 +02:00
vincentnl changed title from Wrapping node with Texture "Extend" artifacts. to Texture Image node with "Extend" and Math "Wrap" creating artifacts. 2023-09-19 10:17:54 +02:00
Member

Can confirm, Cycles seems to be better in that regard

Can confirm, Cycles seems to be better in that regard
Philipp Oeser added
Status
Confirmed
Module
EEVEE & Viewport
and removed
Status
Needs Triage
labels 2023-09-19 10:58:12 +02:00
Member

This seems to only occur in Linear texture interpolation. It also occurs when extension is set to Repeat. Replacing Wrap with Fract also shows the issue.

This seems to only occur in `Linear` texture interpolation. It also occurs when extension is set to `Repeat`. Replacing `Wrap` with `Fract` also shows the issue.
Member

This solves the issue for me but I'm not an expert with GPU to know if this is a valid fix.

--- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_image.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_image.glsl
@@ -56,7 +56,7 @@ void point_map_to_tube(vec3 vin, out vec3 vout)
 
 void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha)
 {
-  color = safe_color(texture(ima, co.xy));
+  color = safe_color(textureLod(ima, co.xy, 0.0));
   alpha = color.a;
 }
 
This solves the issue for me but I'm not an expert with GPU to know if this is a valid fix. ```Diff --- a/source/blender/gpu/shaders/material/gpu_shader_material_tex_image.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_tex_image.glsl @@ -56,7 +56,7 @@ void point_map_to_tube(vec3 vin, out vec3 vout) void node_tex_image_linear(vec3 co, sampler2D ima, out vec4 color, out float alpha) { - color = safe_color(texture(ima, co.xy)); + color = safe_color(textureLod(ima, co.xy, 0.0)); alpha = color.a; } ```
Author

This seems to only occur in Linear texture interpolation. It also occurs when extension is set to Repeat. Replacing Wrap with Fract also shows the issue.

Yes I confirm this too.
Regarding your above mentioned fix, is it integrated in latest build?

> This seems to only occur in `Linear` texture interpolation. It also occurs when extension is set to `Repeat`. Replacing `Wrap` with `Fract` also shows the issue. Yes I confirm this too. Regarding your above mentioned fix, is it integrated in latest build?
Member

This is just the way texture sampling works on GPUs. You're going to see the same issue in any other real-time engine.
The Mip level is selected based on the UV delta between pixels and, in your case, the delta at the edge is the whole image.
That's the whole reason the REPEAT mode exists.

What @CharlieJolly change does is disable mip mapping, so not really a viable solution.

What you can do is go the other way around. Set the sampling to REPEAT and manually clamp the Y axis.

imagen

This is just the way texture sampling works on GPUs. You're going to see the same issue in any other real-time engine. The Mip level is selected based on the UV delta between pixels and, in your case, the delta at the edge is the whole image. That's the whole reason the `REPEAT` mode exists. What @CharlieJolly change does is disable mip mapping, so not really a viable solution. What you can do is go the other way around. Set the sampling to `REPEAT` and manually clamp the `Y` axis. ![imagen](/attachments/effb2baa-17a3-446e-8c7a-4d642aaf9ef7)
870 KiB
Miguel Pozo added
Type
Known Issue
Priority
Low
and removed
Type
Report
Priority
Normal
labels 2023-09-20 19:50:42 +02:00
Member

@pragma37 this can also be fixed by changing interpolation to Closest which also turns mip mapping off.

  if (tex->interpolation != SHD_INTERP_CLOSEST) {
    /* TODO(fclem): For now assume mipmap is always enabled. */
    sampler_state.filtering = GPU_SAMPLER_FILTERING_ANISOTROPIC | GPU_SAMPLER_FILTERING_LINEAR |
                              GPU_SAMPLER_FILTERING_MIPMAP;
  }
@pragma37 this can also be fixed by changing interpolation to `Closest` which also turns mip mapping off. ``` if (tex->interpolation != SHD_INTERP_CLOSEST) { /* TODO(fclem): For now assume mipmap is always enabled. */ sampler_state.filtering = GPU_SAMPLER_FILTERING_ANISOTROPIC | GPU_SAMPLER_FILTERING_LINEAR | GPU_SAMPLER_FILTERING_MIPMAP; } ```
Author

This is just the way texture sampling works on GPUs. You're going to see the same issue in any other real-time engine.
The Mip level is selected based on the UV delta between pixels and, in your case, the delta at the edge is the whole image.
That's the whole reason the REPEAT mode exists.

What @CharlieJolly change does is disable mip mapping, so not really a viable solution.

What you can do is go the other way around. Set the sampling to REPEAT and manually clamp the Y axis.

imagen

No that's not clamping top and bottom sides correctly, it just repeat the same side all over.
You can see the intended look here: https://i.imgur.com/ZPBLnrA.png

Other than "closest" also "bicubic" does not show artifacts, so it's just "linear" showing this issue?

> This is just the way texture sampling works on GPUs. You're going to see the same issue in any other real-time engine. > The Mip level is selected based on the UV delta between pixels and, in your case, the delta at the edge is the whole image. > That's the whole reason the `REPEAT` mode exists. > > What @CharlieJolly change does is disable mip mapping, so not really a viable solution. > > What you can do is go the other way around. Set the sampling to `REPEAT` and manually clamp the `Y` axis. > > ![imagen](/attachments/effb2baa-17a3-446e-8c7a-4d642aaf9ef7) No that's not clamping top and bottom sides correctly, it just repeat the same side all over. You can see the intended look here: https://i.imgur.com/ZPBLnrA.png Other than "closest" also "bicubic" does not show artifacts, so it's just "linear" showing this issue?
Member

Just lower the clamp range.

Just lower the clamp range.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#112559
No description provided.