-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
113 lines (94 loc) · 4.06 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import bpy
import subprocess
import sys
import os
def install_pillow():
try:
# Attempt to import Pillow
import PIL
except ImportError:
# Pillow not installed, install it
# Find Blender's Python executable
python_exe = sys.executable
# Ensure pip is installed and then install Pillow
subprocess.call([python_exe, "-m", "ensurepip"])
subprocess.call([python_exe, "-m", "pip", "install", "Pillow"])
# Call the install function before importing other modules
install_pillow()
# Now import other modules that might depend on Pillow
from .operators import SnapshotOperator, ApplyGreebleTextureOperator, ApplyDepthMapOperator, ScaleUVOperator, SaveTexturesOperator
from .ui import GreebleGeneratorPanel
from bpy.props import StringProperty
bl_info = {
"name": "Greeble Generator",
"author": "2014312728",
"version": (1, 0),
"blender": (3, 5, 0),
"location": "View3D > N Panel > Greeble Tab",
"description": "Generates greebles using Stable Diffusion",
"category": "Object",
}
def update_texture_scale(self, context):
scale_factor = context.scene.greeble_texture_scale
scale_uv(context, scale_factor)
bpy.types.Scene.greeble_texture_scale = bpy.props.FloatProperty(
name="Texture Scale",
description="Scale the texture on the UV map",
default=1.0,
min=0.1,
max=10.0,
update=update_texture_scale
)
bpy.types.Scene.greeble_cfg_scale = bpy.props.FloatProperty(
name="CFG Scale",
description="Conditional Free Guidance Scale for Stable Diffusion",
default=7.0,
min=1.0,
max=30.0,
step=50, # Represents a step of 0.5
)
bpy.types.Scene.greeble_denoising_strength = bpy.props.FloatProperty(
name="Denoising Strength",
description="Strength of denoising for Stable Diffusion",
default=0.80,
min=0.0,
max=1.0
)
def register():
bpy.utils.register_class(SnapshotOperator)
bpy.utils.register_class(GreebleGeneratorPanel)
bpy.utils.register_class(ApplyGreebleTextureOperator)
bpy.utils.register_class(ApplyDepthMapOperator)
bpy.utils.register_class(ScaleUVOperator)
bpy.utils.register_class(SaveTexturesOperator)
bpy.types.Scene.greeble_generator_snapshot_path = StringProperty(
name="Snapshot Path",
description="Path to the snapshot image",
default=""
)
bpy.types.Scene.greeble_generator_prompt = bpy.props.StringProperty(
name="Greeble Prompt",
description="Enter the prompt for the Greeble Generator",
default="grb, mechanical parts, mechanical pistons and parts, hard surface, rigorous detail, precise detail, ultra realistic, highly detailed, sophisticated Generate a high-resolution, detailed texture-like image filled with intricate greebles and sci-fi details. The image should showcase a complex array of mechanical and futuristic elements, with a focus on metallic textures, interlocking geometric shapes, and a monochromatic color scheme with hints of neon blue. The overall mood is futuristic and high-tech, resembling the surface of a sci-fi spaceship or machinery, with a fine balance of shadows and light to enhance the 3D effect of the greebles."
)
# Register the custom property
bpy.types.Scene.greeble_texture_scale = bpy.props.FloatProperty(
name="Texture Scale",
description="Scale the texture on the UV map",
default=1.0,
min=0.1,
max=10.0
)
def unregister():
bpy.utils.unregister_class(SnapshotOperator)
bpy.utils.unregister_class(GreebleGeneratorPanel)
bpy.utils.unregister_class(ApplyGreebleTextureOperator)
bpy.utils.unregister_class(ApplyDepthMapOperator)
bpy.utils.unregister_class(ScaleUVOperator)
bpy.utils.unregister_class(SaveTexturesOperator)
del bpy.types.Scene.greeble_generator_snapshot_path
del bpy.types.Scene.greeble_generator_prompt
# Unregister the custom property
del bpy.types.Scene.greeble_texture_scale
if __name__ == "__main__":
register()