wahn/rs_pbrt

[parse_blend_file] Attic Close-up

wahn opened this issue · 5 comments

wahn commented

On the Blender Cloud there is a project called Attic Close-up (by Gleb Alexandrov). You can download a Blender scene from there. The goal of this issue is to create a similar Blender (version 2.79) scene, which can be used to render directly with parse_blend_file (see examples folder).

wahn commented

The current Blender scene (using Cycles), which I downloaded from the Blender Cloud, renders like this:

attic_close_up_cloud

wahn commented

The current version of the Blender (2.79) scene does render already via parse_blend_file, but the light blocking geometry is not visible yet, because another light blocker (which uses a transparency texture) is currently blocking all light from the sun (directional light source):

pbrt

The lighting actually comes from two point lights, which are just fill lights and are in the original scene as well. The main lighting is supposed to come from the sun. So one task for this issue is to make parse_blend_file being aware of transparency textures and to adjust the scene for Blender 2.79 to be usable directly as input.

wahn commented

You can see that both kind of light blockers (geometry vs. texture) are already in the scene if you render via Cycles:

attic_close_up_v279_cycles_01

wahn commented

Before we can investigate how to store the transparency texture in a Blender (2.79) file (in a way that we can pick it up using the Blender DNA), we should look at another scene to see how this is done for Cycles. This scene can be exported via the multi exporter, a former Python add-on I used to export from Blender to many other renderers, including Luxrender and PBRT (v3):

attic_cycles_transparent_texture

Let's look into how this would be translated to a .pbrt (v3) file to understand how the add-on should translate this ... and later how this can be stored in the DNA to be picked up by parse_blend_file ...

wahn commented

I had to change the code for triangle meshes (see commit bbadb88) to allow the usage of an alpha texture (RGB for now) to hide geometry:

pbrt

In a .pbrt file that would look like this:

...
  # Plane                                                                                               
  Texture "Plane::Kd" "color" "imagemap"
    "string filename" ["textures/leaf.png"]
    "bool gamma" ["false"]
  Texture "Plane::alpha" "float" "imagemap"
    "string filename" ["textures/leaf_alpha.png"]
    "bool gamma" ["false"]
  MakeNamedMaterial "Plane"
    "string type" [ "matte" ]
    "texture Kd" [ "Plane::Kd" ]
...
  # Plane                                                                                               
  AttributeBegin
    Transform [
...
    ]
    NamedMaterial "Plane"
    Shape "trianglemesh"
      "point P" [
        -1.0 -1.0 0.0
        1.0 -1.0 0.0
        1.0 1.0 0.0
        -1.0 1.0 0.0
      ]
      "integer indices" [
        0 1 2
        0 2 3
      ]
      "float uv" [
        0.0 0.0
        1.0 0.0
        1.0 1.0
        0.0 1.0
      ]
      "texture alpha" [ "Plane::alpha" ]
      "texture shadowalpha" [ "Plane::alpha" ]
  AttributeEnd
...

Currently I can't use the alpha channel directly (needs to be improved at some point), instead I load two textures, one for the color (RGB), the other for alpha (still stored in an RGB image). The color texture is used in the material (for the diffuse color), and the alpha texture is used to hide geometry (from two triangles with texture coordinates). Be aware that alpha and shadowalpha are parameters of the Shape and are used in the ray intersection function.