Code Monkey home page Code Monkey logo

thicket's Introduction

Thicket

Laubwerk Plants Add-on for Blender

Thicket is a Blender Add-on to import Laubwerk Plants high resolution plant and tree models.

Thicket is an open source community developed project using the Laubwerk Python SDK. While not affiliated with or officially supported by Laubwerk GmbH, this project would not be possible without Laubwerk's efforts to answer questions and address issues during the development of Thicket.

Using Laubwerk's level of detail controls, Thicket keeps the Blender viewport responsive and renderings photo-realistic. Cycles render of a Japanese Maple (Acer Palmatum):

doc/acerp-cycles.png

Features

Thicket provides a visual plant selection gallery and options to configure the plant model variant, age, and leaf density. It generates separate viewport and render models, supporting various levels of detail for each. The viewport can display a low poly proxy (convex hull), partial or full geometry models in any of Blender's viewport modes. The rendered model geometry is generated using various level of detail controls.

  • Sidebar "N Panel" UI
    • Visual plant selection gallery
    • Update existing plants
    • Update all identical instances at once
    • Batch update selected plants
    • Make instances unique
    • Smart delete to manage scene size
  • Plant model options
  • Separate viewport and render models
  • Render level of detail controls
  • Material nodes
  • Collection instancing

doc/thicket-banner-2048.png

Install

  • Download and install the prerequisites
    • Blender 2.80 or later through 3.0.1. Laubwerk 1.0.43 supports up to Python 3.9, Blender 3.1 switched to Python 3.10. Until Laubwerk adds Python 3.10 support, Blender 3.0.1 is the latest version Thicket can support.
    • Laubwerk Python SDK 1.0.33 or later, provided by all Laubwerk Plant Kits, including the Plants Kit Freebie.
      • Choose the "Custom" installation method and ensure the "Python Extension" component is checked.
  • Installation options
    • From a release Zip file (most users)
      • Download the latest release zip file from the Releases Tab
      • Start Blender
      • Choose Edit -> Preferences -> Add-ons -> Install
      • Select the zip file and click Install Add-on
    • Latest from GitHub (for testers and developers)
      • Exit Blender
      • Clone the thicket git repository into the Blender addons folder:
        • Mac: ~/Library/Blender/2.80/scripts/addons/thicket
        • Windows: %AppData%\Blender Foundation\Blender\2.80\scripts\addons\thicket
      • Start Blender
  • Configure Thicket
    • Choose Edit -> Preferences...
    • Select the Add-ons tab and search for thicket
    • Check the box to enable the row Import-Export: Thicket: Laubwerk Plants Add-on for Blender
      • If you have more than one version installed, be sure to only enable one at a time
    • Click the arrow to expand the add-on preferences
    • Enter the Laubwerk Plants and Python Extension installation paths (these will be pre-populated with the platform defaults). The boxes will be red until valid paths are entered, then the Laubwerk SDK version will be displayed below.
    • Click Rebuild Database. This will take a few minutes depending on your computer and the number of Laubwerk Plants Kits installed.
    • When it completes, the number of plants in the database is displayed
  • Thicket is now ready to use (see Usage)

doc/thicket-prefs.png

Usage

N Panel

Thicket adds a Blender N Panel to Add, Edit, and Delete plants. Access the panel by pressing n and clicking on the Thicket tab.

doc/thicket-panel-add-only.png

Add Plant

To add a plant, click Add Plant. Tthe panel presents a plant model, season, leaf density, and level of detail options.

doc/thicket-panel-add.png

Toa select a different plant from the gallery, press Change Plant. You can resize the panel to show up to 5 columns of plants. You can filter the results by entering a search term (clear the search by pressing the cancel icon to the right of the search field).

doc/thicket-panel-select.png

The image preview will update when you change the Model variant and age. You can also configure the Season, Leaf Density, and several Level of Detail properties:

Plant Model

Model: Select variant and age
Season: Affect foliage, color, and flowers
Leaf Density: Control how full the foliage appears

Level of Detail

