Page MenuHome

3D View: UV Checker Pattern Overlay
Needs RevisionPublic

Authored by CandleComet (CandleComet) on May 14 2021, 3:49 AM.
Tags
None
Tokens
"Love" token, awarded by 14AUDDIN."Love" token, awarded by andreasus."Love" token, awarded by andruxa696."Love" token, awarded by razed."Love" token, awarded by Lillya."Love" token, awarded by kioku."Love" token, awarded by Ikyuv."Love" token, awarded by kenziemac130."Love" token, awarded by Leul."Love" token, awarded by dulrich.

Details

Summary

This implements the UV checker pattern overlay as described in this RCS post

Considerations

  • This patch adds the checker overlay only for the 3D view. Perhaps the overlay should be linked to the UV editor, as in D8871.
  • The checkers are drawn based on the position of the UVs. Perhaps it should also factor in objects' texture resolution, which could be useful to visualize texture density.

Diff Detail

Event Timeline

CandleComet (CandleComet) requested review of this revision.May 14 2021, 3:49 AM
CandleComet (CandleComet) created this revision.

Amazing!!! I feel as though the overlay shader needs an option for tile recursions to better show smaller distortions. Maybe something like this?

(mockup in gimp, every time decrease by 1/4th and overlay with exponent drop in strength)

From a gamedev perspective it would be really helpful if one could define the 'pixelsize' of the checker. This would allow to see the real texelsize - on my work I regularly assign a temp checker image in predefined sizes (1024x1014/2048/2048 etc) for doing this.

It might also be worth a thought to make the checker pattern a bit more advanced:

  • show a low contrast pixel grid to see acutal pixel size
  • add some symbol to communicate orientation of the uvs (direction/mirrored)
  • circles help to see slight distortions

maybe best would be to support defining a texture for this?

Anyways - doing this in an overlay is really nice as it does not interfere with materials anymore. :)

Thanks for the patch!

On code side some style issues.
I am not an UV expert so not 100% sure if we should use a scale or a resolution or both.
I would @Julien Kaspar (JulienKaspar) to get his approval for this.

Error when using:

  • enter sculptmode
  • remesh
  • sculpt
  • enable uv overlay. it won't show as it is grayed out.
  • enter object mode
BLI_assert failed: source/blender/draw/intern/draw_cache_impl_mesh.c:764, texpaint_request_active_uv(), at 'cd_needed.uv != 0 && "No uv layer available in texpaint, but batches requested anyway!"'

or

  • activate overlay
  • remove uv layer.

When overlay is active and switching to eevee the overlay does not always render correct at first. Could not detect anything that might create this glitch

Overlay does not work in xray mode. Not essential as this is a known issue for other overlays as well.

source/blender/draw/engines/overlay/overlay_checker.c
16

or update the year or remove the line mentioning the year.

28

Empty function can be removed.

source/blender/draw/engines/overlay/overlay_engine.c
315

any reason why in_sculpt_mode isn't enough?

source/blender/draw/engines/overlay/overlay_private.h
534

single empty line is enough.

source/blender/draw/engines/overlay/shaders/checker_frag.glsl
9

precalc and use checkerScaleInv as uniform.

source/blender/makesdna/DNA_view3d_types.h
521

Use capitals

Jeroen Bakker (jbakker) requested changes to this revision.May 14 2021, 4:01 PM
This revision now requires changes to proceed.May 14 2021, 4:01 PM
  • style corrections
  • only draw the overlay when a UV layer is available (me->mloopuv != NULL). This was intended to fix the errors about no uv layer being available, but it still gives an error if the uv layer is deleted while in edit mode.
CandleComet (CandleComet) marked 5 inline comments as done.May 15 2021, 10:27 PM
CandleComet (CandleComet) added inline comments.
source/blender/draw/engines/overlay/overlay_engine.c
315

In cases when sculpt mode does not use pbvh, the overlay could work despite being in sculpt mode. That said, in_sculpt_mode makes more sense to use instead of is_sculpt_pbvh so as to match the UI being grayed out in sculpt mode.

From my side the patch looks good. @Pablo Dobarro (pablodp606) mentioned he had a similar patch for sculpting. Have added Sculpt, Paint & Texture as reviewer to find out if the ideas match. He mentioned to use HUE alteration for the texture.

I think it would be nice to have the overlay work in Sculpt Mode as well but this is a known limitation right now anyway with UVs in sculpt mode.
I wonder why we are not using the already existing grid textures in Blender for this overlay?

Especially the color grid for more information on seams and UV orientation would be welcome.
Other than that the overlay works wonderfully!

Does it makes more sense to have this feature:

  • as an overlay (current patch)
  • as a shading option for workbench

The overlay approach has some drawback:

  • Performance: it needs another geometry pass.
  • Surface matching: depth needs to match for the overlay to work. This fails with transparency (xray). We already have this issue with other overlays.
  • Blending: Having to blend on top of shading is going to have issue with shading info loss if using anything than the gray checker.

The workbench approach on the other hand:

  • Little to integrate since we already have a texture mode.
  • Might actually read the active texture size from nodetree.
  • Will not have the limitations of the overlay method.

I am surely missing some cons and pros for both.

So do we have a real use case for it to be an overlay? Do we really want this to be available for EEVEE or Cycles?

After testing this for a bit further I do think having this as a shading options instead might be more useful.
In edit mode the wires and selections, etc can obscure the grid very easily so it's very typical to disable overlays to see the grid more clearly. This is not possible if it's also an overlay.

Jeroen Bakker (jbakker) requested changes to this revision.Oct 27 2021, 7:56 AM

Looking at the feedback above, this should be migrated a workbench shading option.

This revision now requires changes to proceed.Oct 27 2021, 7:56 AM