• Stars
    star
    596
  • Rank 75,095 (Top 2 %)
  • Language Cython
  • License
    Other
  • Created over 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Import shaders end environments in Blender from a single URL

If this helps you save time or money for your job, please consider supporting the work involved in here ;) Donate

Cover

Lily Surface Scraper

There are many sources for getting PBR textures on the Internet, but it is always a repetitive task to setup the shader once in Blender. Some sources provide an add-on to automatically handle this, but it remains painful to install a new add-on for each of them, and learn over how they slightly differ from the other one.

LilySurfaceScraper suggest a very intuitive and unified workflow: browse your favorite library in your browser. Once you have made your choice, just copy the URL of the page and paste it in Blender. The script will prompt for potential variants if some are detected, then download the maps and setup the material.

This add-on has been designed to make it very easy to add new sources. You can just add a script in the Scrapers/ directory, it will be automatically detected. See below for more information.

Links & Resources

Installation

Download the latest release, then in Blender, go to Edit > Preferences, Add-on, Install, browse to the zip file.

Make sure that you have ticked the small checkbox next to "Import: Lily Surface Scraper", otherwise the add-on will not be active.

Add-on loaded in the User Preferences

Preferences

You can set a path to your texture library. If the path is in absolute form, like C:\Users\Suzanne\Pictures, you will not have to save your blend files before you can use the add-on.

If a path is relative like image-textures\lily LilySurfaceScraper searches for a folder named image-textures next to your .blend project file and saves the textures inside image-textures in a subfolder named lily.

Usage

  1. Open the material properies panel.

Add-on loaded in the User Preferences

  1. If you see this message you need to save your file first or set an absolute path for your textures.

Add-on loaded in the User Preferences

  1. Browse one of the supported websites, until you find a texture, say https://cc0textures.com/view.php?tex=Metal01

  2. Copy this URL

  3. Click Import from Clipboard to instantly import the material. Alternatively you can click Import Surface and paste the URL you just copied:

Add-on loaded in the User Preferences

  1. Select the variant, if there is more than one available on the page:

Add-on loaded in the User Preferences

  1. The textures are now being downloaded and the material is being setup. Depending on the resolution and your internet connection this can take a few seconds.

To change where the textures are being stored on the drive, check Preferences. Note that they are not downloaded twice if you use the same URL and variant again.

Add-on loaded in the User Preferences

NB The same process is available in the World panel:

Lily Surface Scraper in world panel

Supported sources

The following sources are supported, feel free to suggest new ones.

Materials:

Worlds:

Lights:

Troubleshooting

Blender hangs forever when downloading the files
If you are using a VPN, try to disable it.

Cannot import name 'etree' from 'lxml' We tried to bundle lxml into the add-on to avoid issues, but there are still some people having trouble with it. If you get such an error when activating the add-on, install lxml manually by running the following command line in admin mode (adapt the path to your version and installation location of Blender):

Windows

"C:\Program Files\Blender Foundation\Blender 3.1\3.1\python\bin\python.exe" -m pip install lxml -t "C:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules"

MacOS

/Applications/Blender.app/Content/Resources/3.4/python/bin/python -m pip install lxml -t /Applications/Blender.app/Content/Resources/3.4/scripts/modules

Ideally, you could share the folder C:\Program Files\Blender Foundation\Blender 3.1\3.1\scripts\modules\lxml or /Applications/Blender.app/Content/Resources/3.4/scripts/modules/lxml that this creates in an issue here so that I can add it to the repo.

Other
If you run into any sort of trouble running this add-on, please fill an issue on this repository. Please, do not attempt to report problems with the addon to the material and sky sources' websites as they are not involved in this project and I don't want them to receive undue "spam" because of me.

Trouble is to be expected the source websites change their design. Please report it here and be patient so we can fix the addon, or try to propose your own changes (they should be pretty easy to do, see section about new sources below).

Adding new sources

I tried to make it as easy as possible to add new sources of data. The only thing to do is to add a python file in Scrapers/ and define in it a class deriving from AbstractScraper.

You can start from a copy of AmbientCgScraper.py or CgbookcaseScraper.py. The former loads a zip and extracts maps while the second looks for a different URL for each map (base color, normal, etc.).

The following three methods are required:

canHandleUrl(cls, url)

A static method (just add @staticmethod before its definition) that returns True only if the scraper recognizes the URL url.

fetchVariantList(self, url)

Return a list of variant names (a list of strings), to prompt the user. This is useful when a single page provides several versions of the material, like different resolutions (2K, 4K, etc.) or front/back textures.

This method may save info like the html page in self, to reuse it in fetchVariant.

fetchVariant(self, variant_index, material_data)

