### Purpose
Following warning in Storm delegate could happen with multimaterials:
`Invalid Hydra prim '/scene/O_000001C64A534808/SM_0001': Vertex primvar points has 42 elements, while its topology references only upto element index 40.`
### Technical steps
Moved vertices to `MeshData::SubMesh`. Optimized SubMesh to hold only used vertices.
Pull Request BogdanNagirniak/blender#84
### Purpose
Crash on MacOS.
### Technical steps
1. For MacOS `RenderTaskDelegate` is created instead of `GPURenderTaskDelegate`.
2. Disabled `skydome_task` for MacOS.
3. Improved some logging.
### Notes
Need to fix Skydome.
Pull Request BogdanNagirniak/blender#82
### Purpose
After code refactor in #75 there is good to adjust logging + do code polishing and improvement.
### Technical steps
1. Renamed logger `LOG_RENDER_HYDRA_SCENE -> LOG_HYDRA_SCENE` as "hydra.scene".
2. Renamed logger `LOG_RENDER_HYDRA -> LOG_HYDRA_RENDER` as "hydra.render".
3. Simplified `Engine` classes by adding `depsgraph_`, `context_` and `scene_` to class fields. Unified structure of `Engine` classes.
4. Moved AOV tokens map to `FinalEngine` as more related.
5. Made other code cleanups and improvements.
Pull Request BogdanNagirniak/blender#81
### Purpose
After refactoring PRs there are render issues such as crash with RPR delegate in viewport.
### Technical steps
1. Moved binding of framebuffer and VAO to `GPURenderTaskDelegate` and use it in Viewport render.
2. Made more correct viewport render for Storm delegate by rendering it to separate framebuffer.
Pull Request BogdanNagirniak/blender#79
* Makes it more consistent with other types that can be subclassed.
* Give bl_ prefix to delegate_id.
* Lazily import _bpy_hydra.
* Tweaks to API docs example.
Pull Request: BogdanNagirniak/blender#77
To make it more clear that these are closely related and should stay in
sync as much as possible.
Also
* Rename BlenderSceneDelegate to HydraSceneDelegate, to go along with
with USDSceneDelegate.
* Move MaterialX code into material.cc.
Pull Request: BogdanNagirniak/blender#75
The context is temporary and changes over time depending on the
operation Blender is doing. That means holding on to it in the scene
delegate is not safe. Instead extract the members from it beforehand.
Pull Request #76
None of these textures need filtering or mipmaps. These are not scaled
for drawing, and even if they were used for image editor drawing with
zoom the consistent thing would still be to use nearest interpolation.
### Purpose
Curves and volumes are supported objects but not working as instances.
### Technical steps
1. Changed `InstancerData::LightInstance` to `InstancerData::NonmeshInstance` which supports all other object types except mesh.
2. Adjusted `update_nonmesh_instance` to support all object types.
3. Made code adjustments and renamings.
Pull Request BogdanNagirniak/blender#74
### Purpose
Code for `RenderTaskDelegate` is obsolete + working with separate framebuffer for GPU engines instead of aov is hard to maintain.
This is preparation for supporting more AOVs and GL context with core profile mode.
### Technical steps
1. Moved working with `GPUTexture` and `GPUFramebuffer` to `RenderTaskDelegate`. Now it is working the same as AOVs. Added `class GPURenderTaskDelegate : public RenderTaskDelegate`. Improved structure of `class RenderTaskDelegate`.
2. Removed `FinalEngineGPU`, `PreviewEngineGPU` as not needed, as forking with render framebuffer moved to `RenderTaskDelegate`. Simplified `PreviewEngine`.
3. Additionally improved structure of `LightTasksDelegate` for easier to maintain.
4. Adjusted `FinalEngine` and `ViewportEngine`.
Pull Request BogdanNagirniak/blender#73
### Purpose
Implement transparent background for Storm delegate.
### Technical steps
Utilized scene.render.film_transparent build-in blender property for Storm delegate.
Adjusted clear_color to alpha 0.0 for final render.
### Notes for reviewers
Should be reviewed with the pull request BogdanNagirniak/blender-addons#21
Pull Request BogdanNagirniak/blender#71
### Purpose
Make available Strom delegate to utilize for material preview.
### Technical steps
- Implemented PreviewEngineGPU::render. Similar to FinalEngineGPU::render.
- Adjusted python.cc to use PreviewEngineGPU.
### Notes for reviewers
Should be reviewed with the pull request BogdanNagirniak/blender-addons#20
Pull Request BogdanNagirniak/blender#69
### Purpose
Make world color and texture visible for Storm delegate.
### Technical steps
- Implemented LightTasksDelegate.
- Updates CMakeLists.txt with light_tasks_delegate.h, light_tasks_delegate.cc.
- Appended HdTaskSharedPtrVector with light_tasks_delegate_.
Pull Request BogdanNagirniak/blender#68
### Purpose
Some code has to be refactored after BogdanNagirniak/blender#57:
- Remove unused code
- Improve structure of ID classes
This is preparation for instancing curves and volumes.
### Technical steps
1. Improved structure of classes `IdData` and `ObjectData`, adjusted child classes.
2. Changed inheritance: `WorldData: LightData`.
3. Added `ObjectData::get_or_create_material()`, simplified child classes.
4. Removed unused code.
5. Improved logging.
6. Fixed crash with `MaterialPreview`.
Pull Request BogdanNagirniak/blender#67
The Hydra Storm add-on already had a setting to use a USD file, with
associated sync_usd API function. But this way works for all Hydra
engines and doesn't require manually exporting a USD file each time.
Pull Request #65
* Fix build when WITH_USD and WITH_MATERIALX are disabled
* Link issue with mixed Clang and GCC libs
* Unused arguments
* Different integer printf types on Windows and Linux
Pull Request #63
### Purpose
Final render for Storm delegate returns empty image.
### Technical steps
1. Added comment in `bpy_hydra.py` that if `bl_use_gpu_context` is enabled then `update()` should be empty and engine cretaion and syncing has to moved to `render()`. Corresponded PR for Storm Hydra addon BogdanNagirniak/blender-addons#17.
2. Renamed `FinalEngineGL -> FinalEngineGPU` as more related.
3. Fixed `FinalEngineGPU::render()` to works with Storm delegate.
4. Fixed CullStyle for mesh and material.
5. Improved logging.
Pull Request BogdanNagirniak/blender#61
### Purpose
Fix code review comments:
#104712 (comment)#104712 (comment)#104712 (comment)
### Technical steps
1. Made getting object visibility from depsgraph without using custom functionality.
2. Made instancing creation to be calculated from depsgraph. Moved to to use one `InstancerData` in `BlenderSceneDelegate` for whole scene.
3. Removed unused code.
Pull Request BogdanNagirniak/blender#57
### Purpose
Add support `EnvironmentTexture` node for world
### Technical steps
* Add support `EnvironmentTexture` node for world
* added `DomeLight` transform not only for HdRPR
* fixed bug when image save options where not applied
Pull Request BogdanNagirniak/blender#59
### Purpose
Implement Viewport render with material preview
### Technical steps
* Fixed issue with wrong `std::string` usage which leads to incorrect behavior;
* Added special checks for various options of material preview;
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request BogdanNagirniak/blender#56
### Purpose
Storm delegate produces warning if not texture in DomeLight: `Warning: in _GetResolvedDomeLightEnvironmentFilePath at line 320 of C:\db\build\S\VS1564R\build\usd\src\external_usd\pxr\imaging\hdSt\simpleLightingShader.cpp -- Dome light has no texture asset path.`
### Technical steps
Implemented cache_image_color() to image.cc.
Added pxr::HdLightTokens->textureFile to WorldData with colored texture if only color is available.
Pull Request BogdanNagirniak/blender#55
### Purpose
Fix infinite loop in preview render when generated image cached.
### Technical steps
Caching images moved from python to C++ part so caching no more triggers Depsgraph updates;
Added `cache_image_func`;
Fixed caching logic;
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request BogdanNagirniak/blender#53
### Purpose
Mesh UV coords aren't translated to Storm delegate.
### Technical steps
Changed mesh primvar name for UVs to `st` which is primary name in HdStorm.
Added private token: `st`
Pull Request BogdanNagirniak/blender#54
### Purpose
For testing purposes it'll be useful to have possibility to render USD stage.
### Technical steps
- Added `usd_delegate_ (class UsdImagingDelegate)` and `sync_usd()` to `class Engine`
- Added `engine_sync_usd_func()` in `python.cc`
### Notes
Can be tested with Storm delegate BogdanNagirniak/blender-addons#14
Pull Request BogdanNagirniak/blender#49
### Purpose
Implement Curves export.
### Technical steps
New class CurvesData.
### Note for reviewers
Applying any material on Curves causes wrong behavior and crash on RPR side (HdStorm work fine). Will discuss it with RPR team.
Pull Request BogdanNagirniak/blender#46
Purpose
Fix various visibility settings for objects and instances.
Technical steps
* Added static functions `is_visible` for `InstanceData` and `ObjectData`
* Instance visibility performed via `ObjectData::update_parent()`
* Fixed update on scene update
* Reworked algorithm of visibility identification
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request BogdanNagirniak/blender#43
### Purpose
Hydra doesn't support multimaterials assigned to one mesh, therefore we have to split mesh to submeshes with one material.
### Technical steps
1. Changed structure of `MeshData` to support submeshes for one material:
- added `MeshData::SubMesh`
- moved mesh export to `write_submeshes()`
- implemented more correct material assignment.
2. Adjusted `InstancerData` due to submeshes in `MeshData`.
3. Adjusted `BlenderSceneDelegate`.
Pull Request BogdanNagirniak/blender#44
### Purpose
Hydra render addons could provide additional settings for `BlenderSceneDelegate`, like HdRPR could ask for direct `MaterialXFilename`.
### Technical steps
1. Separated setting render and sync settings in `Engine`: added `Engine::set_sync_setting(), Engine::set_render_setting()`. Added corresponded functions to `python.cc` and `bpy_hydra.py`.
2. Added possibility to provide additional settings for `BlenderSceneDelegate`: `BlenderSceneDelegate::set_setting()`.
3. Separated `MaterialData::init()` to `export_mtlx()` and `write_material_network_map()`.
4. Adjusted code.
Pull Request BogdanNagirniak/blender#41
### Purpose
GetDoubleSided and GetCullStyle has to be implemented for BlenderSceneDelegate. It is especially important for HdStorm.
### Technical steps
1. `double_sided` option is material property, not mesh, therefore it was translated from MaterialData to MeshData.
2. Implemented set of `DirtyDoubleSided` for mesh when it was changed for material.
Pull Request BogdanNagirniak/blender#38
### Purpose
Fix rendering of Car Demo scene.
### Technical steps
Improved support for instancers type of EMPTY object.
Adjusted condition for `update_instancers` and `available_objects`.
Pull Request BogdanNagirniak/blender#37
### Purpose
Recreate `PreviewEngine` when `render_delegate_name` is changed.
### Technical steps
Added comparison of `render_delegate_name` and `PreviewEngine` re-creation on `PreviewEngine::update`
Added/updated some comments.
Pull Request BogdanNagirniak/blender#36
### Purpose
Instancing of light objects isn't working yet. It differs from mesh instancing, because they light instances has to be created as separate light prims for HdRenderIndex.
### Technical steps
1. Separated `MeshInstance` and `LightInstance` in `Instancer` class.
2. Implemented `Instancer` to create light instances as separate prims for HdRenderIndex.
3. Fixed light update.
4. Fixed Instancer transform update for HdStorm.
Pull Request BogdanNagirniak/blender#35
### Purpose
Changing parent object for mesh doesn't influence to instancer, when parent object is instancer.
### Technical steps
1. Added `MeshData::parent_` field for checking parent object changes.
2. Implemented `InstancerData::update_as_parent()` and call it when parent is changed.
3. Fixed bug with positioning instance mesh after update.
Pull Request BogdanNagirniak/blender#33
### Purpose
Currently we catch all exceptions in `bpy_hydra.export_mtlx()`, because of memory issues.
### Technical steps
1. Removed `except:` and `traceback.print_exc()` from `bpy_hydra.export_mtlx()`.
2. Applied `PyErr_Fetch()` instead `PyErr_Print()` to correctly free exception data.
Pull Request BogdanNagirniak/blender#28
### Purpose
Add support for ".exr" image extention for DomeLight
### Technical steps
1. Refactored:
- moved `cache_image_file()` from `utils.cc` to `scene_delegate/image.cc`
- moved `gf_matrix_from_transform()` from `utils.cc` to `scene_delegate/object.cc`
- removed `utils.cc` as not needed.
2. Implemented more correct image caching.
3. Adjusted passing image for DomeLight.
4. Added copying hioOiio folder.
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request BogdanNagirniak/blender#29
### Purpose
Refactoring to match Blender's team requirements and code style.
### Technical steps
Simplified `FinalEngine`, `FinalEngineGL` and `PreviewEngine` with `FinalEngine::prepare_for_render`
Added `render_delegate_name` to `BlenderSceneDelegate` and `Engine`
Pull Request BogdanNagirniak/blender#31
### Purpose
Made some code refactoring after implementing instances for better maintain code in future + added bug fixes.
### Technical steps
1. Refactor:
- Moved `prim_id()` functions from `IdData` classes to `BlenderSceneDelegate` as more related
- Moved to use `ObjectData::transform` as a field for better maintain it
- Made some fields as public in `BlenderSceneDelegate` as logically more related and as they use in `IdData` classes. Made some fields in `IdData` as public. Removed some friends classes
- Added `const` to some methods
- Renamed some fields
2. Bug fixes:
- Fixed crash with Storm delegate after finish render
- Fixed scene update after removing world object from scene
Pull Request BogdanNagirniak/blender#26
### Purpose
Instancer object could provide instances for its children objects, but we support only one instance object. Also removing/changing/adding of instancer object isn't working correctly.
### Technical steps
1. Restructured `InstancerData`:
- now it could hold several `ObjectData` which are instances
- restructured order of instancer and instance objects in `RenderIndex`.
2. Refactoring:
- improved logging in `IdData` children classes
- splitted `populate()` and `update_collection()` in `BlenderSceneDelegate` to several functions for more flexibility.
3. Improved/fixed:
- object updates (transform, mesh update, remove) inside instancer
- instancer updates (transform, update, remove).
Pull Request BogdanNagirniak/blender#24
**Purpose**
`PreviewEngine` shouldn’t be recreated every time when material is changed.
**Technical steps**
Python:
1. Creation and sync of engine moved to `def update`
C++:
1. Added delayed deletion for `PreviewEngine` (180 sec for now). Timer is refreshed with every change;
2. Moved creation of `BlenderSceneDelegate` from every `Engine`'s inheritor to `Engine::Engine`;
3. `PreviewEngine::sync` clears `render_index` and `scene_delegate`'s data;
Co-authored-by: Bogdan Nagirniak <bodyan@gmail.com>
Pull Request BogdanNagirniak/blender#21
### Purpose
We have to use GPU API instead OpenGL
### Technical steps
1. Rewritten code in GLTexture, renamed GLTexture -> DrawTexture.
Improved: moved GPUBatch creation to constructor instead creating it in draw().
2. Rewritten code in FinalEngineGL.
3. Cleaned up CMakeLists.txt.
### Notes
FinalEngineGL still shows empty picture, this bug isn't fixed here.
Pull Request [#23](BogdanNagirniak/blender#23)
### Purpose
Instances aren't correctly applied in scene delegate + updates instances in viewport isn't working.
### Technical steps
1. Refactoring:
* updated interface of IdData class: added base methods `init() insert() remove() update()` which should be overrided in child classes
* moved object update to `update()` instead recreation of IdData
2. Implemented InstancerData class.
* moved instancer related code to InstancerData, improved working with instances transforms
* adjusted BlenderSceneDelegate code to work with InstancerData
3. Implemented updates of instanced due to:
* parent object changes: transform, mesh changes, add/remove
* base mesh changes: transform, mesh changes, add/remove
### Notes
This is not final changes in instances here. We work only with one instancer for parent object, but it could have several instancers.
Pull Request [#20](BogdanNagirniak/blender#20)
### Purpose
Fix build code due to code review comments.
### Technical steps
1. Set WITH_HYDRA option ON for all platforms.
2. Removed unnecessary build flags.
3. Removed copying plugin/usd/hdStorm, it has to be moved to Hydra storm addon
### Notes
Storm is working with BogdanNagirniak/blender-addons#6
Pull Request #18
### Purpose
CLOG logger should be used.
### Technical steps
Changed logger from GLOG to CLOG, adjusted log messages. Improved some logs.
### Notes
CLOG_INFO can be tested by running `blender.exe --log-level 3 --log rhd.* <--log-show-timestamp> <--log-show-basename>`
Pull Request #16
### Purpose
There is still part of code which use RNA API instead of native DNA API.
### Technical steps
1. Changed to DNA API in: camera.cc/.h, engine files.
2. Added set_env_paths() to utils.
3. Made some renamings.
Pull Request #12
* added check for empty mesh returned by object.to_mesh() function
* added check for world input node
* removed OB_CURVES from list of supported objects
Pull Request #13
Created mtlxHydraAdapter.h\cc. Adjusted MaterialData.
Storm does not work correctly. It'll be fixed in a separate PR because they are unrelated to the mtlx integration.
Pull Request #5
Apparently, Storm's Hydra implementation is not fully encapsulated in the render delegate. It's partially contained in the Hdx module. Storm requires HdxSimpleLightTask to be present in the graph.
Pull Request #6
### Purpose
RNA API supposed to use in python bindings. DNA API is much more flexible and powerful.
### Technical steps
1. Moved depsgraph export and updates to DNA API.
2. Moved update_visibility() implementation to update_collection().
3. Adjusted depsgraph and context pointers.
4. Preparations for export instances: added InstanceData class.
### Purpose
Move geometry export, working with HdRenderIndex to ObjectData classes, to be more flexible in future.
Fix area light visibility + normalize intensity.
### Technical steps
1. Refactored ObjectData class: separated code to hierarchic classes IdData, ObjectData, MaterialData, MeshData, LightData.
2. Moved working with HdRenderIndex (Insert/remove/mark_dirty) from BlenderSceneDelegate to \*Data classes.
3. Fixed area light visibility, normalized intensity.
Co-authored-by: Bogdan Nagirniak <bnagirniak@luxoft.com>
Pull Request #2
### Purpose
Add initial implementation of export environment light to hydra. Both color and images supported.
### Technical steps
Added caching images.
Added new class `WorldData`.
How it works:
1. find output node for word light;
2. find linked node and read inputs;
3. if `color` linked with image - cache image on disk;
Use with https://github.com/bnagirniak/RPRHydraRenderBlenderAddon/pull/6
Co-authored-by: georgiy.m.markelov@gmail.com <georgiy.m.markelov@gmail.com>
Pull Request #1
1. Changed syncing logic for objects, now they'll be stored in ObjectData class which holds required data for object like mesh (+meshables), light, camera. Not everything is implemented yet. Export of object data is moved to object.cc.
2. Iterating through depsgraph is still use RNA API.
3. Improved working with objects for future implementations.
4. BlenderSceneDelegate::Populate() funcions splitted to several functions for better support.
Refactor c++ part:
- moved project extern_usdhydra to blender/source/render/hydra and renamed to bf_render_hydra
- renamed cmake key: WITH_USDHYDRA -> WITH_HYDRA
- renamed namespace to blender::render::hydra
- moved code from finalEngineGL.cpp/.h to finalEngine.cpp/.h
- moved py api code from engine.cpp to python.cpp
- Renamed *.cpp -> *.cc.
Refactor python part:
- moved python code to release/scripts/modules/hydra.py
- removed storm and addon code, as it became a module.
Implemented assignment of materials in BlenderSceneDelegate.
Made material conversion to .mtlx using MaterialX plugin by calling python code from c++.
Implemented material update/add/remove in viewport.
Added UVs export.
Made code improvements.
Added light export to Hydra. Made light to be updated, added/removed in viewport.
Added panel with Light properties.
Co-authored-by: Bogdan Nagirniak <bnagirniak@luxoft.com>
Make code to use HdxRenderTask and HdxRenderTaskParams.
Implemented viewport render for RPR delegate.
Updated RenderTaskDelegate to support updates.
Splitted engine.h -> engine.h, finalEngine.h, viewportEngine.h
Removed unused code related to USD stages.
Added initial code for Blender scene delegate.
Made UsdImagingLite to use BlenderSceneDelegate.
Basic implementation providing mesh data in BlenderSceneDelegate.
Refactor:
- Moved code from camera.cpp, view_settings.cpp to viewportEngine.cpp
- Moved related code to finalEngine.cpp and viewportEngine.cpp
- Removed stage.cpp/h, camera.cpp/h, view_settings.cpp/h.
Removed unused includes.
Removed unused functions.
Added stage_export_to_str_func() to engine.cpp.
Renamed session.h/cpp -> engine.h/cpp.
Created classes Engine, FinalEngine, ViewportEngine. Moved code from BlenderSession to Engine classes.
Simplified python and c++ code.