Fix T58227: Subdivision Surface Type Simple messes up UVs

This seems to be a bug in OpenSubdiv. For now simply use Catmark
subdivision scheme with infinitely sharp edges.

Later on it's either gets fixed in OpenSubdiv or we do bilinear
subdivision on our side.
This commit is contained in:
Sergey Sharybin 2018-12-04 15:15:14 +01:00
parent 245065460f
commit e666ee965c
Notes: blender-bot 2023-02-14 05:28:01 +01:00
Referenced by issue #58227, Subdivision Surface Type Simple messes up UVs
3 changed files with 23 additions and 5 deletions

View File

@ -46,8 +46,8 @@ void BKE_multires_subdiv_settings_init(
const MultiresModifierData *mmd)
{
settings->is_simple = (mmd->simple != 0);
settings->is_adaptive = !settings->is_simple;
settings->level = mmd->quality;
settings->is_adaptive = true;
settings->level = settings->is_simple ? 1 : mmd->quality;
settings->vtx_boundary_interpolation = SUBDIV_VTX_BOUNDARY_EDGE_ONLY;
settings->fvar_linear_interpolation =
BKE_subdiv_fvar_interpolation_from_uv_smooth(mmd->uv_smooth);

View File

@ -47,6 +47,10 @@
#include "opensubdiv_capi.h"
#include "opensubdiv_converter_capi.h"
/* Enable work-around for non-working CPU evaluator when using bilinear scheme.
* This forces Catmark scheme with all edges marked as infinitely sharp. */
#define BUGGY_SIMPLE_SCHEME_WORKAROUND 1
typedef struct ConverterStorage {
SubdivSettings settings;
const Mesh *mesh;
@ -78,6 +82,10 @@ typedef struct ConverterStorage {
static OpenSubdiv_SchemeType get_scheme_type(
const OpenSubdiv_Converter *converter)
{
#if BUGGY_SIMPLE_SCHEME_WORKAROUND
(void) converter;
return OSD_SCHEME_CATMARK;
#else
ConverterStorage *storage = converter->user_data;
if (storage->settings.is_simple) {
return OSD_SCHEME_BILINEAR;
@ -85,6 +93,7 @@ static OpenSubdiv_SchemeType get_scheme_type(
else {
return OSD_SCHEME_CATMARK;
}
#endif
}
static OpenSubdiv_VtxBoundaryInterpolation get_vtx_boundary_interpolation(
@ -161,6 +170,11 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter,
int manifold_edge_index)
{
ConverterStorage *storage = converter->user_data;
#if BUGGY_SIMPLE_SCHEME_WORKAROUND
if (storage->settings.is_simple) {
return 10.0f;
}
#endif
const int edge_index =
storage->manifold_edge_index_reverse[manifold_edge_index];
const MEdge *medge = storage->mesh->medge;
@ -168,11 +182,15 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter,
return edge_crease * edge_crease * 10.0f;
}
static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter,
int manifold_vertex_index)
{
ConverterStorage *storage = converter->user_data;
#if BUGGY_SIMPLE_SCHEME_WORKAROUND
if (storage->settings.is_simple) {
return true;
}
#endif
const int vertex_index =
storage->manifold_vertex_index_reverse[manifold_vertex_index];
return BLI_BITMAP_TEST_BOOL(storage->infinite_sharp_vertices_map,

View File

@ -115,8 +115,8 @@ static void subdiv_settings_init(SubdivSettings *settings,
const SubsurfModifierData *smd)
{
settings->is_simple = (smd->subdivType == SUBSURF_TYPE_SIMPLE);
settings->is_adaptive = !settings->is_simple;
settings->level = smd->quality;
settings->is_adaptive = true;
settings->level = settings->is_simple ? 1 : smd->quality;
settings->vtx_boundary_interpolation = SUBDIV_VTX_BOUNDARY_EDGE_ONLY;
settings->fvar_linear_interpolation =
BKE_subdiv_fvar_interpolation_from_uv_smooth(smd->uv_smooth);