Scrap the information of the variant numbered variant_index, and write it to material_data. The following fields of material_data can be filled:

  • material_data.name: The name of the texture, typically prefixed by the source, followed by the texture name, then the variant name.
  • material_data.maps['baseColor']: The path to the baseColor map, or None
  • material_data.maps['diffuse']: The path to the diffuse map, or None
  • material_data.maps['normal']: The path to the normal map, or None
  • material_data.maps['normalInvertedY']: The path to the normal map, or None
  • material_data.maps['opacity']: The path to the opacity map, or None
  • material_data.maps['roughness']: The path to the roughness map, or None
  • material_data.maps['metallic']: The path to the metallic map, or None
  • material_data.maps['emission']: The path to the emission map, or None
  • material_data.maps['ambientOcclusion']: The path to the ambient occlusion map, or None
  • material_data.maps['ambientOcclusionRough']: The path to the rough ambient occlusion map, or None
  • material_data.maps['specular']: The path to the specular map, or None
  • material_data.maps['glossiness']: The path to the glossiness map (inverted roughness), or None
  • material_data.maps['height']: The path to the height map, or None
  • material_data.maps['vectorDisplacement']: The path to the vector displacement map, or None

You can define your own texture maps by adding them to self.maps in MaterialData.py. You can then assign a texture map that name in your scraper (we, by convention, have a dictionary called maps_tr that maps the scraped name onto the internal naming defined in MaterialData.py) and translate it to a node setup in for example CyclesMaterialData.py.

Utility functions

To implement these methods, you can rely on the following utils:

self.fetchHtml(url)

Get the url as a lxml.etree object. You can then call the xpath() method to explore the page using the very convenient xpath synthax.

fetchImage(self, url, material_name, map_name)

Get an image from the URL url, place it in a directory whose name is generated from the material_name, and call the map map_name + extension (if an extension is explicit in the URL). The function returns the path to the downloaded texture, and you can directly provide it to material_data.maps[...].

fetchZip(self, url, material_name, zip_name)

Get a zip file from the URL url. This works like fetchImage(), returning the path to the zip file. You can then use the zipfile module, like AmbientCgScraper.py does.

self.clearString(s)

Remove non printable characters from s

Advanced use

There are some advanced hidden properties provided in the Lily Surface operators, that may be useful for integration into other scripts or pipelines:

create_material/create_world

These properties default to True, but can be turned off to prevent the operator from creating a material/world. When it is off, it still download the textures and loads the images in the blend file, but don't affect neither the active object's material nor the world.

callback_handle

It can be useful to have operations run after the operator. Since it is always painful to do so with the vanilla bpy API, Lily Surface Scraper features a simple callback mechanism. All operators can take a callback as property, a callback being a function called once the operator is done. It recieves one argument, namely the bpy context into which the operator was running.

Since Blender operators cannot take arbitrary values like callbacks as properties, a register_callback() utility function is provided to convert the callback into a numeric handle that can then be provided to the operator. The following snippet illustrates the process:

import LilySurfaceScraper

def c(ctx):
    print("Callback running!")
    print(ctx)
    
h = LilySurfaceScraper.register_callback(c)
bpy.ops.object.lily_surface_import(url="https://cc0textures.com/view.php?tex=Metal01", callback_handle=h)

More Repositories

1

MapsModelsImporter

A Blender add-on to import models from google maps
Python
2,414
star
2

LearnWebGPU

Learn to use WebGPU for native graphic applications in C++
C++
383
star
3

BMeshUnity

A Unity package to make runtime procedural mesh generation more flexible.
C#
350
star
4

WebGPU-Cpp

A single-file zero-overhead C++ idiomatic wrapper for WebGPU native
C++
277
star
5

HoudiniEngineForBlender

Branch of Blender featuring a Houdini Engine based modifier
181
star
6

OpenMfxForBlender

A branch of Blender featuring an OpenMfx modifier
C
176
star
7

DagAmendment

The official implementation of the research paper "DAG Amendment for Inverse Control of Parametric Shapes"
C++
171
star
8

OpenMfx

A low-overhead mesh-processing plug-in API for cross-software procedural effects
C
161
star
9

WebGPU-distribution

Distributions of WebGPU for native and web development, easy to integrate and interchangeable.
CMake
145
star
10

LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
99
star
11

BlenderImgui

Custom GUI for your Blender add-ons using Dear ImGui
Python
94
star
12

glfw3webgpu

An extension for the GLFW library for using WebGPU native.
C
62
star
13

LilyRender360

Lily Render 360 is a tool for rendering a Unity scene into stitch-free equirectangular images
C#
59
star
14

MfxHoudini

A Houdini-Engine based Open Mesh Effect
C
57
star
15

AdvancedBlenderAddon

A starter kit and reference for writing advanced Blender add-ons
Python
39
star
16

Python3dViewer

A simple starter Python code for experimenting 3D graphics
Python
30
star
17

sdl2webgpu

An extension for the SDL2 library for using WebGPU native.
C
25
star
18

MesoGen

The official implementation of MesoGen: Designing Procedural On-Surface Stranded Mesostructures (Siggraph 2023)
C++
24
star
19

RayStep

A real-time 3D distance field modeling software
C++
22
star
20

MapsModelsImporter-samples

Sample file to check MapsModelsImporter installation
20
star
21

LilyImageFromURL

A very very simple Blender add-on to very very quickly import images from URLs.
Python
17
star
22

