Skip to content
Snippets Groups Projects
texturing_properties.py 35.8 KiB
Newer Older
# SPDX-License-Identifier: GPL-2.0-or-later
Maurice Raybaud's avatar
Maurice Raybaud committed

"""Declare texturing properties controllable in UI."""

import bpy
from bpy.utils import register_class, unregister_class
from bpy.types import PropertyGroup
from bpy.props import (
    FloatVectorProperty,
    StringProperty,
    BoolProperty,
    IntProperty,
    FloatProperty,
    EnumProperty,
    PointerProperty,
    CollectionProperty,
)

from .shading_properties import active_texture_name_from_uilist, active_texture_name_from_search

# ---------------------------------------------------------------- #
Maurice Raybaud's avatar
Maurice Raybaud committed
# Texture slots (Material context) exported as POV texture properties.
# ---------------------------------------------------------------- #


Maurice Raybaud's avatar
Maurice Raybaud committed
class MaterialTextureSlot(PropertyGroup):
    """Declare material texture slot level properties for UI and translated to POV."""

    bl_idname = ("pov_texture_slots",)
    bl_description = ("Nodeless texture slots",)
Maurice Raybaud's avatar
Maurice Raybaud committed

    # Adding a "real" texture datablock as property is not possible
    # (or at least not easy through a dynamically populated EnumProperty).
    # That's why we'll use a prop_search() UILayout function in texturing_gui.py.
    # So we'll assign the name of the needed texture datablock to the below StringProperty.
    texture: StringProperty(update=active_texture_name_from_uilist)
    # and use another temporary StringProperty to change the linked data
    texture_search: StringProperty(
        name="", update=active_texture_name_from_search, description="Browse Texture to be linked"
    )

    alpha_factor: FloatProperty(
        name="Alpha", description="Amount texture affects alpha", default=1.0
    )

    ambient_factor: FloatProperty(
        name="", description="Amount texture affects ambient", default=1.0
    )

    bump_method: EnumProperty(
        name="",
        description="Method to use for bump mapping",
        items=(
            ("BUMP_ORIGINAL", "Bump Original", ""),
            ("BUMP_COMPATIBLE", "Bump Compatible", ""),
            ("BUMP_DEFAULT", "Bump Default", ""),
            ("BUMP_BEST_QUALITY", "Bump Best Quality", ""),
        ),
        default="BUMP_ORIGINAL",
    )

    bump_objectspace: EnumProperty(
        name="",
        description="Space to apply bump mapping in",
        items=(
            ("BUMP_VIEWSPACE", "Bump Viewspace", ""),
            ("BUMP_OBJECTSPACE", "Bump Objectspace", ""),
            ("BUMP_TEXTURESPACE", "Bump Texturespace", ""),
        ),
        default="BUMP_VIEWSPACE",
    )

    density_factor: FloatProperty(
        name="", description="Amount texture affects density", default=1.0
    )

    diffuse_color_factor: FloatProperty(
        name="", description="Amount texture affects diffuse color", default=1.0
    )

    diffuse_factor: FloatProperty(
        name="", description="Amount texture affects diffuse reflectivity", default=1.0
    )

    displacement_factor: FloatProperty(
        name="", description="Amount texture displaces the surface", default=0.2
    )

    emission_color_factor: FloatProperty(
        name="", description="Amount texture affects emission color", default=1.0
    )

    emission_factor: FloatProperty(
        name="", description="Amount texture affects emission", default=1.0
    )

    emit_factor: FloatProperty(name="", description="Amount texture affects emission", default=1.0)

    hardness_factor: FloatProperty(
        name="", description="Amount texture affects hardness", default=1.0
    )

    mapping: EnumProperty(
        name="",
        description="",
        items=(
            ("FLAT", "Flat", ""),
            ("CUBE", "Cube", ""),
            ("TUBE", "Tube", ""),
            ("SPHERE", "Sphere", ""),
        ),
        default="FLAT",
    )

    mapping_x: EnumProperty(
        name="",
        description="",
        items=(("NONE", "", ""), ("X", "", ""), ("Y", "", ""), ("Z", "", "")),
        default="NONE",
    )

    mapping_y: EnumProperty(
        name="",
        description="",
        items=(("NONE", "", ""), ("X", "", ""), ("Y", "", ""), ("Z", "", "")),
        default="NONE",
    )

    mapping_z: EnumProperty(
        name="",
        description="",
        items=(("NONE", "", ""), ("X", "", ""), ("Y", "", ""), ("Z", "", "")),
        default="NONE",
    )

    mirror_factor: FloatProperty(
        name="", description="Amount texture affects mirror color", default=1.0
    )

    normal_factor: FloatProperty(
        name="", description="Amount texture affects normal values", default=1.0
    )

    normal_map_space: EnumProperty(
        name="",
        description="Sets space of normal map image",
        items=(
            ("CAMERA", "Camera", ""),
            ("WORLD", "World", ""),
            ("OBJECT", "Object", ""),
            ("TANGENT", "Tangent", ""),
        ),
        default="CAMERA",
    )

    object: StringProperty(
        name="Object",
        description="Object to use for mapping with Object texture coordinates",
        default="",
    )

    raymir_factor: FloatProperty(
        name="", description="Amount texture affects ray mirror", default=1.0
    )

    reflection_color_factor: FloatProperty(
        name="", description="Amount texture affects color of out-scattered light", default=1.0
    )

    reflection_factor: FloatProperty(
        name="", description="Amount texture affects brightness of out-scattered light", default=1.0
    )

    scattering_factor: FloatProperty(
        name="", description="Amount texture affects scattering", default=1.0
    )

    specular_color_factor: FloatProperty(
        name="", description="Amount texture affects specular color", default=1.0
    )

    specular_factor: FloatProperty(
        name="", description="Amount texture affects specular reflectivity", default=1.0
    )

    offset: FloatVectorProperty(
        name="Offset",
        description="Fine tune of the texture mapping X, Y and Z locations ",
Maurice Raybaud's avatar
Maurice Raybaud committed
        precision=4,
        step=0.1,
        soft_min=-100.0,
        soft_max=100.0,
        default=(0.0, 0.0, 0.0),
        options={"ANIMATABLE"},
        subtype="TRANSLATION",
    )

    scale: FloatVectorProperty(
        name="Size",
        subtype="XYZ",
Loading
Loading full blame...