Viewport: Control the model displayed in the viewport

  • Proxy: low poly proxy (convex hull)
  • Partial Geometry: low detail version of the render model
  • Full Geometry: high detail render model

Render: Control the rendered model

  • Proxy: low poly proxy (convex hull, forces viewport to Proxy)
  • Full Geometry: high detail render model

Max Branching Level: Limit the number of branching levels off the trunk (uncheck to use the plant default)
Min Branch Thickness: Eliminate branches smaller than this value (uncheck to use the plant default)
Max Subdivisions: Control the max number of edges in a branch cross-section (1 is square)
Leaf Amount: Control the number of leaves used to reach the specified leaf density (fewer leaves result in larger individual leaves)

You can return to the gallery to select a different plant with Change Plant, add the current plant with Add, or cancel the operation with Cancel.

Adding Acer Palmatum with Viewport Proxy selected, loads the convex hull into the viewport:

doc/thicket-import-proxy.png

Importing the same plant with Viewport Partial Geometry selected loads a low detail version of the render model into the viewport:

doc/thicket-panel-view.png

The rendered model is the same for each, resulting in the following rendered image:

doc/thicket-import-render.png

Edit Plant

To edit the properties after a plant is added, select the plant in the viewport and press Edit under the thumbnail in the panel. Here, you can change the plant and any of the options. Pressing Update will replace the selected plant's template, changing all plants using the same template.

doc/thicket-panel-edit.png

Batch updates are supported by selected multiple plants. In this mode, you can specify some new properties, and leave some unchanged. For example, you can select two different plant models, and change only the season. All options affecting geometry are changed as a group, made available by checking Show Geometry Options.

doc/thicket-panel-batch-edit.png

Delete Plants

