Fix #116809: Geometry nodes UV map of UV Sphere #116856
No reviewers
Labels
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
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#116856
Loading…
Reference in New Issue
No description provided.
Delete Branch "fuvesib/blender:gn-uvsphere-uvsegmentfix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix #116809. The UV map of the UV Sphere Mesh Primitive matches other Geometry Nodes Mesh Primitives by shifting all the segments to the right and moving the last segment to the beginning.
Thanks for fix! Just one comment to make math more clear.
This fix works correct right now:
Now here is issue: old blend file (with original uv) is become to looks different.
This is compatibility issue. To fix that, you need to create new function in
blender\blenloader\intern\versioning_400.cc
.This function need to be called at versioning_400.cc#L2561 line (with version check if statement). See this function as example versioning_300.cc#L553
In result, i think, is enough to rotate mesh to in old files to make it looks the same as in older blender. Here is my setup:
(I've highlighted in pencil below the new nodes that need to be created by the versioning code.)
If the to
Segments
socket of node previously a link was connected, then you need to create a new link so that it is connected to the Math node.If
Mesh
output was unused, new nodes is not necessary. But in case is was used, links should be reconnected to be fromTransform Geometry
node, and new link fromMesh
output toTransform Geometry
input need to be created.@ -252,3 +252,3 @@
for (const int i_segment : IndexRange(segments)) {
const int loop_start = i_segment * 3;
const float segment = float(i_segment);
float segment = float(i_segment + 1);
This could be done in single line:
const float segment = math::mod<int>(i_segment + 1, segments);
.It is better to make this in single line to keep
segment
variable as const.If you will get error due to undefined function, you would search required header in
blenlib
folder.I just made pretty similar versioning, you could use this as example: #116870/files
@ -1805,0 +1881,4 @@
// nodeAddLink(&ntree, segments_node, integer_output, primitive_node, segments_input);
// nodeAddLink(&ntree, segments_node, integer_output, divide_node, divisor_input);
*version_cycles_node_socket_float_value(divisor_input) = *version_cycles_node_socket_int_value(segments_input);
version_cycles_node_socket_int_value->default_value_typed<bNodeSocketValueInt>()->value
Fix UV map of UV sphere to match cone's and cylinder's UV map by rotating vertex positions and matching them with cone's and cylinder's vertex positions (Small icosphere marks 1st vertex):
Versioning:
Now everything is works correct! Old file looks the same, and easy i can mute
Transform Geometry
and result will be fixed. I add some comments about code clean.@ -1805,0 +1809,4 @@
LISTBASE_FOREACH (bNodeLink *, link, &ntree.links) {
bNode *to_node = link->tonode;
if ((to_node->type == GEO_NODE_MESH_PRIMITIVE_UV_SPHERE) && (link->tosock == nodeFindSocket(to_node, SOCK_IN, "Segments"))) {
You can simply check name of socket (
STREQ(link->tosock->name, "Segments")
). Same below.@ -1805,0 +1813,4 @@
primitive_nodes_inputs.add(to_node, link);
}
bNode *from_node = link->fromnode;
if ((from_node->type == GEO_NODE_MESH_PRIMITIVE_UV_SPHERE) && (link->fromsock == nodeFindSocket(from_node, SOCK_OUT, "Mesh"))) {
Can you run in your root folder of blender fork:
To format this and other lines. See https://wiki.blender.org/wiki/Tools/ClangFormat
@ -1805,0 +1864,4 @@
bNodeSocket *divisor_input = static_cast<bNodeSocket *>(BLI_findlink(÷_node->inputs, 1));
bNodeSocket *value_output = nodeFindSocket(divide_node, SOCK_OUT, "Value");
*version_cycles_node_socket_float_value(dividend_input) = M_PI * 2;
2
->2.0f
See https://wiki.blender.org/wiki/Style_Guide/C_Cpp#Value_Literals
@ -1805,0 +1870,4 @@
if (primitive_nodes_inputs.contains(primitive_node)) {
bNodeLink *link = primitive_nodes_inputs.lookup(primitive_node);
nodeAddLink(&ntree, link->fromnode, link->fromsock, divide_node, divisor_input);
Add
continue;
in end of this branch, and deleteelse
after. This is early return pattern (to reduce nesting).@ -344,6 +344,12 @@ void add_realize_instances_before_socket(bNodeTree *ntree,
}
}
int *version_cycles_node_socket_int_value(bNodeSocket *socket)
This function doesn't make sense. Here is
bNodeSocket::default_value_typed<bNodeSocketValueInt>()
method witch is should be used to access to the socket value. This is commonly used in whole blender.If you think you done my comment point, you would press
Resolve conversation
.2b682c8e3b
Thanks for working on this. Maybe I don't understand it properly, but I have to say I'm not convinced by the versioning strategy. It seems like rotating the whole sphere is a more invasive change than fixing the UV map. I'd expect that many more files depend on the vertex positions than the UV map values of the sphere's top. I'm not so sure about better options yet.
Only thing why files might be changed is if files depends on indices of mesh. Right now positions looks the same.
Maybe I'm misunderstanding something, but with the current fix and versioning all three (UVMap, index and position) are the same, see the picture below.
With the added benefit that the vertex order follows the cylinder and cone primitives' vertex order.
Just by fixing the UV map and not rotating the sphere, I didn't find a way to achieve all of these.
Small icosphere marks the 1st, small cube the 2nd vertex, 0th is on top, last on bottom.
Note with versioning the old and new UVMap, index and position are identical.
The new has identical UVMap and vertex order with the other primitives e.g. cylinder.
Checkout
From your project repository, check out a new branch and test the changes.