Support Blender 5.0
This commit is contained in:
parent
628ccb5ce0
commit
354cc6e952
@ -18,8 +18,8 @@
|
||||
bl_info = {
|
||||
"name": "Symmetrize Texture",
|
||||
"author": "akaneyu",
|
||||
"version": (1, 3, 0),
|
||||
"blender": (3, 3, 0),
|
||||
"version": (1, 4, 0),
|
||||
"blender": (4, 2, 0),
|
||||
"location": "View3D",
|
||||
"warning": "",
|
||||
"description": "",
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
'''
|
||||
Copyright (C) 2020 - 2024 Akaneyu
|
||||
Copyright (C) 2020 - 2025 Akaneyu
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -16,15 +16,12 @@
|
||||
'''
|
||||
|
||||
import gpu
|
||||
from gpu.shader import create_from_info
|
||||
from gpu_extras.batch import batch_for_shader
|
||||
from mathutils import Matrix
|
||||
import numpy as np
|
||||
|
||||
default_vertex_shader = '''
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(pos, 0, 1.0);
|
||||
@ -32,10 +29,6 @@ void main()
|
||||
'''
|
||||
|
||||
default_fragment_shader = '''
|
||||
uniform vec4 color;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragColor = color;
|
||||
@ -43,13 +36,6 @@ void main()
|
||||
'''
|
||||
|
||||
dotted_line_vertex_shader = '''
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
in vec2 pos;
|
||||
in float arcLength;
|
||||
|
||||
out float arcLengthInter;
|
||||
|
||||
void main()
|
||||
{
|
||||
arcLengthInter = arcLength;
|
||||
@ -59,15 +45,6 @@ void main()
|
||||
'''
|
||||
|
||||
dotted_line_fragment_shader = '''
|
||||
uniform float scale;
|
||||
uniform float offset;
|
||||
uniform vec4 color1;
|
||||
uniform vec4 color2;
|
||||
|
||||
in float arcLengthInter;
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (step(sin((arcLengthInter + offset) * scale), 0.5) == 1) {
|
||||
@ -80,12 +57,32 @@ void main()
|
||||
|
||||
class UIRenderer:
|
||||
def __init__(self):
|
||||
self.default_shader = gpu.types.GPUShader(default_vertex_shader,
|
||||
default_fragment_shader)
|
||||
self.default_shader_u_color = self.default_shader.uniform_from_name("color")
|
||||
default_shader_info = gpu.types.GPUShaderCreateInfo()
|
||||
default_shader_info.push_constant('MAT4', 'ModelViewProjectionMatrix')
|
||||
default_shader_info.push_constant('VEC4', 'color')
|
||||
default_shader_info.vertex_in(0, 'VEC2', 'pos')
|
||||
default_shader_info.fragment_out(0, 'VEC4', 'fragColor')
|
||||
default_shader_info.vertex_source(default_vertex_shader)
|
||||
default_shader_info.fragment_source(default_fragment_shader)
|
||||
self.default_shader = create_from_info(default_shader_info)
|
||||
self.default_shader_u_color = self.default_shader.uniform_from_name('color')
|
||||
|
||||
self.dotted_line_shader = gpu.types.GPUShader(dotted_line_vertex_shader,
|
||||
dotted_line_fragment_shader)
|
||||
dotted_line_shader_inter = gpu.types.GPUStageInterfaceInfo("dotted_line")
|
||||
dotted_line_shader_inter.smooth('FLOAT', "arcLengthInter")
|
||||
|
||||
dotted_line_shader_info = gpu.types.GPUShaderCreateInfo()
|
||||
dotted_line_shader_info.push_constant('MAT4', 'ModelViewProjectionMatrix')
|
||||
dotted_line_shader_info.push_constant('FLOAT', 'scale')
|
||||
dotted_line_shader_info.push_constant('FLOAT', 'offset')
|
||||
dotted_line_shader_info.push_constant('VEC4', 'color1')
|
||||
dotted_line_shader_info.push_constant('VEC4', 'color2')
|
||||
dotted_line_shader_info.vertex_in(0, 'VEC2', 'pos')
|
||||
dotted_line_shader_info.vertex_in(1, 'FLOAT', 'arcLength')
|
||||
dotted_line_shader_info.vertex_out(dotted_line_shader_inter)
|
||||
dotted_line_shader_info.fragment_out(0, 'VEC4', 'fragColor')
|
||||
dotted_line_shader_info.vertex_source(dotted_line_vertex_shader)
|
||||
dotted_line_shader_info.fragment_source(dotted_line_fragment_shader)
|
||||
self.dotted_line_shader = create_from_info(dotted_line_shader_info)
|
||||
self.dotted_line_shader_u_color1 = self.dotted_line_shader.uniform_from_name("color1")
|
||||
self.dotted_line_shader_u_color2 = self.dotted_line_shader.uniform_from_name("color2")
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user