diff options
author | Amir Shehata <amir.shehata> | 2018-12-31 15:38:57 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2018-12-31 15:41:36 +0300 |
commit | 00fc9bddbcf8cef1ebfc29f69166e2d5b919f5dc (patch) | |
tree | e53f996b9ce86a029f5c5fdb6f313ef6ea5aee89 /ant_landscape | |
parent | 75c9dda8224318c56abba1a39687f719eaab2f16 (diff) |
Port 'A.N.T. Landscape' addon to Blender 2.8
Differential Revision: https://developer.blender.org/D4122
Diffstat (limited to 'ant_landscape')
-rw-r--r-- | ant_landscape/__init__.py | 198 | ||||
-rw-r--r-- | ant_landscape/add_mesh_ant_landscape.py | 189 | ||||
-rw-r--r-- | ant_landscape/ant_functions.py | 82 | ||||
-rw-r--r-- | ant_landscape/ant_noise.py | 120 | ||||
-rw-r--r-- | ant_landscape/mesh_ant_displace.py | 175 |
5 files changed, 367 insertions, 397 deletions
diff --git a/ant_landscape/__init__.py b/ant_landscape/__init__.py index 49432e81..b9888d52 100644 --- a/ant_landscape/__init__.py +++ b/ant_landscape/__init__.py @@ -23,7 +23,7 @@ bl_info = { "name": "A.N.T.Landscape", "author": "Jimmy Hazevoet", "version": (0, 1, 8), - "blender": (2, 78, 0), + "blender": (2, 80, 0), "location": "View3D > Tool Shelf", "description": "Another Noise Tool: Landscape and Displace", "warning": "", @@ -75,13 +75,13 @@ def menu_func_landscape(self, context): # Landscape Add Panel -class panel_func_add_landscape(bpy.types.Panel): +class AntLandscapeAddPanel(bpy.types.Panel): bl_idname = "ANTLANDSCAPE_PT_add" bl_space_type = "VIEW_3D" bl_context = "objectmode" - bl_region_type = "TOOLS" + bl_region_type = "UI" bl_label = "Landscape" - bl_category = "Create" + bl_category = "A.N.T. Landscape" bl_options = {'DEFAULT_CLOSED'} def draw(self, context): @@ -94,9 +94,9 @@ class AntLandscapeToolsPanel(bpy.types.Panel): bl_idname = "ANTLANDSCAPE_PT_tools" bl_space_type = "VIEW_3D" bl_context = "objectmode" - bl_region_type = "TOOLS" + bl_region_type = "UI" bl_label = "Landscape Tools" - bl_category = "Tools" + bl_category = "A.N.T. Landscape" bl_options = {'DEFAULT_CLOSED'} @classmethod @@ -412,128 +412,128 @@ class AntDisplaceSettingsPanel(bpy.types.Panel): # Properties group class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): - ant_terrain_name = StringProperty( + ant_terrain_name: StringProperty( name="Name", default="Landscape" ) - land_material = StringProperty( + land_material: StringProperty( name='Material', default="", description="Terrain material" ) - water_material = StringProperty( + water_material: StringProperty( name='Material', default="", description="Water plane material" ) - texture_block = StringProperty( + texture_block: StringProperty( name="Texture", default="" ) - at_cursor = BoolProperty( + at_cursor: BoolProperty( name="Cursor", default=True, description="Place at cursor location", ) - smooth_mesh = BoolProperty( + smooth_mesh: BoolProperty( name="Smooth", default=True, description="Shade smooth" ) - tri_face = BoolProperty( + tri_face: BoolProperty( name="Triangulate", default=False, description="Triangulate faces" ) - sphere_mesh = BoolProperty( + sphere_mesh: BoolProperty( name="Sphere", default=False, description="Generate uv sphere - remove doubles when ready" ) - subdivision_x = IntProperty( + subdivision_x: IntProperty( name="Subdivisions X", default=128, min=4, max=6400, description="Mesh X subdivisions" ) - subdivision_y = IntProperty( + subdivision_y: IntProperty( default=128, name="Subdivisions Y", min=4, max=6400, description="Mesh Y subdivisions" ) - mesh_size = FloatProperty( + mesh_size: FloatProperty( default=2.0, name="Mesh Size", min=0.01, max=100000.0, description="Mesh size" ) - mesh_size_x = FloatProperty( + mesh_size_x: FloatProperty( default=2.0, name="Mesh Size X", min=0.01, description="Mesh x size" ) - mesh_size_y = FloatProperty( + mesh_size_y: FloatProperty( name="Mesh Size Y", default=2.0, min=0.01, description="Mesh y size" ) - random_seed = IntProperty( + random_seed: IntProperty( name="Random Seed", default=0, min=0, description="Randomize noise origin" ) - noise_offset_x = FloatProperty( + noise_offset_x: FloatProperty( name="Offset X", default=0.0, description="Noise X Offset" ) - noise_offset_y = FloatProperty( + noise_offset_y: FloatProperty( name="Offset Y", default=0.0, description="Noise Y Offset" ) - noise_offset_z = FloatProperty( + noise_offset_z: FloatProperty( name="Offset Z", default=0.0, description="Noise Z Offset" ) - noise_size_x = FloatProperty( + noise_size_x: FloatProperty( default=1.0, name="Size X", min=0.01, max=1000.0, description="Noise x size" ) - noise_size_y = FloatProperty( + noise_size_y: FloatProperty( name="Size Y", default=1.0, min=0.01, max=1000.0, description="Noise y size" ) - noise_size_z = FloatProperty( + noise_size_z: FloatProperty( name="Size Z", default=1.0, min=0.01, max=1000.0, description="Noise Z size" ) - noise_size = FloatProperty( + noise_size: FloatProperty( name="Noise Size", default=1.0, min=0.01, max=1000.0, description="Noise size" ) - noise_type = EnumProperty( + noise_type: EnumProperty( name="Noise Type", default='hetero_terrain', description="Noise type", @@ -558,46 +558,26 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17), ('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)] ) - basis_type = EnumProperty( + basis_type: EnumProperty( name="Noise Basis", - default="0", + default=ant_noise.noise_basis_default, description="Noise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - vl_basis_type = EnumProperty( + items = ant_noise.noise_basis + ) + vl_basis_type: EnumProperty( name="vlNoise Basis", - default="0", + default=ant_noise.noise_basis_default, description="VLNoise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - distortion = FloatProperty( + items = ant_noise.noise_basis + ) + distortion: FloatProperty( name="Distortion", default=1.0, min=0.01, max=100.0, description="Distortion amount" ) - hard_noise = EnumProperty( + hard_noise: EnumProperty( name="Soft Hard", default="0", description="Soft Noise, Hard noise", @@ -605,56 +585,56 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("0", "Soft", "Soft Noise", 0), ("1", "Hard", "Hard noise", 1)] ) - noise_depth = IntProperty( + noise_depth: IntProperty( name="Depth", default=8, min=0, max=16, description="Noise Depth - number of frequencies in the fBm" ) - amplitude = FloatProperty( + amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - frequency = FloatProperty( + frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - dimension = FloatProperty( + dimension: FloatProperty( name="Dimension", default=1.0, min=0.01, max=2.0, description="H - fractal dimension of the roughest areas" ) - lacunarity = FloatProperty( + lacunarity: FloatProperty( name="Lacunarity", min=0.01, max=6.0, default=2.0, description="Lacunarity - gap between successive frequencies" ) - offset = FloatProperty( + offset: FloatProperty( name="Offset", default=1.0, min=0.01, max=6.0, description="Offset - raises the terrain from sea level" ) - gain = FloatProperty( + gain: FloatProperty( name="Gain", default=1.0, min=0.01, max=6.0, description="Gain - scale factor" ) - marble_bias = EnumProperty( + marble_bias: EnumProperty( name="Bias", default="0", description="Marble bias", @@ -664,7 +644,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("2", "Tri", "Tri", 2), ("3", "Saw", "Saw", 3)] ) - marble_sharp = EnumProperty( + marble_sharp: EnumProperty( name="Sharp", default="0", description="Marble sharpness", @@ -676,7 +656,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("4", "Sharp inv.", "Sharp", 4), ("5", "Sharper inv.", "Sharper", 5)] ) - marble_shape = EnumProperty( + marble_shape: EnumProperty( name="Shape", default="0", description="Marble shape", @@ -690,33 +670,33 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("6", "Y", "Y", 6), ("7", "X", "X", 7)] ) - height = FloatProperty( + height: FloatProperty( name="Height", default=0.5, min=-10000.0, max=10000.0, description="Noise intensity scale" ) - height_invert = BoolProperty( + height_invert: BoolProperty( name="Invert", default=False, description="Height invert", ) - height_offset = FloatProperty( + height_offset: FloatProperty( name="Offset", default=0.0, min=-10000.0, max=10000.0, description="Height offset" ) - fx_mixfactor = FloatProperty( + fx_mixfactor: FloatProperty( name="Mix Factor", default=0.0, min=-1.0, max=1.0, description="Effect mix factor: -1.0 = Noise, +1.0 = Effect" ) - fx_mix_mode = EnumProperty( + fx_mix_mode: EnumProperty( name="Effect Mix", default="0", description="Effect mix mode", @@ -732,7 +712,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("8", "Max", "Maximum", 8) ] ) - fx_type = EnumProperty( + fx_type: EnumProperty( name="Effect Type", default="0", description="Effect type", @@ -761,7 +741,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("21", "Flat Voronoi", "Flat voronoi", 21) ] ) - fx_bias = EnumProperty( + fx_bias: EnumProperty( name="Effect Bias", default="0", description="Effect bias type", @@ -772,64 +752,64 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("3", "Saw", "Saw", 3), ("4", "None", "None", 4)] ) - fx_turb = FloatProperty( + fx_turb: FloatProperty( name="Distortion", default=0.0, min=0.0, max=1000.0, description="Effect turbulence distortion" ) - fx_depth = IntProperty( + fx_depth: IntProperty( name="Depth", default=0, min=0, max=16, description="Effect depth - number of frequencies" ) - fx_amplitude = FloatProperty( + fx_amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - fx_frequency = FloatProperty( + fx_frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - fx_size = FloatProperty( + fx_size: FloatProperty( name="Effect Size", default=1.0, min=0.01, max=1000.0, description="Effect size" ) - fx_loc_x = FloatProperty( + fx_loc_x: FloatProperty( name="Offset X", default=0.0, description="Effect x offset" ) - fx_loc_y = FloatProperty( + fx_loc_y: FloatProperty( name="Offset Y", default=0.0, description="Effect y offset" ) - fx_height = FloatProperty( + fx_height: FloatProperty( name="Intensity", default=1.0, min=-1000.0, max=1000.0, description="Effect intensity scale" ) - fx_invert = BoolProperty( + fx_invert: BoolProperty( name="Invert", default=False, description="Effect invert" ) - fx_offset = FloatProperty( + fx_offset: FloatProperty( name="Offset", default=0.0, min=-1000.0, @@ -837,7 +817,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): description="Effect height offset" ) - edge_falloff = EnumProperty( + edge_falloff: EnumProperty( name="Falloff", default="3", description="Flatten edges", @@ -847,42 +827,42 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("2", "X", "X Falloff", 2), ("3", "X Y", "X Y Falloff", 3)] ) - falloff_x = FloatProperty( + falloff_x: FloatProperty( name="Falloff X", default=4.0, min=0.1, max=100.0, description="Falloff x scale" ) - falloff_y = FloatProperty( + falloff_y: FloatProperty( name="Falloff Y", default=4.0, min=0.1, max=100.0, description="Falloff y scale" ) - edge_level = FloatProperty( + edge_level: FloatProperty( name="Edge Level", default=0.0, min=-10000.0, max=10000.0, description="Edge level, sealevel offset" ) - maximum = FloatProperty( + maximum: FloatProperty( name="Maximum", default=1.0, min=-10000.0, max=10000.0, description="Maximum, flattens terrain at plateau level" ) - minimum = FloatProperty( + minimum: FloatProperty( name="Minimum", default=-1.0, min=-10000.0, max=10000.0, description="Minimum, flattens terrain at seabed level" ) - vert_group = StringProperty( + vert_group: StringProperty( name="Vertex Group", default="" ) @@ -893,7 +873,7 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): max=1000.0, description="Strata layers / terraces" ) - strata_type = EnumProperty( + strata_type: EnumProperty( name="Strata", default="0", description="Strata types", @@ -905,29 +885,29 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): ("4", "Quantize", "Quantize", 4), ("5", "Quantize Mix", "Quantize mixed", 5)] ) - water_plane = BoolProperty( + water_plane: BoolProperty( name="Water Plane", default=False, description="Add water plane" ) - water_level = FloatProperty( + water_level: FloatProperty( name="Level", default=0.01, min=-10000.0, max=10000.0, description="Water level" ) - remove_double = BoolProperty( + remove_double: BoolProperty( name="Remove Doubles", default=False, description="Remove doubles" ) - refresh = BoolProperty( + refresh: BoolProperty( name="Refresh", default=False, description="Refresh" ) - auto_refresh = BoolProperty( + auto_refresh: BoolProperty( name="Auto", default=True, description="Automatic refresh" @@ -936,15 +916,33 @@ class AntLandscapePropertiesGroup(bpy.types.PropertyGroup): # ------------------------------------------------------------ # Register: +classes = ( + AntLandscapeAddPanel, + AntLandscapeToolsPanel, + AntMainSettingsPanel, + AntNoiseSettingsPanel, + AntDisplaceSettingsPanel, + AntLandscapePropertiesGroup, + add_mesh_ant_landscape.AntAddLandscape, + mesh_ant_displace.AntMeshDisplace, + ant_functions.AntLandscapeRefresh, + ant_functions.AntLandscapeRegenerate, + ant_functions.AntVgSlopeMap, + ant_functions.Eroder, +) + def register(): - bpy.utils.register_module(__name__) + for cls in classes: + bpy.utils.register_class(cls) + bpy.types.VIEW3D_MT_mesh_add.append(menu_func_landscape) bpy.types.Object.ant_landscape = PointerProperty(type=AntLandscapePropertiesGroup, name="ANT_Landscape", description="Landscape properties") bpy.types.VIEW3D_MT_paint_weight.append(menu_func_eroder) def unregister(): - bpy.utils.unregister_module(__name__) + for cls in reversed(classes): + bpy.utils.unregister_class(cls) bpy.types.VIEW3D_MT_mesh_add.remove(menu_func_landscape) bpy.types.VIEW3D_MT_paint_weight.remove(menu_func_eroder) diff --git a/ant_landscape/add_mesh_ant_landscape.py b/ant_landscape/add_mesh_ant_landscape.py index 52afed75..28f89da7 100644 --- a/ant_landscape/add_mesh_ant_landscape.py +++ b/ant_landscape/add_mesh_ant_landscape.py @@ -42,6 +42,8 @@ from .ant_functions import ( draw_ant_water, ) +from ant_landscape import ant_noise + # ------------------------------------------------------------ # Add landscape class AntAddLandscape(bpy.types.Operator): @@ -50,128 +52,128 @@ class AntAddLandscape(bpy.types.Operator): bl_description = "Add landscape mesh" bl_options = {'REGISTER', 'UNDO', 'PRESET'} - ant_terrain_name = StringProperty( + ant_terrain_name: StringProperty( name="Name", default="Landscape" ) - land_material = StringProperty( + land_material: StringProperty( name='Material', default="", description="Terrain material" ) - water_material = StringProperty( + water_material: StringProperty( name='Material', default="", description="Water plane material" ) - texture_block = StringProperty( + texture_block: StringProperty( name="Texture", default="" ) - at_cursor = BoolProperty( + at_cursor: BoolProperty( name="Cursor", default=True, description="Place at cursor location", ) - smooth_mesh = BoolProperty( + smooth_mesh: BoolProperty( name="Smooth", default=True, description="Shade smooth" ) - tri_face = BoolProperty( + tri_face: BoolProperty( name="Triangulate", default=False, description="Triangulate faces" ) - sphere_mesh = BoolProperty( + sphere_mesh: BoolProperty( name="Sphere", default=False, description="Generate uv sphere - remove doubles when ready" ) - subdivision_x = IntProperty( + subdivision_x: IntProperty( name="Subdivisions X", default=128, min=4, max=6400, description="Mesh X subdivisions" ) - subdivision_y = IntProperty( + subdivision_y: IntProperty( default=128, name="Subdivisions Y", min=4, max=6400, description="Mesh Y subdivisions" ) - mesh_size = FloatProperty( + mesh_size: FloatProperty( default=2.0, name="Mesh Size", min=0.01, max=100000.0, description="Mesh size" ) - mesh_size_x = FloatProperty( + mesh_size_x: FloatProperty( default=2.0, name="Mesh Size X", min=0.01, description="Mesh x size" ) - mesh_size_y = FloatProperty( + mesh_size_y: FloatProperty( name="Mesh Size Y", default=2.0, min=0.01, description="Mesh y size" ) - random_seed = IntProperty( + random_seed: IntProperty( name="Random Seed", default=0, min=0, description="Randomize noise origin" ) - noise_offset_x = FloatProperty( + noise_offset_x: FloatProperty( name="Offset X", default=0.0, description="Noise X Offset" ) - noise_offset_y = FloatProperty( + noise_offset_y: FloatProperty( name="Offset Y", default=0.0, description="Noise Y Offset" ) - noise_offset_z = FloatProperty( + noise_offset_z: FloatProperty( name="Offset Z", default=0.0, description="Noise Z Offset" ) - noise_size_x = FloatProperty( + noise_size_x: FloatProperty( default=1.0, name="Size X", min=0.01, max=1000.0, description="Noise x size" ) - noise_size_y = FloatProperty( + noise_size_y: FloatProperty( name="Size Y", default=1.0, min=0.01, max=1000.0, description="Noise y size" ) - noise_size_z = FloatProperty( + noise_size_z: FloatProperty( name="Size Z", default=1.0, min=0.01, max=1000.0, description="Noise Z size" ) - noise_size = FloatProperty( + noise_size: FloatProperty( name="Noise Size", default=1.0, min=0.01, max=1000.0, description="Noise size" ) - noise_type = EnumProperty( + noise_type: EnumProperty( name="Noise Type", default='hetero_terrain', description="Noise type", @@ -196,46 +198,26 @@ class AntAddLandscape(bpy.types.Operator): ('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17), ('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)] ) - basis_type = EnumProperty( + basis_type: EnumProperty( name="Noise Basis", - default="0", + default=ant_noise.noise_basis_default, description="Noise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - vl_basis_type = EnumProperty( + items = ant_noise.noise_basis + ) + vl_basis_type: EnumProperty( name="vlNoise Basis", - default="0", + default=ant_noise.noise_basis_default, description="VLNoise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - distortion = FloatProperty( + items = ant_noise.noise_basis + ) + distortion: FloatProperty( name="Distortion", default=1.0, min=0.01, max=100.0, description="Distortion amount" ) - hard_noise = EnumProperty( + hard_noise: EnumProperty( name="Soft Hard", default="0", description="Soft Noise, Hard noise", @@ -243,56 +225,56 @@ class AntAddLandscape(bpy.types.Operator): ("0", "Soft", "Soft Noise", 0), ("1", "Hard", "Hard noise", 1)] ) - noise_depth = IntProperty( + noise_depth: IntProperty( name="Depth", default=8, min=0, max=16, description="Noise Depth - number of frequencies in the fBm" ) - amplitude = FloatProperty( + amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - frequency = FloatProperty( + frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - dimension = FloatProperty( + dimension: FloatProperty( name="Dimension", default=1.0, min=0.01, max=2.0, description="H - fractal dimension of the roughest areas" ) - lacunarity = FloatProperty( + lacunarity: FloatProperty( name="Lacunarity", min=0.01, max=6.0, default=2.0, description="Lacunarity - gap between successive frequencies" ) - offset = FloatProperty( + offset: FloatProperty( name="Offset", default=1.0, min=0.01, max=6.0, description="Offset - raises the terrain from sea level" ) - gain = FloatProperty( + gain: FloatProperty( name="Gain", default=1.0, min=0.01, max=6.0, description="Gain - scale factor" ) - marble_bias = EnumProperty( + marble_bias: EnumProperty( name="Bias", default="0", description="Marble bias", @@ -302,7 +284,7 @@ class AntAddLandscape(bpy.types.Operator): ("2", "Tri", "Tri", 2), ("3", "Saw", "Saw", 3)] ) - marble_sharp = EnumProperty( + marble_sharp: EnumProperty( name="Sharp", default="0", description="Marble sharpness", @@ -314,7 +296,7 @@ class AntAddLandscape(bpy.types.Operator): ("4", "Sharp inv.", "Sharp", 4), ("5", "Sharper inv.", "Sharper", 5)] ) - marble_shape = EnumProperty( + marble_shape: EnumProperty( name="Shape", default="0", description="Marble shape", @@ -328,33 +310,33 @@ class AntAddLandscape(bpy.types.Operator): ("6", "Y", "Y", 6), ("7", "X", "X", 7)] ) - height = FloatProperty( + height: FloatProperty( name="Height", default=0.5, min=-10000.0, max=10000.0, description="Noise intensity scale" ) - height_invert = BoolProperty( + height_invert: BoolProperty( name="Invert", default=False, description="Height invert", ) - height_offset = FloatProperty( + height_offset: FloatProperty( name="Offset", default=0.0, min=-10000.0, max=10000.0, description="Height offset" ) - fx_mixfactor = FloatProperty( + fx_mixfactor: FloatProperty( name="Mix Factor", default=0.0, min=-1.0, max=1.0, description="Effect mix factor: -1.0 = Noise, +1.0 = Effect" ) - fx_mix_mode = EnumProperty( + fx_mix_mode: EnumProperty( name="Effect Mix", default="0", description="Effect mix mode", @@ -370,7 +352,7 @@ class AntAddLandscape(bpy.types.Operator): ("8", "Max", "Maximum", 8) ] ) - fx_type = EnumProperty( + fx_type: EnumProperty( name="Effect Type", default="0", description="Effect type", @@ -399,7 +381,7 @@ class AntAddLandscape(bpy.types.Operator): ("21", "Flat Voronoi", "Flat voronoi", 21) ] ) - fx_bias = EnumProperty( + fx_bias: EnumProperty( name="Effect Bias", default="0", description="Effect bias type", @@ -410,64 +392,64 @@ class AntAddLandscape(bpy.types.Operator): ("3", "Saw", "Saw", 3), ("4", "None", "None", 4)] ) - fx_turb = FloatProperty( + fx_turb: FloatProperty( name="Distortion", default=0.0, min=0.0, max=1000.0, description="Effect turbulence distortion" ) - fx_depth = IntProperty( + fx_depth: IntProperty( name="Depth", default=0, min=0, max=16, description="Effect depth - number of frequencies" ) - fx_amplitude = FloatProperty( + fx_amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - fx_frequency = FloatProperty( + fx_frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - fx_size = FloatProperty( + fx_size: FloatProperty( name="Effect Size", default=1.0, min=0.01, max=1000.0, description="Effect size" ) - fx_loc_x = FloatProperty( + fx_loc_x: FloatProperty( name="Offset X", default=0.0, description="Effect x offset" ) - fx_loc_y = FloatProperty( + fx_loc_y: FloatProperty( name="Offset Y", default=0.0, description="Effect y offset" ) - fx_height = FloatProperty( + fx_height: FloatProperty( name="Intensity", default=1.0, min=-1000.0, max=1000.0, description="Effect intensity scale" ) - fx_invert = BoolProperty( + fx_invert: BoolProperty( name="Invert", default=False, description="Effect invert" ) - fx_offset = FloatProperty( + fx_offset: FloatProperty( name="Offset", default=0.0, min=-1000.0, @@ -475,7 +457,7 @@ class AntAddLandscape(bpy.types.Operator): description="Effect height offset" ) - edge_falloff = EnumProperty( + edge_falloff: EnumProperty( name="Falloff", default="3", description="Flatten edges", @@ -485,53 +467,53 @@ class AntAddLandscape(bpy.types.Operator): ("2", "X", "X Falloff", 2), ("3", "X Y", "X Y Falloff", 3)] ) - falloff_x = FloatProperty( + falloff_x: FloatProperty( name="Falloff X", default=4.0, min=0.1, max=100.0, description="Falloff x scale" ) - falloff_y = FloatProperty( + falloff_y: FloatProperty( name="Falloff Y", default=4.0, min=0.1, max=100.0, description="Falloff y scale" ) - edge_level = FloatProperty( + edge_level: FloatProperty( name="Edge Level", default=0.0, min=-10000.0, max=10000.0, description="Edge level, sealevel offset" ) - maximum = FloatProperty( + maximum: FloatProperty( name="Maximum", default=1.0, min=-10000.0, max=10000.0, description="Maximum, flattens terrain at plateau level" ) - minimum = FloatProperty( + minimum: FloatProperty( name="Minimum", default=-1.0, min=-10000.0, max=10000.0, description="Minimum, flattens terrain at seabed level" ) - vert_group = StringProperty( + vert_group: StringProperty( name="Vertex Group", default="" ) - strata = FloatProperty( + strata: FloatProperty( name="Amount", default=5.0, min=0.01, max=1000.0, description="Strata layers / terraces" ) - strata_type = EnumProperty( + strata_type: EnumProperty( name="Strata", default="0", description="Strata types", @@ -543,44 +525,44 @@ class AntAddLandscape(bpy.types.Operator): ("4", "Quantize", "Quantize", 4), ("5", "Quantize Mix", "Quantize mixed", 5)] ) - water_plane = BoolProperty( + water_plane: BoolProperty( name="Water Plane", default=False, description="Add water plane" ) - water_level = FloatProperty( + water_level: FloatProperty( name="Level", default=0.01, min=-10000.0, max=10000.0, description="Water level" ) - remove_double = BoolProperty( + remove_double: BoolProperty( name="Remove Doubles", default=False, description="Remove doubles" ) - show_main_settings = BoolProperty( + show_main_settings: BoolProperty( name="Main Settings", default=True, description="Show settings" ) - show_noise_settings = BoolProperty( + show_noise_settings: BoolProperty( name="Noise Settings", default=True, description="Show noise settings" ) - show_displace_settings = BoolProperty( + show_displace_settings: BoolProperty( name="Displace Settings", default=True, description="Show displace settings" ) - refresh = BoolProperty( + refresh: BoolProperty( name="Refresh", default=False, description="Refresh" ) - auto_refresh = BoolProperty( + auto_refresh: BoolProperty( name="Auto", default=True, description="Automatic refresh" @@ -689,6 +671,7 @@ class AntAddLandscape(bpy.types.Operator): ] scene = context.scene + vl = context.view_layer # Main function, create landscape mesh object if self.ant_terrain_name != "": @@ -709,7 +692,7 @@ class AntAddLandscape(bpy.types.Operator): ) new_ob = create_mesh_object(context, verts, [], faces, new_name) if self.remove_double: - new_ob.select = True + new_ob.select_set(True) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False) bpy.ops.object.mode_set(mode = 'OBJECT') @@ -727,7 +710,7 @@ class AntAddLandscape(bpy.types.Operator): ) new_ob = create_mesh_object(context, verts, [], faces, new_name) - new_ob.select = True + new_ob.select_set(True) if self.smooth_mesh: bpy.ops.object.shade_smooth() @@ -755,7 +738,7 @@ class AntAddLandscape(bpy.types.Operator): ) wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane") if self.remove_double: - wobj.select = True + wobj.select_set(True) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False) bpy.ops.object.mode_set(mode = 'OBJECT') @@ -773,7 +756,7 @@ class AntAddLandscape(bpy.types.Operator): ) wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane") - wobj.select = True + wobj.select_set(True) if self.smooth_mesh: bpy.ops.object.shade_smooth() @@ -787,10 +770,10 @@ class AntAddLandscape(bpy.types.Operator): bpy.context.object.data.materials.append(mat) # select landscape and make active - new_ob.select = True - scene.objects.active = new_ob.object + new_ob.select_set(True) + vl.objects.active = new_ob # - new_ob = store_properties(self, new_ob.object) + new_ob = store_properties(self, new_ob) if self.auto_refresh is False: self.refresh = False diff --git a/ant_landscape/ant_functions.py b/ant_landscape/ant_functions.py index 71dbde72..c815b720 100644 --- a/ant_landscape/ant_functions.py +++ b/ant_landscape/ant_functions.py @@ -232,7 +232,7 @@ class AntLandscapeRegenerate(bpy.types.Operator): ) new_ob = create_mesh_object(context, verts, [], faces, new_name).object if ob['remove_double']: - new_ob.select = True + new_ob.select_set(True) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False) bpy.ops.object.mode_set(mode = 'OBJECT') @@ -250,7 +250,7 @@ class AntLandscapeRegenerate(bpy.types.Operator): ) new_ob = create_mesh_object(context, verts, [], faces, new_name).object - new_ob.select = True + new_ob.select_set(True) if ob['smooth_mesh']: bpy.ops.object.shade_smooth() @@ -275,7 +275,7 @@ class AntLandscapeRegenerate(bpy.types.Operator): ) wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane").object if ob['remove_double']: - wobj.select = True + wobj.select_set(True) bpy.ops.object.mode_set(mode = 'EDIT') bpy.ops.mesh.remove_doubles(threshold=0.0001, use_unselected=False) bpy.ops.object.mode_set(mode = 'OBJECT') @@ -293,7 +293,7 @@ class AntLandscapeRegenerate(bpy.types.Operator): ) wobj = create_mesh_object(context, verts, [], faces, new_name+"_plane").object - wobj.select = True + wobj.select_set(True) if ob['smooth_mesh']: bpy.ops.object.shade_smooth() @@ -308,7 +308,7 @@ class AntLandscapeRegenerate(bpy.types.Operator): wobj.location = obj.location wobj.rotation_euler = obj.rotation_euler wobj.scale = obj.scale - wobj.select = False + wobj.select_set(False) new_ob.location = obj.location new_ob.rotation_euler = obj.rotation_euler @@ -318,14 +318,14 @@ class AntLandscapeRegenerate(bpy.types.Operator): new_ob = store_properties(ob, new_ob) # Delete old object - new_ob.select = False + new_ob.select_set(False) - obj.select = True + obj.select_set(True) scene.objects.active = obj bpy.ops.object.delete(use_global=False) # Select landscape and make active - new_ob.select = True + new_ob.select_set(True) scene.objects.active = new_ob # restore pre operator undo state @@ -342,24 +342,24 @@ class AntVgSlopeMap(bpy.types.Operator): bl_description = "A.N.T. Slope Map - z normal value to vertex group weight" bl_options = {'REGISTER', 'UNDO'} - z_method = EnumProperty( + z_method: EnumProperty( name="Method:", default='SLOPE_Z', items=[ ('SLOPE_Z', "Z Slope", "Slope for planar mesh"), ('SLOPE_XYZ', "Sphere Slope", "Slope for spherical mesh") ]) - group_name = StringProperty( + group_name: StringProperty( name="Vertex Group Name:", default="Slope", description="Name" ) - select_flat = BoolProperty( + select_flat: BoolProperty( name="Vert Select:", default=True, description="Select vertices on flat surface" ) - select_range = FloatProperty( + select_range: FloatProperty( name="Vert Select Range:", default=0.0, min=0.0, @@ -406,7 +406,7 @@ class AntVgSlopeMap(bpy.types.Operator): if self.select_flat: if zval >= (1.0 - self.select_range): - v.select = True + v.select_set(True) vg_normal.name = self.group_name @@ -438,8 +438,8 @@ def draw_ant_main(self, context, generate=True): if generate: row = box.row(align=True) split = row.split(align=True) - split.prop(self, "at_cursor", toggle=True, icon_only=True, icon='CURSOR') - split.prop(self, "smooth_mesh", toggle=True, icon_only=True, icon='SOLID') + split.prop(self, "at_cursor", toggle=True, icon_only=True, icon='PIVOT_CURSOR') + split.prop(self, "smooth_mesh", toggle=True, icon_only=True, icon='SHADING_SOLID') split.prop(self, "tri_face", toggle=True, icon_only=True, icon='MESH_DATA') if not self.sphere_mesh: @@ -447,7 +447,7 @@ def draw_ant_main(self, context, generate=True): row.prop(self, "sphere_mesh", toggle=True) else: row = box.row(align=True) - split = row.split(0.5, align=True) + split = row.split(factor=0.5, align=True) split.prop(self, "sphere_mesh", toggle=True) split.prop(self, "remove_double", toggle=True) @@ -636,7 +636,7 @@ def draw_ant_noise(self, context, generate=True): col.prop(self, "fx_turb") col = box.column(align=True) - row = col.row(align=True).split(0.92, align=True) + row = col.row(align=True).split(factor=0.92, align=True) row.prop(self, "fx_height") row.prop(self, "fx_invert", toggle=True, text="", icon='ARROW_LEFTRIGHT') col.prop(self, "fx_offset") @@ -652,7 +652,7 @@ def draw_ant_displace(self, context, generate=True): col.prop(self, "direction", toggle=True) col = box.column(align=True) - row = col.row(align=True).split(0.92, align=True) + row = col.row(align=True).split(factor=0.92, align=True) row.prop(self, "height") row.prop(self, "height_invert", toggle=True, text="", icon='ARROW_LEFTRIGHT') col.prop(self, "height_offset") @@ -785,49 +785,49 @@ class Eroder(bpy.types.Operator): bl_description = "Apply various kinds of erosion to a square ANT-Landscape grid. Also available in Weight Paint mode > Weights menu" bl_options = {'REGISTER', 'UNDO', 'PRESET'} - Iterations = IntProperty( + Iterations: IntProperty( name="Iterations", description="Number of overall iterations", default=1, min=1, soft_max=100 ) - IterRiver = IntProperty( + IterRiver: IntProperty( name="River Iterations", description="Number of river iterations", default=30, min=1, soft_max=1000 ) - IterAva = IntProperty( + IterAva: IntProperty( name="Avalanche Iterations", description="Number of avalanche iterations", default=5, min=1, soft_max=10 ) - IterDiffuse = IntProperty( + IterDiffuse: IntProperty( name="Diffuse Iterations", description="Number of diffuse iterations", default=5, min=1, soft_max=10 ) - Ef = FloatProperty( + Ef: FloatProperty( name="Rain on Plains", description="1 gives equal rain across the terrain, 0 rains more at the mountain tops", default=0.0, min=0, max=1 ) - Kd = FloatProperty( + Kd: FloatProperty( name="Kd", description="Thermal diffusion rate (1.0 is a fairly high rate)", default=0.1, min=0, soft_max=100 ) - Kt = FloatProperty( + Kt: FloatProperty( name="Kt", description="Maximum stable talus angle", default=radians(60), @@ -835,7 +835,7 @@ class Eroder(bpy.types.Operator): max=radians(90), subtype='ANGLE' ) - Kr = FloatProperty( + Kr: FloatProperty( name="Rain amount", description="Total Rain amount", default=.01, @@ -843,96 +843,96 @@ class Eroder(bpy.types.Operator): soft_max=1, precision=3 ) - Kv = FloatProperty( + Kv: FloatProperty( name="Rain variance", description="Rain variance (0 is constant, 1 is uniform)", default=0, min=0, max=1 ) - userainmap = BoolProperty( + userainmap: BoolProperty( name="Use rain map", description="Use active vertex group as a rain map", default=True ) - Ks = FloatProperty( + Ks: FloatProperty( name="Soil solubility", description="Soil solubility - how quickly water quickly reaches saturation point", default=0.5, min=0, soft_max=1 ) - Kdep = FloatProperty( + Kdep: FloatProperty( name="Deposition rate", description="Sediment deposition rate - how quickly silt is laid down once water stops flowing quickly", default=0.1, min=0, soft_max=1 ) - Kz = FloatProperty(name="Fluvial Erosion Rate", + Kz: FloatProperty(name="Fluvial Erosion Rate", description="Amount of sediment moved each main iteration - if 0, then rivers are formed but the mesh is not changed", default=0.3, min=0, soft_max=20 ) - Kc = FloatProperty( + Kc: FloatProperty( name="Carrying capacity", description="Base sediment carrying capacity", default=0.9, min=0, soft_max=1 ) - Ka = FloatProperty( + Ka: FloatProperty( name="Slope dependence", description="Slope dependence of carrying capacity (not used)", default=1.0, min=0, soft_max=2 ) - Kev = FloatProperty( + Kev: FloatProperty( name="Evaporation", description="Evaporation Rate per grid square in % - causes sediment to be dropped closer to the hills", default=.5, min=0, soft_max=2 ) - numexpr = BoolProperty( + numexpr: BoolProperty( name="Numexpr", description="Use numexpr module (if available)", default=True ) - Pd = FloatProperty( + Pd: FloatProperty( name="Diffusion Amount", description="Diffusion probability", default=0.2, min=0, max=1 ) - Pa = FloatProperty( + Pa: FloatProperty( name="Avalanche Amount", description="Avalanche amount", default=0.5, min=0, max=1 ) - Pw = FloatProperty( + Pw: FloatProperty( name="River Amount", description="Water erosion probability", default=1, min=0, max=1 ) - smooth = BoolProperty( + smooth: BoolProperty( name="Smooth", description="Set smooth shading", default=True ) - showiterstats = BoolProperty( + showiterstats: BoolProperty( name="Iteration Stats", description="Show iteraration statistics", default=False ) - showmeshstats = BoolProperty(name="Mesh Stats", + showmeshstats: BoolProperty(name="Mesh Stats", description="Show mesh statistics", default=False ) diff --git a/ant_landscape/ant_noise.py b/ant_landscape/ant_noise.py index fdec9b87..d9f13483 100644 --- a/ant_landscape/ant_noise.py +++ b/ant_landscape/ant_noise.py @@ -39,6 +39,20 @@ from math import ( sin, cos, pi, ) +noise_basis_default = "PERLIN_ORIGINAL" +noise_basis = [ + ("BLENDER", "Blender", "Blender default noise", 0), + ("PERLIN_ORIGINAL", "Perlin", "Perlin noise", 1), + ("PERLIN_NEW", "New Perlin", "New Perlin noise", 2), + ("VORONOI_F1", "Voronoi F1", "Voronoi F1", 3), + ("VORONOI_F2", "Voronoi F2", "Voronoi F2", 4), + ("VORONOI_F3", "Voronoi F3", "Voronoi F3", 5), + ("VORONOI_F4", "Voronoi F4", "Voronoi F4", 6), + ("VORONOI_F2F1", "Voronoi F2-F1", "Voronoi F2-F1", 7), + ("VORONOI_CRACKLE", "Voronoi Crackle", "Voronoi Crackle", 8), + ("CELLNOISE", "Cell Noise", "Cell noise", 9) +] + # ------------------------------------------------------------ # Height scale: def Height_Scale(input, iscale, offset, invert): @@ -138,7 +152,7 @@ def marble_noise(x, y, z, origin, size, shape, bias, sharpnes, turb, depth, hard x += origin[0] y += origin[1] z += origin[2] - value = s + turb * turbulence_vector((x, y, z), depth, hard, basis)[1] + value = s + turb * turbulence_vector((x, y, z), depth, hard, noise_basis=basis)[1] if bias is 1: value = cos_bias(value) @@ -169,10 +183,10 @@ def marble_noise(x, y, z, origin, size, shape, bias, sharpnes, turb, depth, hard def vlnTurbMode(coords, distort, basis, vlbasis, hardnoise): # hard noise if hardnoise: - return (abs(-variable_lacunarity(coords, distort, basis, vlbasis))) + return (abs(-variable_lacunarity(coords, distort, noise_type1=basis, noise_type2=vlbasis))) # soft noise else: - return variable_lacunarity(coords, distort, basis, vlbasis) + return variable_lacunarity(coords, distort, noise_type1=basis, noise_type2=vlbasis) def vl_noise_turbulence(coords, distort, depth, basis, vlbasis, hardnoise, amp, freq): @@ -188,86 +202,86 @@ def vl_noise_turbulence(coords, distort, depth, basis, vlbasis, hardnoise, amp, ## duo_multiFractal: def double_multiFractal(coords, H, lacunarity, octaves, offset, gain, basis, vlbasis): x, y, z = coords - n1 = multi_fractal((x * 1.5 + 1, y * 1.5 + 1, z * 1.5 + 1), 1.0, 1.0, 1.0, basis) * (offset * 0.5) - n2 = multi_fractal((x - 1, y - 1, z - 1), H, lacunarity, octaves, vlbasis) * (gain * 0.5) + n1 = multi_fractal((x * 1.5 + 1, y * 1.5 + 1, z * 1.5 + 1), 1.0, 1.0, 1.0, noise_basis=basis) * (offset * 0.5) + n2 = multi_fractal((x - 1, y - 1, z - 1), H, lacunarity, octaves, noise_basis=vlbasis) * (gain * 0.5) return (n1 * n1 + n2 * n2) * 0.5 ## distorted_heteroTerrain: def distorted_heteroTerrain(coords, H, lacunarity, octaves, offset, distort, basis, vlbasis): x, y, z = coords - h1 = (hetero_terrain((x, y, z), 1.0, 2.0, 1.0, 1.0, basis) * 0.5) + h1 = (hetero_terrain((x, y, z), 1.0, 2.0, 1.0, 1.0, noise_basis=basis) * 0.5) d = h1 * distort - h2 = (hetero_terrain((x + d, y + d, z + d), H, lacunarity, octaves, offset, vlbasis) * 0.25) + h2 = (hetero_terrain((x + d, y + d, z + d), H, lacunarity, octaves, offset, noise_basis=vlbasis) * 0.25) return (h1 * h1 + h2 * h2) * 0.5 ## SlickRock: def slick_rock(coords, H, lacunarity, octaves, offset, gain, distort, basis, vlbasis): x, y, z = coords - n = multi_fractal((x,y,z), 1.0, 2.0, 2.0, basis) * distort * 0.25 - r = ridged_multi_fractal((x + n, y + n, z + n), H, lacunarity, octaves, offset + 0.1, gain * 2, vlbasis) + n = multi_fractal((x,y,z), 1.0, 2.0, 2.0, noise_basis=basis) * distort * 0.25 + r = ridged_multi_fractal((x + n, y + n, z + n), H, lacunarity, octaves, offset + 0.1, gain * 2, noise_basis=vlbasis) return (n + (n * r)) * 0.5 ## vlhTerrain def vl_hTerrain(coords, H, lacunarity, octaves, offset, basis, vlbasis, distort): x, y, z = coords - ht = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, basis ) * 0.25 - vl = ht * variable_lacunarity((x, y, z), distort, basis, vlbasis) * 0.5 + 0.5 + ht = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, noise_basis=basis ) * 0.25 + vl = ht * variable_lacunarity((x, y, z), distort, noise_type1=basis, noise_type2=vlbasis) * 0.5 + 0.5 return vl * ht # another turbulence def ant_turbulence(coords, depth, hardnoise, nbasis, amp, freq, distortion): x, y, z = coords - t = turbulence_vector((x/2, y/2, z/2), depth, 0, nbasis, amp, freq) * 0.5 * distortion - return turbulence((t[0], t[1], t[2]), 2, hardnoise, 3) * 0.5 + 0.5 + t = turbulence_vector((x/2, y/2, z/2), depth, 0, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq) * 0.5 * distortion + return turbulence((t[0], t[1], t[2]), 2, hardnoise, noise_basis="VORONOI_F1") * 0.5 + 0.5 # rocks noise def rocks_noise(coords, depth, hardnoise, nbasis, distortion): x,y,z = coords - p = turbulence((x, y, z), 4, 0, 0) * 0.125 * distortion + p = turbulence((x, y, z), 4, 0, noise_basis='BLENDER') * 0.125 * distortion xx, yy, zz = x, y, z - a = turbulence((xx + p, yy + p, zz), 2, 0, 7) + a = turbulence((xx + p, yy + p, zz), 2, 0, noise_basis='VORONOI_F2F1') pa = a * 0.1875 * distortion - b = turbulence((x, y, z + pa), depth, hardnoise, nbasis) + b = turbulence((x, y, z + pa), depth, hardnoise, noise_basis=nbasis) return ((a + 0.5 * (b - a)) * 0.5 + 0.5) # shattered_hterrain: def shattered_hterrain(coords, H, lacunarity, octaves, offset, distort, basis): x, y, z = coords - d = (turbulence_vector(coords, 6, 0, 0)[0] * 0.5 + 0.5) * distort * 0.5 - t1 = (turbulence_vector((x + d, y + d, z + d), 0, 0, 7)[0] + 0.5) - t2 = (hetero_terrain((x * 2, y * 2, z * 2), H, lacunarity, octaves, offset, basis) * 0.5) + d = (turbulence_vector(coords, 6, 0)[0] * 0.5 + 0.5) * distort * 0.5 + t1 = (turbulence_vector((x + d, y + d, z + d), 0, 0, noise_basis='VORONOI_F2F1')[0] + 0.5) + t2 = (hetero_terrain((x * 2, y * 2, z * 2), H, lacunarity, octaves, offset, noise_basis=basis) * 0.5) return ((t1 * t2) + t2 * 0.5) * 0.5 # strata_hterrain def strata_hterrain(coords, H, lacunarity, octaves, offset, distort, basis): x, y, z = coords - value = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, basis) * 0.5 + value = hetero_terrain((x, y, z), H, lacunarity, octaves, offset, noise_basis=basis) * 0.5 steps = (sin(value * (distort * 5) * pi) * (0.1 / (distort * 5) * pi)) return (value * (1.0 - 0.5) + steps * 0.5) # Planet Noise by: Farsthary # https://farsthary.com/2010/11/24/new-planet-procedural-texture/ -def planet_noise(coords, oct=6, hard=0, noisebasis=1, nabla=0.001): +def planet_noise(coords, oct=6, hard=0, noisebasis='PERLIN_ORIGINAL', nabla=0.001): x, y, z = coords d = 0.001 offset = nabla * 1000 - x = turbulence((x, y, z), oct, hard, noisebasis) - y = turbulence((x + offset, y, z), oct, hard, noisebasis) - z = turbulence((x, y + offset, z), oct, hard, noisebasis) - xdy = x - turbulence((x, y + d, z), oct, hard, noisebasis) - xdz = x - turbulence((x, y, z + d), oct, hard, noisebasis) - ydx = y - turbulence((x + d, y, z), oct, hard, noisebasis) - ydz = y - turbulence((x, y, z + d), oct, hard, noisebasis) - zdx = z - turbulence((x + d, y, z), oct, hard, noisebasis) - zdy = z - turbulence((x, y + d, z), oct, hard, noisebasis) + x = turbulence((x, y, z), oct, hard, noise_basis=noisebasis) + y = turbulence((x + offset, y, z), oct, hard, noise_basis=noisebasis) + z = turbulence((x, y + offset, z), oct, hard, noise_basis=noisebasis) + xdy = x - turbulence((x, y + d, z), oct, hard, noise_basis=noisebasis) + xdz = x - turbulence((x, y, z + d), oct, hard, noise_basis=noisebasis) + ydx = y - turbulence((x + d, y, z), oct, hard, noise_basis=noisebasis) + ydz = y - turbulence((x, y, z + d), oct, hard, noise_basis=noisebasis) + zdx = z - turbulence((x + d, y, z), oct, hard, noise_basis=noisebasis) + zdy = z - turbulence((x, y + d, z), oct, hard, noise_basis=noisebasis) return (zdy - ydz), (zdx - xdz), (ydx - xdy) @@ -388,51 +402,51 @@ def Effect_Basis_Function(coords, type, bias): effect = offset + iscale * effect ## crackle: elif type == 13: - t = turbulence((x, y, 0), 6, 0, 0) * 0.25 - effect = variable_lacunarity((x, y, t), 0.25, 0, 8) + t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER") * 0.25 + effect = variable_lacunarity((x, y, t), 0.25, noise_type2='VORONOI_CRACKLE') if effect > 0.5: effect = 0.5 effect = offset + iscale * effect ## sparse cracks noise: elif type == 14: - effect = 2.5 * abs(noise((x, y, 0), 1)) - 0.1 + effect = 2.5 * abs(noise((x, y, 0), noise_basis="PERLIN_ORIGINAL")) - 0.1 if effect > 0.25: effect = 0.25 effect = offset + iscale * (effect * 2.5) ## shattered rock noise: elif type == 15: - effect = 0.5 + noise((x, y, 0), 7) + effect = 0.5 + noise((x, y, 0), noise_basis="VORONOI_F2F1") if effect > 0.75: effect = 0.75 effect = offset + iscale * effect ## lunar noise: elif type == 16: - effect = 0.25 + 1.5 * voronoi((x, y, 0), 1)[0][0] + effect = 0.25 + 1.5 * voronoi((x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0] if effect > 0.5: effect = 0.5 effect = offset + iscale * effect * 2 ## cosine noise: elif type == 17: - effect = cos(5 * noise((x, y, 0), 0)) + effect = cos(5 * noise((x, y, 0), noise_basis="BLENDER")) effect = offset + iscale * (effect * 0.5) ## spikey noise: elif type == 18: - n = 0.5 + 0.5 * turbulence((x * 5, y * 5, 0), 8, 0, 0) + n = 0.5 + 0.5 * turbulence((x * 5, y * 5, 0), 8, 0, noise_basis="BLENDER") effect = ((n * n)**5) effect = offset + iscale * effect ## stone noise: elif type == 19: - effect = offset + iscale * (noise((x * 2, y * 2, 0), 0) * 1.5 - 0.75) + effect = offset + iscale * (noise((x * 2, y * 2, 0), noise_basis="BLENDER") * 1.5 - 0.75) ## Flat Turb: elif type == 20: - t = turbulence((x, y, 0), 6, 0, 0) + t = turbulence((x, y, 0), 6, 0, noise_basis="BLENDER") effect = t * 2.0 if effect > 0.25: effect = 0.25 effect = offset + iscale * effect ## Flat Voronoi: elif type == 21: - t = 1 - voronoi((x, y, 0), 1)[0][0] + t = 1 - voronoi((x, y, 0), distance_metric='DISTANCE_SQUARED')[0][0] effect = t * 2 - 1.5 if effect > 0.25: effect = 0.25 @@ -452,7 +466,7 @@ def Effect_Function(coords, type, bias, turb, depth, frequency, amplitude): x, y, z = coords ## turbulence: if turb > 0.0: - t = turb * ( 0.5 + 0.5 * turbulence(coords, 6, 0, 0)) + t = turb * ( 0.5 + 0.5 * turbulence(coords, 6, 0, noise_basis="BLENDER")) x = x + t y = y + t z = z + t @@ -496,8 +510,8 @@ def noise_gen(coords, props): size_z = props[19] nsize = props[20] ntype = props[21] - nbasis = int(props[22]) - vlbasis = int(props[23]) + nbasis = props[22] + vlbasis = props[23] distortion = props[24] hardnoise = int(props[25]) depth = props[26] @@ -563,33 +577,27 @@ def noise_gen(coords, props): ncoords = (x / (nsize * size_x) + origin_x, y / (nsize * size_y) + origin_y, z / (nsize * size_z) + origin_z) - # Noise basis type's - if nbasis == 9: - nbasis = 14 # Cellnoise - if vlbasis == 9: - vlbasis = 14 - # Noise type's if ntype in [0, 'multi_fractal']: - value = multi_fractal(ncoords, dimension, lacunarity, depth, nbasis) * 0.5 + value = multi_fractal(ncoords, dimension, lacunarity, depth, noise_basis=nbasis) * 0.5 elif ntype in [1, 'ridged_multi_fractal']: - value = ridged_multi_fractal(ncoords, dimension, lacunarity, depth, offset, gain, nbasis) * 0.5 + value = ridged_multi_fractal(ncoords, dimension, lacunarity, depth, offset, gain, noise_basis=nbasis) * 0.5 elif ntype in [2, 'hybrid_multi_fractal']: - value = hybrid_multi_fractal(ncoords, dimension, lacunarity, depth, offset, gain, nbasis) * 0.5 + value = hybrid_multi_fractal(ncoords, dimension, lacunarity, depth, offset, gain, noise_basis=nbasis) * 0.5 elif ntype in [3, 'hetero_terrain']: - value = hetero_terrain(ncoords, dimension, lacunarity, depth, offset, nbasis) * 0.25 + value = hetero_terrain(ncoords, dimension, lacunarity, depth, offset, noise_basis=nbasis) * 0.25 elif ntype in [4, 'fractal']: - value = fractal(ncoords, dimension, lacunarity, depth, nbasis) + value = fractal(ncoords, dimension, lacunarity, depth, noise_basis=nbasis) elif ntype in [5, 'turbulence_vector']: - value = turbulence_vector(ncoords, depth, hardnoise, nbasis, amp, freq)[0] + value = turbulence_vector(ncoords, depth, hardnoise, noise_basis=nbasis, amplitude_scale=amp, frequency_scale=freq)[0] elif ntype in [6, 'variable_lacunarity']: - value = variable_lacunarity(ncoords, distortion, nbasis, vlbasis) + value = variable_lacunarity(ncoords, distortion, noise_type1=nbasis, noise_type2=vlbasis) elif ntype in [7, 'marble_noise']: value = marble_noise( diff --git a/ant_landscape/mesh_ant_displace.py b/ant_landscape/mesh_ant_displace.py index a5c57d75..3442711f 100644 --- a/ant_landscape/mesh_ant_displace.py +++ b/ant_landscape/mesh_ant_displace.py @@ -37,6 +37,7 @@ from .ant_functions import ( draw_ant_displace, ) from .ant_noise import noise_gen +from ant_landscape import ant_noise # ------------------------------------------------------------ # Do vert displacement @@ -46,128 +47,128 @@ class AntMeshDisplace(bpy.types.Operator): bl_description = "Displace mesh vertices" bl_options = {'REGISTER', 'UNDO', 'PRESET'} - ant_terrain_name = StringProperty( + ant_terrain_name: StringProperty( name="Name", default="Landscape" ) - land_material = StringProperty( + land_material: StringProperty( name='Material', default="", description="Terrain material" ) - water_material = StringProperty( + water_material: StringProperty( name='Material', default="", description="Water plane material" ) - texture_block = StringProperty( + texture_block: StringProperty( name="Texture", default="" ) - at_cursor = BoolProperty( + at_cursor: BoolProperty( name="Cursor", default=True, description="Place at cursor location", ) - smooth_mesh = BoolProperty( + smooth_mesh: BoolProperty( name="Smooth", default=True, description="Shade smooth" ) - tri_face = BoolProperty( + tri_face: BoolProperty( name="Triangulate", default=False, description="Triangulate faces" ) - sphere_mesh = BoolProperty( + sphere_mesh: BoolProperty( name="Sphere", default=False, description="Generate uv sphere - remove doubles when ready" ) - subdivision_x = IntProperty( + subdivision_x: IntProperty( name="Subdivisions X", default=128, min=4, max=6400, description="Mesh X subdivisions" ) - subdivision_y = IntProperty( + subdivision_y: IntProperty( default=128, name="Subdivisions Y", min=4, max=6400, description="Mesh Y subdivisions" ) - mesh_size = FloatProperty( + mesh_size: FloatProperty( default=2.0, name="Mesh Size", min=0.01, max=100000.0, description="Mesh size" ) - mesh_size_x = FloatProperty( + mesh_size_x: FloatProperty( default=2.0, name="Mesh Size X", min=0.01, description="Mesh x size" ) - mesh_size_y = FloatProperty( + mesh_size_y: FloatProperty( name="Mesh Size Y", default=2.0, min=0.01, description="Mesh y size" ) - random_seed = IntProperty( + random_seed: IntProperty( name="Random Seed", default=0, min=0, description="Randomize noise origin" ) - noise_offset_x = FloatProperty( + noise_offset_x: FloatProperty( name="Offset X", default=0.0, description="Noise X Offset" ) - noise_offset_y = FloatProperty( + noise_offset_y: FloatProperty( name="Offset Y", default=0.0, description="Noise Y Offset" ) - noise_offset_z = FloatProperty( + noise_offset_z: FloatProperty( name="Offset Z", default=0.0, description="Noise Z Offset" ) - noise_size_x = FloatProperty( + noise_size_x: FloatProperty( default=1.0, name="Size X", min=0.01, max=1000.0, description="Noise x size" ) - noise_size_y = FloatProperty( + noise_size_y: FloatProperty( name="Size Y", default=1.0, min=0.01, max=1000.0, description="Noise y size" ) - noise_size_z = FloatProperty( + noise_size_z: FloatProperty( name="Size Z", default=1.0, min=0.01, max=1000.0, description="Noise Z size" ) - noise_size = FloatProperty( + noise_size: FloatProperty( name="Noise Size", default=0.25, min=0.01, max=1000.0, description="Noise size" ) - noise_type = EnumProperty( + noise_type: EnumProperty( name="Noise Type", default='hetero_terrain', description="Noise type", @@ -192,46 +193,26 @@ class AntMeshDisplace(bpy.types.Operator): ('planet_noise', "Planet Noise", "Planet Noise by: Farsthary", 17), ('blender_texture', "Blender Texture - Texture Nodes", "Blender texture data block", 18)] ) - basis_type = EnumProperty( + basis_type: EnumProperty( name="Noise Basis", - default="0", + default=ant_noise.noise_basis_default, description="Noise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - vl_basis_type = EnumProperty( + items = ant_noise.noise_basis + ) + vl_basis_type: EnumProperty( name="vlNoise Basis", - default="0", + default=ant_noise.noise_basis_default, description="VLNoise basis algorithms", - items = [ - ("0", "Blender", "Blender default noise", 0), - ("1", "Perlin", "Perlin noise", 1), - ("2", "New Perlin", "New Perlin noise", 2), - ("3", "Voronoi F1", "Voronoi F1", 3), - ("4", "Voronoi F2", "Voronoi F2", 4), - ("5", "Voronoi F3", "Voronoi F3", 5), - ("6", "Voronoi F4", "Voronoi F4", 6), - ("7", "Voronoi F2-F1", "Voronoi F2-F1", 7), - ("8", "Voronoi Crackle", "Voronoi Crackle", 8), - ("9", "Cell Noise", "Cell noise", 9)] - ) - distortion = FloatProperty( + items = ant_noise.noise_basis + ) + distortion: FloatProperty( name="Distortion", default=1.0, min=0.01, max=100.0, description="Distortion amount" ) - hard_noise = EnumProperty( + hard_noise: EnumProperty( name="Soft Hard", default="0", description="Soft Noise, Hard noise", @@ -239,56 +220,56 @@ class AntMeshDisplace(bpy.types.Operator): ("0", "Soft", "Soft Noise", 0), ("1", "Hard", "Hard noise", 1)] ) - noise_depth = IntProperty( + noise_depth: IntProperty( name="Depth", default=8, min=0, max=16, description="Noise Depth - number of frequencies in the fBm" ) - amplitude = FloatProperty( + amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - frequency = FloatProperty( + frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - dimension = FloatProperty( + dimension: FloatProperty( name="Dimension", default=1.0, min=0.01, max=2.0, description="H - fractal dimension of the roughest areas" ) - lacunarity = FloatProperty( + lacunarity: FloatProperty( name="Lacunarity", min=0.01, max=6.0, default=2.0, description="Lacunarity - gap between successive frequencies" ) - offset = FloatProperty( + offset: FloatProperty( name="Offset", default=1.0, min=0.01, max=6.0, description="Offset - raises the terrain from sea level" ) - gain = FloatProperty( + gain: FloatProperty( name="Gain", default=1.0, min=0.01, max=6.0, description="Gain - scale factor" ) - marble_bias = EnumProperty( + marble_bias: EnumProperty( name="Bias", default="0", description="Marble bias", @@ -298,7 +279,7 @@ class AntMeshDisplace(bpy.types.Operator): ("2", "Tri", "Tri", 2), ("3", "Saw", "Saw", 3)] ) - marble_sharp = EnumProperty( + marble_sharp: EnumProperty( name="Sharp", default="0", description="Marble sharpness", @@ -310,7 +291,7 @@ class AntMeshDisplace(bpy.types.Operator): ("4", "Sharp inv.", "Sharp", 4), ("5", "Sharper inv.", "Sharper", 5)] ) - marble_shape = EnumProperty( + marble_shape: EnumProperty( name="Shape", default="0", description="Marble shape", @@ -324,19 +305,19 @@ class AntMeshDisplace(bpy.types.Operator): ("6", "Y", "Y", 6), ("7", "X", "X", 7)] ) - height = FloatProperty( + height: FloatProperty( name="Height", default=0.25, min=-10000.0, max=10000.0, description="Noise intensity scale" ) - height_invert = BoolProperty( + height_invert: BoolProperty( name="Invert", default=False, description="Height invert", ) - height_offset = FloatProperty( + height_offset: FloatProperty( name="Offset", default=0.0, min=-10000.0, @@ -344,14 +325,14 @@ class AntMeshDisplace(bpy.types.Operator): description="Height offset" ) - fx_mixfactor = FloatProperty( + fx_mixfactor: FloatProperty( name="Mix Factor", default=0.0, min=-1.0, max=1.0, description="Effect mix factor: -1.0 = Noise, +1.0 = Effect" ) - fx_mix_mode = EnumProperty( + fx_mix_mode: EnumProperty( name="Effect Mix", default="0", description="Effect mix mode", @@ -367,7 +348,7 @@ class AntMeshDisplace(bpy.types.Operator): ("8", "Max", "Maximum", 8) ] ) - fx_type = EnumProperty( + fx_type: EnumProperty( name="Effect Type", default="0", description="Effect type", @@ -396,7 +377,7 @@ class AntMeshDisplace(bpy.types.Operator): ("21", "Flat Voronoi", "Flat voronoi", 21) ] ) - fx_bias = EnumProperty( + fx_bias: EnumProperty( name="Effect Bias", default="0", description="Effect bias type", @@ -408,64 +389,64 @@ class AntMeshDisplace(bpy.types.Operator): ("4", "None", "None", 4) ] ) - fx_turb = FloatProperty( + fx_turb: FloatProperty( name="Distortion", default=0.0, min=0.0, max=1000.0, description="Effect turbulence distortion" ) - fx_depth = IntProperty( + fx_depth: IntProperty( name="Depth", default=0, min=0, max=16, description="Effect depth - number of frequencies" ) - fx_amplitude = FloatProperty( + fx_amplitude: FloatProperty( name="Amp", default=0.5, min=0.01, max=1.0, description="Amplitude" ) - fx_frequency = FloatProperty( + fx_frequency: FloatProperty( name="Freq", default=2.0, min=0.01, max=5.0, description="Frequency" ) - fx_size = FloatProperty( + fx_size: FloatProperty( name="Effect Size", default=1.0, min=0.01, max=1000.0, description="Effect size" ) - fx_loc_x = FloatProperty( + fx_loc_x: FloatProperty( name="Offset X", default=0.0, description="Effect x offset" ) - fx_loc_y = FloatProperty( + fx_loc_y: FloatProperty( name="Offset Y", default=0.0, description="Effect y offset" ) - fx_height = FloatProperty( + fx_height: FloatProperty( name="Intensity", default=1.0, min=-1000.0, max=1000.0, description="Effect intensity scale" ) - fx_invert = BoolProperty( + fx_invert: BoolProperty( name="Invert", default=False, description="Effect invert" ) - fx_offset = FloatProperty( + fx_offset: FloatProperty( name="Offset", default=0.0, min=-1000.0, @@ -473,7 +454,7 @@ class AntMeshDisplace(bpy.types.Operator): description="Effect height offset" ) - edge_falloff = EnumProperty( + edge_falloff: EnumProperty( name="Falloff", default="0", description="Flatten edges", @@ -483,53 +464,53 @@ class AntMeshDisplace(bpy.types.Operator): ("2", "X", "X Falloff", 2), ("3", "X Y", "X Y Falloff", 3)] ) - falloff_x = FloatProperty( + falloff_x: FloatProperty( name="Falloff X", default=4.0, min=0.1, max=100.0, description="Falloff x scale" ) - falloff_y = FloatProperty( + falloff_y: FloatProperty( name="Falloff Y", default=4.0, min=0.1, max=100.0, description="Falloff y scale" ) - edge_level = FloatProperty( + edge_level: FloatProperty( name="Edge Level", default=0.0, min=-10000.0, max=10000.0, description="Edge level, sealevel offset" ) - maximum = FloatProperty( + maximum: FloatProperty( name="Maximum", default=1.0, min=-10000.0, max=10000.0, description="Maximum, flattens terrain at plateau level" ) - minimum = FloatProperty( + minimum: FloatProperty( name="Minimum", default=-1.0, min=-10000.0, max=10000.0, description="Minimum, flattens terrain at seabed level" ) - vert_group = StringProperty( + vert_group: StringProperty( name="Vertex Group", default="" ) - strata = FloatProperty( + strata: FloatProperty( name="Amount", default=5.0, min=0.01, max=1000.0, description="Strata layers / terraces" ) - strata_type = EnumProperty( + strata_type: EnumProperty( name="Strata", default="0", description="Strata types", @@ -541,24 +522,24 @@ class AntMeshDisplace(bpy.types.Operator): ("4", "Quantize", "Quantize", 4), ("5", "Quantize Mix", "Quantize mixed", 5)] ) - water_plane = BoolProperty( + water_plane: BoolProperty( name="Water Plane", default=False, description="Add water plane" ) - water_level = FloatProperty( + water_level: FloatProperty( name="Level", default=0.01, min=-10000.0, max=10000.0, description="Water level" ) - remove_double = BoolProperty( + remove_double: BoolProperty( name="Remove Doubles", default=False, description="Remove doubles" ) - direction = EnumProperty( + direction: EnumProperty( name="Direction", default="NORMAL", description="Displacement direction", @@ -568,27 +549,27 @@ class AntMeshDisplace(bpy.types.Operator): ("Y", "Y", "Displace in the Y direction", 2), ("X", "X", "Displace in the X direction", 3)] ) - show_main_settings = BoolProperty( + show_main_settings: BoolProperty( name="Main Settings", default=True, description="Show settings" ) - show_noise_settings = BoolProperty( + show_noise_settings: BoolProperty( name="Noise Settings", default=True, description="Show noise settings" ) - show_displace_settings = BoolProperty( + show_displace_settings: BoolProperty( name="Displace Settings", default=True, description="Show terrain settings" ) - refresh = BoolProperty( + refresh: BoolProperty( name="Refresh", default=False, description="Refresh" ) - auto_refresh = BoolProperty( + auto_refresh: BoolProperty( name="Auto", default=False, description="Automatic refresh" |