mirror of
https://github.com/blender/blender-addons.git
synced 2025-08-16 15:35:05 +00:00
Fix #103838: fail to enable Lighting Sun Position addon on Metal
The `Shader` creation needs to be updated using `ShaderCreateInfo`.
This commit is contained in:
@ -16,7 +16,7 @@
|
||||
bl_info = {
|
||||
"name": "Sun Position",
|
||||
"author": "Michael Martin",
|
||||
"version": (3, 2, 0),
|
||||
"version": (3, 2, 1),
|
||||
"blender": (3, 0, 0),
|
||||
"location": "World > Sun Position",
|
||||
"description": "Show sun position with objects and/or sky texture",
|
||||
|
@ -11,14 +11,23 @@ if bpy.app.background: # ignore north line in background mode
|
||||
def north_update(self, context):
|
||||
pass
|
||||
else:
|
||||
vertex_shader = '''
|
||||
uniform mat4 u_ViewProjectionMatrix;
|
||||
shader_info = gpu.types.GPUShaderCreateInfo()
|
||||
shader_interface = gpu.types.GPUStageInterfaceInfo("")
|
||||
shader_interface.flat('VEC2', "v_StartPos")
|
||||
shader_interface.smooth('VEC4', "v_VertPos")
|
||||
|
||||
in vec3 position;
|
||||
|
||||
flat out vec2 v_StartPos;
|
||||
out vec4 v_VertPos;
|
||||
shader_info.push_constant('MAT4', "u_ViewProjectionMatrix")
|
||||
shader_info.push_constant('VEC4', "u_Color")
|
||||
shader_info.push_constant('VEC2', "u_Resolution")
|
||||
shader_info.vertex_in(0, 'VEC3', "position")
|
||||
shader_info.vertex_out(shader_interface)
|
||||
|
||||
shader_info.vertex_source(
|
||||
# uniform mat4 u_ViewProjectionMatrix;
|
||||
# in vec3 position;
|
||||
# flat out vec2 v_StartPos;
|
||||
# out vec4 v_VertPos;
|
||||
'''
|
||||
void main()
|
||||
{
|
||||
vec4 pos = u_ViewProjectionMatrix * vec4(position, 1.0f);
|
||||
@ -26,17 +35,17 @@ else:
|
||||
v_StartPos = (pos / pos.w).xy;
|
||||
v_VertPos = pos;
|
||||
}
|
||||
'''
|
||||
|
||||
fragment_shader = '''
|
||||
uniform vec4 u_Color;
|
||||
|
||||
flat in vec2 v_StartPos;
|
||||
in vec4 v_VertPos;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform vec2 u_Resolution;
|
||||
'''
|
||||
)
|
||||
|
||||
shader_info.fragment_out(0, 'VEC4', "FragColor")
|
||||
shader_info.fragment_source(
|
||||
# uniform vec4 u_Color;
|
||||
# uniform vec2 u_Resolution;
|
||||
# flat in vec2 v_StartPos;
|
||||
# in vec4 v_VertPos;
|
||||
# out vec4 FragColor;
|
||||
'''
|
||||
void main()
|
||||
{
|
||||
vec4 vertPos_2d = v_VertPos / v_VertPos.w;
|
||||
@ -47,9 +56,12 @@ else:
|
||||
|
||||
FragColor = u_Color;
|
||||
}
|
||||
'''
|
||||
'''
|
||||
)
|
||||
|
||||
shader = gpu.types.GPUShader(vertex_shader, fragment_shader)
|
||||
shader = gpu.shader.create_from_info(shader_info)
|
||||
del shader_info
|
||||
del shader_interface
|
||||
|
||||
def draw_north_callback():
|
||||
"""
|
||||
|
Reference in New Issue
Block a user