Regression: 3D shader 3D_POLYLINE_UNIFORM_COLOR draw error (the need to set all shader uniforms need to be documented) #103176
Labels
No Label
Meta
Good First Issue
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 & Devices
Module
Python API
Module
Rendering & Cycles
Module
Sculpt, Paint & Texture
Module
User Interface
Module
VFX & Video
Priority
High
Priority
Low
Priority
Normal
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Information 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
11 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-manual#103176
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
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?
System Information
Operating system: Windows-10-10.0.22000-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3070 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 526.98
Blender Version
Broken: version: 3.1.1, 3.5
Worked: 3.1.0
Behaviour changed in blender/blender@49fc4449e7
Short description of error
draw shader error
It's normal:
Exact steps for others to reproduce the error
Run the following code block and use the move gizmo. Drag or directly draw errors
Added subscriber: @Guai_Wo_Ge_EMM
blender/blender#87118 was marked as duplicate of this issue
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @PratikPB2123
3D shader 3D_POLYLINE_UNIFORM_COLOR draw errorto Regression: 3D shader 3D_POLYLINE_UNIFORM_COLOR draw errorAdded subscribers: @ideasman42, @lichtwerk
Behaviour changed in blender/blender@49fc4449e7
CC @ideasman42
Said commit removed the drawing with
GPU_SHADER_3D_UNIFORM_COLOR
on the select pass (and instead always draws withGPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
now.P3415 reverts that part (and it seems to work), but havent checked in depth...
Changed status from 'Confirmed' to: 'Archived'
I don't think this is a bug:
lineWidth
andviewportSize
uniforms need to be set.This example works as expected:
@ideasman42 : OK, should this be mentioned in the documentation though ?
Added subscriber: @fclem
@lichtwerk this seems more like a general issue with documentation.
As I understand it the docs should state prominently stated that all uniforms need to be set, failure to do so may use a value from the last user of the uniform (which could be Blender or another script).
@fclem is this the case? or are there exceptions to this rule?
@ideasman42 yes this is correct. There is no exceptions as far as I can remember. But you can use that to you advantage when drawing multiple things with the same shader, changing only the uniforms that need to be changed.
Changed status from 'Archived' to: 'Confirmed'
To not forget about this, will repoen as a TODO for documentation.
Regression: 3D shader 3D_POLYLINE_UNIFORM_COLOR draw errorto Regression: 3D shader 3D_POLYLINE_UNIFORM_COLOR draw error (the need to set all shader uniforms need to be documented)Added subscriber: @Michael-Parkin-White-Apple
As an additional note, since shaders have also been moved to GPUShaderCreateInfo, default uniform values are no longer valid in any case. Some shaders previously assigned default values directly in the uniform declaration. This feature removal was a requirement as this was not possible in Metal, when uniform values are always pulled directly from a GPU buffer or whole data block in the command stream.
Hence, if there are any other cases in Python add-ons which relied on default values being set, these may also no longer work as expected, especially if the default value is non-zero.
Added subscribers: @MikhailRachinskiy, @Solstice245, @mano-wii, @Harley
@lichtwerk Thanks for directing me here. Campbell's short demonstration that they posted above was enough to figure out what I was doing wrong. Stick it in the docs somewhere maybe where people should expect to find that kinda thing ;p
Let me join your conversation.
So now to get anti-aliasing to work we need to complicate draw shader with additional calculations?
Since
gpu.state.blend_set("ALPHA")
works only withPOLYLINE_UNIFORM_COLOR
orPOLYLINE_SMOOTH_COLOR
as I know.Is it heavier than old method?
Also, where we can get this
3D_POLYLINE_UNIFORM_COLOR
? in the docs there is nothing https://docs.blender.org/api/current/gpu.shader.htmlYes, now you need to provide
lineWidth
andviewportSize
uniforms and if you're using custom shader you also need to implement something similar to polylines yourself.I'm not sure if it's heavier after all but now it does create 2 vertex for each line vertex to define line thickness and add some blending for anti-aliasing.
Code for builtins polyline shaders is here - https://projects.blender.org/blender/blender/src/branch/main/source/blender/gpu/shaders
The same way as there is nothing about
3D_UNIFORM_COLOR
.I don't think this should be considered a documentation error.
All builtins shader uniforms are indicated for example in: https://docs.blender.org/api/current/gpu.shader.html#module-gpu.shader
As with any parameter, a coder should already know that not setting a required value can result in undefined behavior.
It is not clear from this report how the documentation should be improved.
A statement at the top of https://docs.blender.org/api/current/gpu.shader.html noting that uniforms are expected to be initialized by the scripts that use them would help.