Avoid using x to delete plants. Instead, select the plants and press Delete (#) in the panel, where # indicates the number of plants selected. This will remove the plant instances from the viewport as well as the template plants when the last instance is removed. This will help keep your Blender file as small as possible.

Make Plants Unique

To edit plants independently from others based on the same template, select the plants you want to be unique and press Make Unique (#). The number of "sibling" plants (plants with the same template) is indicated by (#) in the Make Unique (#) label. If multiple plants are selected, each one will be made unique from the rest.

Collections and Instancing

Thicket creates a template for each plant added, and places them in a top level collection named "Thicket" which is excluded from the View Layer by default. Each template is a collection consisting of the viewport object and the render object as a child of the viewport object. Object visibility settings determine which object is visible in the viewport, and which is visible for rendering. At import time, a Collection Instance of the template collection is added to the main scene collection. This is the object that is visible after import.

The object model is shown in the image below by checking the Thicket collection and expanding the template collection and object hierarchy:

doc/thicket-collections.png

The collection instance can be duplicated with Shift+D to add a second identical plant instance to the scene, without doubling the memory used. Because Collection Instances are displayed in the viewport, modifying the template in the Thicket collection will be reflected in all the instances (this is what Editing and Updating a plant with the Thicket N Panel does).

In short, leave the Thicket collection unchecked and duplicate the Collection Instance in the scene to make memory efficient copies of plants you can update in groups. To make a plant unique, select it and press Make Unique (#).

Report an Issue

Thicket is an open source project that is not affiliated with Laubwerk GmbH. If you think you have found a problem or a bug with Thicket, please Check Existing Issues to see if someone has already reported it. If not, please Create a New Issue, providing as much detail as possible to help us recreate the problem. Please do not contact Laubwerk directly.

Contributing

See CONTRIBUTING for more information.

thicket's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

thicket's Issues

Index of refraction should be 1.33

We at Laubwerk currently do not explicitly store the index of refraction, but implicitly assume the index of refraction for all Laubwerk materials to be 1.33. That should be reflected, until the index of refraction is explicitly stored, for materials compatibility between different host applications.

Bulk plant edits

Plant selection and edit is currently limited to the active plant (and all identical instances from the same template). The Laubwerk Player for other tools allows for selecting all of the same plant (lbw.gz file) or all plants.

The Thicket edit panel could add a way to identify which plants are affected: e.g. current, all of this plant, all plants and update the panel with the number of instances and templates affected.

This would require the option of "No Change" or similar to avoid changing the plant, model, or season when the intent was to only change some of those.

It may be reasonable to disallow changing the plant for these builk edits.

Blender 3.0 Alpha on MacOS needs to Disable Library Validation Entitlement

From: https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_disable-library-validation?language=objc

"The Hardened Runtime enables library validation by default. This security-hardening feature prevents a program from loading frameworks, plug-ins, or libraries unless they’re either signed by Apple or signed with the same Team ID as the main executable. The macOS dynamic linker (dyld) provides a detailed error message when the system prevents code from loading due to library validation. Use the Disable Library Validation Entitlement if your program loads plug-ins that are signed by other third-party developers.

To add this entitlement to your app, first enable the Hardened Runtime capability in Xcode, and then under Runtime Exceptions, select Disable Library Validation."

Until Blender updates their build, Thicket will fail with a Traceback like this:

Traceback (most recent call last):
File "/Library/Application Support/Laubwerk/Python/laubwerk/init.py", line 39, in
from laubwerk._laubwerk import *
ImportError: dlopen(/Library/Application Support/Laubwerk/Python/laubwerk/_laubwerk.cpython-39-darwin.so, 2): no suitable image found. Did find:
/Library/Application Support/Laubwerk/Python/laubwerk/_laubwerk.cpython-39-darwin.so: code signature in (/Library/Application Support/Laubwerk/Python/laubwerk/_laubwerk.cpython-39-darwin.so) not valid for use in process using Library Validation: mapping process and mapped file (non-platform) have different Team IDs
/Library/Application Support/Laubwerk/Python/laubwerk/_laubwerk.cpython-39-darwin.so: stat() failed with errno=13

Separate Laubwerk Plants and Python folders

John Payne reports that attempting to change the installation path of a Laubwerk Plant Kit on Windows will install the Plants at the specified destination, but the Python SDK is still installed in "C:\Program Files".

If this is by design, the Thicket Add-on preferences may need to allow specifying the Plants and Python folders individually, rather than assume they both exist under a common Laubwerk installation path.

Need to confirm intent with Laubwerk.

thicket throws python errror when trying to add plant

Tested in 2.80, 2.82 and 2.91
I always get the following error


INFO: thicket: Importing "Abies koreana"
[debug] Time to create control mesh: 60ms
[debug] subdiv helper generation time : 0.121s
[debug] subdiv helper generation time : 0.129s
[debug] subdiv helper generation time : 0.127s
[debug] subdiv helper generation time : 0.024s
Traceback (most recent call last):
  File "C:\Users\mnu\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\thicket-0_3_2\__init__.py", line 661, in execute
    thicket_ui_obj = tp.import_lbw()
  File "C:\Users\mnu\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\thicket-0_3_2\__init__.py", line 380, in import_lbw
    return thicket_lbw.import_lbw(filepath, self.model, self.viewport_lod, self.render_lod, mesh_args)
  File "C:\Users\mnu\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\thicket-0_3_2\thicket_lbw.py", line 284, in import_lbw
    render_lod == 'PROXY')
  File "C:\Users\mnu\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\thicket-0_3_2\thicket_lbw.py", line 100, in lbw_to_bl_obj
    mat = lbw_to_bl_mat(lbw_plant, mat_id, mat_name, qualifier, proxy_color)
  File "C:\Users\mnu\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\thicket-0_3_2\thicket_lbw.py", line 134, in lbw_to_bl_mat
    mat.diffuse_color = proxy_color or lbw_mat.get_front().diffuse_color + (1.0,)
AttributeError: 'Side' object has no attribute 'diffuse_color'

location: <unknown location>:-1

Thanx, mnu

Retain plant properties when canceling plant selection

If changes are made to plant properties in the Add or Edit modes and the use then switches to the Select_Add or Select states, and then cancels that operation, the UI returns to View state instead of the previous state, and the property edits are lost. A user can reasonably expect the Cancel button to take them back to the previous view of the UI with their edits preserved.

Add possibility to edit plant materials

As the leaf shaders seemed a bit to reflective for my taste, I tried to edit the materials. But as far as I can see, the plant shaders seem to be hidden from the user.

I would like to see the possibility to dive into materials and edit properties like reflectivity, bump strength or proabably even replace bitmap textures.

Use a module specific logger

Blender guidelines discourage logging to the root logger or configuring it in an add-on:
https://code.blender.org/2016/05/logging-from-python-code-in-blender/

Create a "thicket" logger and log it to a file by default, ensuring that regardless of how the user (or other add-ons..... cough rpr cough) configures the logging system.

This should simplify the error reporting process by not requiring users to launch Blender from the command line in order to capture the log output.

Resolution of preview image is bad

The preview image (in both, browser and property editor) currently is really low resolution. That doesn't look good and also makes it hard to make out details that may be helpful to consider when picking a plant in the browser.

Make Max Branching Level and Min Branch Thickness optional

The Laubwerk SDK has default values for these (presumably per plant) and the Laubwerk Players allow the user to optionally specify these.

Add a boolean property to ThicketPropGroup for each of these and add it to the Plant Properties Panel to enable or disable these properties. If disabled, pass None to import_lbw and drop these from the call to get_mesh(), letting the Laubwerk SDK determine the appropriate value.

Update for Blender 3.0 API Changes (bpy.utils.user_resource)

Hello,
Thicket works fine in Blender 2.92, but since version 2.93 they are using Python 3.9 instead of 3.7, and that breaks some addons, including Thicket.
I tested it on Blender 3.0.0 alpha. It can be installed, but cannot be enabled (ticked) in addon preferences. It throws such an error:

"
Traceback (most recent call last):
File "C:\Program Files\Blender Foundation\E-Cycles_X_Pro_3.0_a_20211008_win\3.0\scripts\modules\addon_utils.py", line 351, in enable
mod = import(module_name)
File "C:\Users\User\AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons\thicket-0_4_0_init_.py", line 70, in
log_path = Path(bpy.utils.user_resource('SCRIPTS', "addons", True)) / name / "thicket.log"
TypeError: user_resource() takes 1 positional argument but 3 were given
"

Is there a chance for an update for newest Blender versions?

Best regards

Use sys.executable instead of bpy.app.binary_path_python

Blender 2.91 now reports the use of bpy.app.binary_path_python as a warning, recommending the use of sys.executable instead:

bpy.app.binary_path_python
'/Applications/Blender.app/Contents/Resources/2.91/python/bin/python3.7m'

/Applications/Blender.app/Contents/MacOS/Blender:1: RuntimeWarning: Use 'sys.executable' instead of 'binary_path_python'!

There are only two instances of this usage in Thicket, both in init.py. Before making the change, we need to determine if this is backward compatible with Blender 2.80 through 2.90 and special case earlier versions if not.

Re-use texture input nodes

Quoting myself from #32:

One possible optimization (not sure if it has any performance implications, but it may simplify/clarify the material graph): Perhaps keep a list of texture input nodes around and just re-use a node when a texture is used multiple times (with the same color space setting). In the example above, e.g. the input node for the front BSDF color could be re-used as input to the Mix BSDF node.

Backfacing unsupported with Radeon ProRender

When switching the render engine to Radeon ProRender v2.4.11, Blender 2.83 reports:

WARNING rpr.export.node [123145529303040]: Ignoring unsupported output socket <bpy_struct, NodeSocketFloat("Backfacing")> <bpy_struct, ShaderNodeNewGeometry("Geometry")> <bpy_struct, Material("Acer_palmatum_lf_01_au")>

This does not occur for Evee or Cycles.

Need to research how to identify and mitigate feature restrictions across popular render engines.

Optimize plant update by not reloading unnecessarily

The current mechanism to update plants collects information from the UI and passes it to the thicket_lbw module to import the Laubwerk plant. It does not attempt to determine if reloading is strictly necessary, which results in unnecessary recreation of existing geometry and user wait times.

A more intelligent approach would check if the viewport and the render geometry changed individually and only recreate what changed. In some situations, like changing from proxy in the viewport to full render geometry, no reload is necessary.

To accomplish this, the thicket_lbw.import_lbw() routine needs to be broken up to handle the viewport and the render models in separate calls and the logic calling those needs to be moved into init.py where there is knowledge of existing model being updated in order to make better decisions about when to reload.

Not found module thicket-blender_3

Hi and thanks for developing this.
I installed the main branch version in Blender 2.91, all fine.
Then I tried the branch for version Blender 3.0. After installing from the .zip, when trying to activate I would get an error :
"not able to find module thicket-blender_3"
Looking in the ..AppData\Roaming\Blender Foundation\Blender\3.0\scripts\addons I found a folder named "thicket-blender_3.0" , I renamed that "thicket-blender_3", restarted Blender and it worked.

"Failed to load Laubwerk Python Extension from this path"

Error Message when selecting Python path. Using thicket 0.4.0 and freshly installed Laubwerk libraries (LaubwerkPlantsKit2 ,LaubwerkPlantsKit8, & LaubwerkPlantsKitFreebie, version 1.034)

image

Same issue on 2 different PCs

  • OS: Windows 10
  • OS 20H2
  • Blender Version: 2.93.1
  • Blender Version: 2.83.4

Add material quality setting

The other Laubwerk plugins all allow to set material quality to high, medium, and low, to allow for object further away to render much faster. Depending on the way the host application works, this is a setting in the browser or in the object attribute panel. I guess in Blender, since materials get updated when model settings are changed, it could go into the object attribute panel.

Silence Laubwerk SDK

For every call to the Laubwerk SDK get_mesh() function, the SDK prints the following to the console:

[debug] Time to create control mesh: 1572ms
[debug] subdiv helper generation time : 0.002604s
[debug] subdiv helper generation time : 0.000803s

There is not option to specify the log level of the SDK.

The typical way to address this is via contextlib.redirect_std(out|err). Unfortunately, this doesn't work with the CPython SDK library.

There may not be a way to address this in Thicket, but tracking this here in case someone knows a way around it. Alternatively, we can reach out to Laubwerk to request a loglevel which honors the standard python log levels and pass in the Thicket log level setting to the SDK directly.

Add proxy to render detail

In some cases, users may choose to use the proxy model even in full renders. Provide a checkbox in Render Detail to use the Proxy model.

In this case, it should force the use of the proxy model in the viewport, and only load the geometry for one of them.

Python SyntaxError initializing Add-on

hi, how do i fix this, theres an error turning on the add on
error

Latest from GitHub (for testers and developers)
Exit Blender
Clone the thicket git repository into the Blender addons folder:
Mac: ~/Library/Blender/2.80/scripts/addons/thicket
Windows: %AppData%\Blender Foundation\Blender\2.80\scripts\addons\thicket
Start Blender

Originally posted by @mheljune in #20

Support two sided leaf materials

Many Laubwerk plants support two sided leaves with front and back materials. lbw_to_bl_mat() currently assumes one sided. Add logic to detect two sided leaves and investigate how to distinguish the two sides within Blender and apply the backside material.

Viewport: Use render model

In some cases, the render model may be low detail, or the user may prefer to view the full geometry in the viewport. Add "Render Model" or similar to the viewport detail options. When selected, only the one model should be loaded and made visible in both viewport and render.

Laubwerk Python Extension 1.0.34 not supported

The material system has undergone substantial changes with the Python Extension 1.0.24. Some material properties have been renamed (e.g. diffuse_color to base_color and a bunch have been added (e.g. specular_roughness_texture or sheen).

Python extension not accepted (Laubwerk 1.0.39 on MacOS only)

Describe the bug
Somehow the path to the Python extension in Blenders Plugin Settings is not accepted.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Blender and
  2. Click on path for Python extensions
  3. See error, path appears red, unfortunately plugin is still disabled

Expected behavior
A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: MacOS
  • OS Version [10.15.2]
  • Blender Version [2.81a]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.