Remove 3D shaders prefix #3876

In Blender 4.0 3D_* shaders are called without "3D_" prefix, otherwise it throws an error. Tested on Blender 3.6 - they work without "3D_" prefix too.
This commit is contained in:
Andrej730
2023-10-31 15:27:43 +05:00
parent 45f2d301b3
commit bbe14834e4
6 changed files with 20 additions and 20 deletions
@@ -62,14 +62,14 @@ class BoundaryDecorator:
gpu.state.point_size_set(6) gpu.state.point_size_set(6)
gpu.state.blend_set("ALPHA") gpu.state.blend_set("ALPHA")
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() # required to be able to change uniforms of the shader self.line_shader.bind() # required to be able to change uniforms of the shader
# POLYLINE_UNIFORM_COLOR specific uniforms # POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0) self.line_shader.uniform_float("lineWidth", 2.0)
# general shader # general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
selected_vertices = [] selected_vertices = []
selected_edges = [] selected_edges = []
@@ -161,9 +161,9 @@ class BaseDecorator:
os.path.join(bpy.context.scene.BIMProperties.data_dir, "fonts", "OpenGost Type B TT.ttf") os.path.join(bpy.context.scene.BIMProperties.data_dir, "fonts", "OpenGost Type B TT.ttf")
) )
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated # POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.base_shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.base_shader = gpu.shader.from_builtin("UNIFORM_COLOR")
def get_camera_width_mm(self): def get_camera_width_mm(self):
# Horrific prototype code to ensure bgl draws at drawing scales # Horrific prototype code to ensure bgl draws at drawing scales
@@ -1563,15 +1563,15 @@ class CutDecorator:
gpu.state.point_size_set(1) gpu.state.point_size_set(1)
gpu.state.blend_set("ALPHA") gpu.state.blend_set("ALPHA")
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated # POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() self.line_shader.bind()
# POLYLINE_UNIFORM_COLOR specific uniforms # POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0) self.line_shader.uniform_float("lineWidth", 2.0)
# general shader # general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
self.shader.bind() self.shader.bind()
black = (0, 0, 0, 1) black = (0, 0, 0, 1)
@@ -1931,7 +1931,7 @@ class DecorationsHandler:
if cls.installed: if cls.installed:
cls.uninstall() cls.uninstall()
handler = cls() handler = cls()
# NOTE: we USE POST_PIXEL here so that we can use both 3D_POLYLINE_UNIFORM_COLOR # NOTE: we USE POST_PIXEL here so that we can use both POLYLINE_UNIFORM_COLOR
# and drawing text in the same handler. BUT this means that we supply coordinates in WINSPACE # and drawing text in the same handler. BUT this means that we supply coordinates in WINSPACE
cls.installed = SpaceView3D.draw_handler_add(handler, (context,), "WINDOW", "POST_PIXEL") cls.installed = SpaceView3D.draw_handler_add(handler, (context,), "WINDOW", "POST_PIXEL")
@@ -288,9 +288,9 @@ class BaseShader:
""" """
def __init__(self): def __init__(self):
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated # POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.base_shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.base_shader = gpu.shader.from_builtin("UNIFORM_COLOR")
def get_shader(self): def get_shader(self):
"""Returns shader for this type""" """Returns shader for this type"""
@@ -191,15 +191,15 @@ class ProfileDecorator:
unselected_edges.append(edge_indices) unselected_edges.append(edge_indices)
### Actually drawing ### Actually drawing
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated # POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() self.line_shader.bind()
# POLYLINE_UNIFORM_COLOR specific uniforms # POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0) self.line_shader.uniform_float("lineWidth", 2.0)
# general shader # general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
self.shader.bind() self.shader.bind()
# Draw faces # Draw faces
@@ -873,14 +873,14 @@ class DecorationsHandler:
if not obj: if not obj:
continue continue
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() # required to be able to change uniforms of the shader self.line_shader.bind() # required to be able to change uniforms of the shader
# POLYLINE_UNIFORM_COLOR specific uniforms # POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0) self.line_shader.uniform_float("lineWidth", 2.0)
# general shader # general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
verts = [] verts = []
selected_edges = [] selected_edges = []
@@ -122,15 +122,15 @@ class SystemDecorator:
selected_vertices = decoration_data["selected_vertices"] selected_vertices = decoration_data["selected_vertices"]
### Actually drawing ### Actually drawing
# 3D_POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated # POLYLINE_UNIFORM_COLOR is good for smoothed lines since `bgl.enable(GL_LINE_SMOOTH)` is deprecated
self.line_shader = gpu.shader.from_builtin("3D_POLYLINE_UNIFORM_COLOR") self.line_shader = gpu.shader.from_builtin("POLYLINE_UNIFORM_COLOR")
self.line_shader.bind() self.line_shader.bind()
# POLYLINE_UNIFORM_COLOR specific uniforms # POLYLINE_UNIFORM_COLOR specific uniforms
self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height)) self.line_shader.uniform_float("viewportSize", (context.region.width, context.region.height))
self.line_shader.uniform_float("lineWidth", 2.0) self.line_shader.uniform_float("lineWidth", 2.0)
# general shader # general shader
self.shader = gpu.shader.from_builtin("3D_UNIFORM_COLOR") self.shader = gpu.shader.from_builtin("UNIFORM_COLOR")
self.shader.bind() self.shader.bind()
self.draw_batch("LINES", all_vertices, transparent_color(unselected_elements_color), unselected_edges) self.draw_batch("LINES", all_vertices, transparent_color(unselected_elements_color), unselected_edges)