GrainViewer

The official implementation of the research paper "Real-time multiscale rendering of dense dynamic stackings"
C++
13
star
23

MonumentValley

A little toy reproducing Monument Alley basic mechanism in Unity
C#
12
star
24

MfxVCG

An OpenMfx plug-in providing effects from VCGlib
C++
12
star
25

WebGPU-utils

A bunch of utility functions for WebGPU
C++
11
star
26

WebGPU-AutoLayout

An online utility tool to generate C++ boilerplate binding code by parsing WGSL.
Rust
10
star
27

TownBuilder

This is an experiment around the reproduction of Stalberg's Townscaper
C#
10
star
28

IRL

Inverse Reinforcement Learning
Jupyter Notebook
9
star
29

CodenameGogh

A node-based front-end to ffmpeg
C++
8
star
30

MfxExamples

An example of OpenMfx plug-in using the C++ SDK
C++
7
star
31

ModernGlad

Depreciation warnings to help writing more modern OpenGL using glad
Python
7
star
32

AugenLight

A cross-plateform OpenGL 4.5 starter kit
C++
6
star
33

firefox-webmention-addon

Firefox add-on to send webmentions though context menu
JavaScript
6
star
34

WebGPU-binaries

A CMake-ready binary release of a WebGPU native implementation (wgpu-native)
C
6
star
35

GreaseJs

A little demo of Grease Pencil using ThreeJS
JavaScript
6
star
36

sphinx_literate

An advanced literate programming tool for writing incremental programming courses.
Python
6
star
37

IvyGenerator

Update of Thomas Luft's original
C++
5
star
38

PythonMfx

A Python-based host for running OpenMfx mesh processing plugins
Python
5
star
39

WebGPU-Cpp-WebBackend

This is the backend of the Web service of https://github.com/eliemichel/WebGPU-Cpp
C++
5
star
40

fxos-AlphaRemote

A Firefox OS remote controller for Sony Alpha series cameras
JavaScript
4
star
41

AlignTools

Alignment tools add-on for Blender
Python
4
star
42

BiharmonicCoords

Webpage for the SIGGRAPH 24 paper "Biharmonic Coordinates and their Derivatives for Triangular 3D Cages"
HTML
4
star
43

WebGPU-raii

An RAII wrapper around the objects of the WebGPU native API.
C++
4
star
44

reshade

Fork ReShade adding Remote Control feature
C++
3
star
45

Cooldown

Feed rythm into live-coding tools
Rust
3
star
46

ReACORN

An attempt to reimplement ACORN
Python
3
star
47

WebMfx

A web-based host for OpenMfx using WASM plugins
C
3
star
48

PolyGreenCoords

Public page of "Polynomial 2D Green Coordinates for Polygonal Cages"(Siggraph 2023)
HTML
3
star
49

StatDeps

A lightweight C++ dependency graph library for compile-time dependent resource management.
C++
3
star
50

cartes-electorales

Python
2
star
51

MfxPlugins

Simple Open Mesh Effect plugins
C++
2
star
52

highspeedracer

Online racing game using Blender Game Engine
Python
2
star
53

LilyFuture

A header-only utiliy library to make std:futures fun to use!
C++
2
star
54

todo

A dead simple command line TODO-list manager
Python
2
star
55

Spillr

Mixed GLSL/C++ static C++ processor aiming at reducing boilerplate in shader writing
OCaml
2
star
56

UnitySsPattern

A screen space shader for Unity with object tracking
ShaderLab
2
star
57

SdfManipulation

Public page of "Direct Manipulation of Analytic Implicit Surfaces"(Siggraph Asia 2024)
HTML
2
star
58

webgpu-doc-jam

Set up for an incoming documentation jam of webgpu-headers, stay tuned!
2
star
59

JeuDePresse

Dessins d'actualité interactifs, produits en quelques heures avec MS Paint
JavaScript
2
star
60

irssi-notify

Notifications for Irssi via a simple http server
Python
1
star
61

WorLd

Simple 2D strategy game whom levels are autogenerated based on mathematical assertions
C++
1
star
62

texdown

Extension of markdown to support mathematics. Based on marked and MathJax.
JavaScript
1
star
63

join.js

The smallest JS library to love promises
JavaScript
1
star
64

fake-position

Firefox addon to spoof geolocation using openstreetmap
JavaScript
1
star
65

ColorSpaceViewer

A browser-based tool for visualizing images in color space
JavaScript
1
star
66

fHMM

Project for the lecture of Probabilistic Graphical Models
TeX
1
star
67

MemoryIDF

Code source du jeu Memory pour l'Ile de France, inspiré de la version pour Paris
HTML
1
star
68

OscToSpout

Forward OSC messages to KodeLife using a texture-sharing via Spout
C++
1
star
69

Dawn

Custom branches of Dawn for the Learn WebGPU for C++ guide
C++
1
star
70

PolyworldJs

Low-poly styled dynamic forest in ThreeJS
JavaScript
1
star
71

ZigDawn

Starter C++ project for using WebGPU native
C
1
star