~wahn/wahn-rnd-org

14425bef74ffdb376c7f80dd67ef9c30e6d8f484 — Jan Walter 9 months ago 3b83b10
See https://www.janwalter.org/rnd/blog/rnd-blender-arnold-004/ ...
M zola/content/rnd-blender-arnold-002/index.md => zola/content/rnd-blender-arnold-002/index.md +1 -1
@@ 5,7 5,7 @@ draft = false

[taxonomies]
categories = ["DCC"]
tags = ["blender", "arnold"]
tags = ["blender", "arnold", "python"]
+++

The last part ([Blender to Arnold Export - Part I: The

A zola/content/rnd-blender-arnold-004/blender-4.0-splash-arnold.png => zola/content/rnd-blender-arnold-004/blender-4.0-splash-arnold.png +0 -0
A zola/content/rnd-blender-arnold-004/blender-4.0-splash-cycles.png => zola/content/rnd-blender-arnold-004/blender-4.0-splash-cycles.png +0 -0
A zola/content/rnd-blender-arnold-004/index.md => zola/content/rnd-blender-arnold-004/index.md +66 -0
@@ 0,0 1,66 @@
+++
title = "Blender to Arnold Export - Part IV: Blender 4.0 Splash Screen"
date = 2023-11-27
draft = false

[taxonomies]
categories = ["DCC"]
tags = ["blender", "arnold", "python"]
+++

The last part ([Blender to Arnold Export - Part III: Base
 Color](@/rnd-blender-arnold-003/index.md)) talked about exporting
 some color information (from [Blender](https://www.blender.org))
 instead of using full materials/shaders. So basically the **light
 sources** are still not taken into account. But can we export the
 latest `Splash Screen` (for `Blender 4.0`) to
 [Arnold](https://arnoldrenderer.com)?

![Blender 4.0 Splash Screen rendered by
Cycles](./blender-4.0-splash-cycles.png)

The image above was rendered by
[Cycles](https://www.cycles-renderer.org). I had to modify the
[Python](https://www.python.org) code a bit to export the camera in
case it's not part of a `Collection`.

```python
...
class AssExporter:
    def __init__(self):
        self.filename = None

    def export(self, context, filename, use_shader_file, use_shader_file_only):
        def exportMaterials():...
        def exportCamera():...
...
            print('DEBUG: export collections ...')
...
                            if me is None:
                                if ob.type == 'CAMERA':
                                    if ob.name == camera_name:
                                        exportCamera()
...
        if not camera_exported and len(bpy.data.cameras) >= 1:
            # camera was not part of a collection
            objects = bpy.data.objects
            for i, ob_main in enumerate(objects):
                obs = [(ob_main, ob_main.matrix_world)]
                for ob, ob_mat in obs:
                    if ob.name == camera_name:
                        print('DEBUG: export camera ...')
                        exportCamera()
...
```

The current source code can be found on
[Codeberg](https://codeberg.org/wahn/Arnold/src/branch/master/blender/io_scene_ass). The
Python source code is probably changing with the latest Blender
releases, whenever I feel the need to render at least a similar scene
with Arnold.

![Blender 4.0 Splash Screen rendered by Arnold](./blender-4.0-splash-arnold.png)

This is it for now. On the `TODO` list is being aware of `subdivision
surfaces` during the export and taking `lights` into account (which
needs also proper `materials/shaders`).