Javascript DHTML Drop Down Menu Powered by dhtml-menu-builder.com
Your Profile

+ Reply to Thread
Results 1 to 6 of 6

Thread: How-To: Manually Load Materials from the LuxRender Material Database

  1. #1

    How-To: Manually Load Materials from the LuxRender Material Database

    The official LuxRender material database is a great place to download ready-to-use materials that already look great and are procedural-based. Unfortunately for us Reality users, in order to use them, we have to use an additional exporter or edit our scene configuration files by hand to recognize them. This tutorial describes how to do the latter.


    Note: The process I fill describe involves editing LuxRender configuration files with a text editor. If the idea of doing so makes you uneasy, you probably might not want to do this. If you would like to know more about the format of the LuxRender configuration files, their structure and syntax is readily available at the LuxRender Wiki.


    Lastly, I can't imagine Preta3D condoning you modifying Reality's output files. Reality won't recognize the manual edits you make to your file and will happily overwrite them if you save over it. So follow at your own risk!


    Step 1: Download a material from the LuxRender material database.


    Go to the LuxRender Material Database. Find a material that you you like and download the .lxm file. You don't need the other files.


    To make things simple, save the new .lxm file in the same directory as your other scene configuration files.


    Note: The material database won't be winning any user experience awards anytime soon. Hitting the download button won't suffice. It requires you to hit the 'Download LXM' button followed by the 'Save LXM' button when it becomes available.


    Step 2: Determine whether or not the your material is a volume.


    Power up your favorite plain text editor. Notepad is an excellent choice for Windows users. For Mac, I prefer good ol' vi.


    Open up the .lxm file you just downloaded and search for MakeNamedVolume. If this text does not appear in the file, you've got a basic material. If you do find one, you're dealing with a volume-based material.


    For this example I'll use the Jade material, which is a volume-based material. Therefore it will contain the MakeNamedMaterial and a MakeNamedVolume parameter (in this case two).


    Code:
    ...
    ...
    ...
    ...
    
    # DB Object ID 412
    MakeNamedVolume "Jade" "homogeneous"
    	# ParamSet ID 301
    	"texture fresnel" ["jade_ior"]
    	"color g" [0 0 0]
    	"color sigma_a" [157.78176496587 106.62381889742 157.78176496587]
    	"color sigma_s" [76.332199573517 150 76.332199573517]
    
    ...
    ...
    ...
    ...
    
    # DB Object ID 413
    MakeNamedVolume "world" "clear"
    	# ParamSet ID 302
    	"float fresnel" [1.0002926588058]
    	"color absorption" [0 0 0]
    
    ...
    ...
    ...
    ...
    
    MakeNamedMaterial "Jade" 
    	# ParamSet ID 305
    	"bool onesided" ["true"]
    	...
    	...

    Another good way to tell what sort of material you're dealing with is to simply read the comments at the top of the file (denoted with the '#' at the start of the line). If the comments specify and interior and/or an exterior, you're dealing with a volume-based material. This is in the comments section of the Jade.lxm.


    Code:
    # BEGIN DB Material 'Jade' ID 109
    # Author binarycortex, Fri, 18 Nov 11 19:50:41 -0800
    # Version 0.9.0.dev ; Rated 5 / 5.0 ; 2 Votes
    # interior : Jade
    # exterior : world
    # previewsamples : 256

    You don't have to do anything with this information yet, but you'll need to know this later on when applying these materials to a geometry as volume-based materials will require an extra line or two.


    Step 3: Add Your New File to the Scene


    Open up your scene's .lxs file with your text editor. Look for the lines that read WorldBegin and WorldEnd. You load your additional .lxm files inbetween these two parameteres. Your scene should already be loading two files similar to the following:


    Code:
    WorldBegin
      Include "jade-tutorial.lxm"
      Include "jade-tutorial.lxo"
    WorldEnd

    Following this format you can use the include parameter to attach your new .lxm like so:


    Code:
    WorldBegin
      Include "jade-tutorial.lxm"
      Include "Jade.lxm"
      Include "jade-tutorial.lxo"
    WorldEnd

    You should always include .lxm files before your scenes .lxo file. This is just so LuxRender defines material properties before trying to apply them.


    Save your .lxs file. Just to be safe you might want to save it as a copy so your don't overwrite your original.


    Step 3b (optional): Test your scene


    Although you haven't applied your new material to an object yet, the act of including it shouldn't break your scene. I recommend doing a test render with your log open to make sure no errors occur.





    (This is my ball. There are many like it but this one is mine.)


    Yay! Nothing exploded.


    Step 4: Take note of your material names


    Go back to the .lxm file you downloaded and look for the MakeNamedMaterial parameter again. The text that appears in quotes besides this material will is the name of this material. So for instance if your file contains something like this:

    Code:
    # This material is named Jade.
    MakeNamedMaterial "Jade" 
    	# ParamSet ID 305
    	"bool onesided" ["true"]
    	...

    'Jade' is the name of this material. Select the name (without the quotes) and copy it.


    Note: Names are case-senstive and if there are two materials with the same name, the last material defined which uses that name replaces the prior definitions. However. LuxRender won't mistake a volume and material with the same name (as demonstrated later on).


    Step 4b (for volumes only): Note your interior and exterior names


    If you have a volume, you will also need to note the names that appear next to the MakeNamedVolume parameter. The Name of volumes is displayed exactly like the way they are for materials. The other text you see in quotes is the type of volume. Volumes are often (but not necessarily) defined as pairs: one an exterior and one an interior. Refer to the comments at the top to determine which one is which.


    Code:
    # Interior Volume
    MakeNamedVolume "Jade" "homogeneous"
    	"texture fresnel" ["jade_ior"]
    	"color g" [0 0 0]
    	"color sigma_a" [157.78176496587 106.62381889742 157.78176496587]
    	"color sigma_s" [76.332199573517 150 76.332199573517]
    
    ...
    ...
    ...
    
    # Exterior Volume
    MakeNamedVolume "world" "clear"
    	"float fresnel" [1.0002926588058]
    	"color absorption" [0 0 0]

    So we should also note that we have an interior volume named 'Jade' (not to be confused with the material) and an exterior volume named 'world'.


    Step 5: Apply your material


    Open your scene's .lxo file. This is where materials are applied to geometries. For every object, materials are applied to it between the AttributeBegin and AttributeEnd parameters. Reality will use this format:


    Code:
    AttributeBegin
    NamedMaterial "material_name_assigned_by_Reality"
    Shape "plymesh" ... (various properties) ... "string filename" ["/path/to/.ply"]
    AttributeEnd

    Materials are applied with the NamedMaterial parameter. Therefore, to apply a material, the value of that paramater to the name of your new material which, in this case, is 'Jade'. So if I wanted to apply my material 'Jade' I'd make the following edits:


    Code:
    AttributeBegin
    NamedMaterial "Jade"
    Shape "plymesh" ... (various properties) "string filename" ["/path/to/.ply"]
    AttributeEnd

    If you're using a basic texture, you can stop here. If you're using a volume, see step 5b.


    Step 5b (for volumes only): Add exterior and interior volumes


    If your using a volume, you'll also need to set the Interior and Exterior parameters. Without these, there's a good chance your new material won't render as expected.





    The ball material is definitely being affected, it's not looking so Jade-tastic. To get the actual effect we are looking for, we have to also apply the interior and exteriors to the object configurations. Usually I apply it right after the NamedMaterial parameter. This is what my object configuration looks like:


    Code:
    AttributeBegin
    NamedMaterial "Jade"
    Interior "Jade"
    Exterior "world"
    Shape "plymesh" "bool smooth" ["false"] "string filename" ["/path/to/.ply"]
    AttributeEnd

    Step 6: Render!


    Save your .lxo file. Like the .lxs file, you can save it as a copy, but you'll have to go back into your .lxs file and change the path to look for this new file.





    That should do it! Render and make sure no shinanigans occur! Hopefully all goes well.

    Happy Rendering!
    Last edited by tgunner; 03-30-2013 at 07:52 PM.
    DeviantArt Gallery: http://tgunner.deviantart.com

  2. #2
    Would it be possible to move this to the "D|S Reality Tips, Techniques, & Recipes thread?"

  3. #3
    Does one need to go through this procedure for every scene? I imagined that, as Reality can assign a standard material to a surface (say glass or metal) then it might be possible to install additional materials from the database. Is there no way of importing materials into LuxRender or am I completely off the tracks?

    Ahh .. a bit more searching and it seems that the makers of Luxus have a beta version of an importer:

    Eluxir is a work in progress. Its purpose is to simplify using the full power of LuxRender's materials, textures, and volumes. Although it is incomplete, Eluxir is currently usable, and not just for those who use Luxus. Anyone who uses LuxRender can benefit.
    Unfortunately:

    Sorry no Mac version at this time. The Mac compiler has a dynamic_cast bug that makes it so a Shader Mixer extension won't work. DAZ has assured Spheric Labs they have implemented a workaround that should become available with the next beta release of DAZ Studio
    Edit: So it seems that this Eluxir has already been discussed and the response from Paolo was:

    More likely Reality user will be interested in Reality 3, in which they can get all the benefits of editing a network of Lux textures without having to use a graph/node system.
    Now if, by graph/node system we are talking about the DAZ shader mixer/builder thingy, I found that a nightmare to play with. So I'm interested in what is meant by "editing a network of Lux textures". Does this imply an importer or an add-on tool?
    Last edited by marble; 04-09-2013 at 02:30 PM.

  4. #4
    OK - a bit more digging and I unearthed the very same question in the Poser/Reality 3 forum ...

    http://forum.runtimedna.com/showthre...l=1#post742851

  5. #5
    I might be talking about the wrong thing, but here is what I believe he is referring to.

    In LuxRender there are terms that appear to be interchangeable when in actuality they refer to different things. Materials and textures are two such terms. A texture is (in essence, I'm oversimplifying) the information LuxRender needs to load a specific image file to be mapped. In addition to its location on the computer, this information as indicates things like the dimensions it uses. There are different types of texture (diffuse maps, normal maps, displacement maps, specular maps, bump maps, transparency maps) and each texture can have characteristics specific to its intended purpose, textures themselves do not define how they are used when rendered. That job is left to materials.

    A Materials takes a textures and uses it to calculate various simulated light interactions. A materials will say "this texture shall appear glossy and this one will appear matte". Materials, not textures, are what are ultimately loaded onto a geometry.

    The same texture can be used by many materials, and one material can say a texture looks like metal while another will say that same texture looks like glass. Furthermore, materials can reference other materials and form composite materials. This scenario can create a huge web of interrelated materials and textures.

    If my description sounds confusing. Try to think of cooking. Ingredients are like textures. All your eggs maybe completely identical in every way, but the way one egg (we'll call it a diffuse map) is used may be different from another egg (used instead as a transparency map) and the resulting dishes may look nothing alike. Adding in other ingredients like salt (let's say specular maps) and pepper (bump map, obviously) change the resulting dish even more. Each resulting dish is a material (it's not a perfect analogy, but I'm really hungry).
    Last edited by tgunner; 04-09-2013 at 09:22 PM.
    DeviantArt Gallery: http://tgunner.deviantart.com

  6. #6
    Yes, it is confusing. For example: Reality translates the material for the eye tear as glass but there is a material for water. I tried water and the result was an unholy mess. So it is not as intuitive as one might think.

    Nevertheless, I believe there are some 60+ "materials" in the material database with descriptions such as "chocolate" and the example above of "Jade". Apart from a preset level of matte or gloss I',m still not sure what else is defined. In DAZ Studio, for example, the surfaces tab allows me to change parameters such as the jpeg image used, the bump/displacement levels, opacity, the ambient colour and strength, the tiling of the image, the specular and gloss, etc. Are there direct equivalents to all of these in Reality/Luxrender? Have I just not found them all?

    Or am I beginning to see the light now(excuse the pun)? Are we saying that a "material" is actually a preset? It is a definition with presets for all of those surface parameters dialled-in already to create the look of glass or metal so that we don't have to spend hours guessing and tweaking?
    Last edited by marble; 04-10-2013 at 12:54 AM.

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Get Social with RDNA:
Runtime DNA Inc 1-877-789-8849 (M-F 9A-5P EST)
Copyright 2001-2013 All Rights Reserved