This patch adds a Hydra render delegate to Cycles, allowing Cycles to be used for rendering in applications that provide a Hydra viewport. The implementation was written from scratch against Cycles X, for integration into the Blender repository to make it possible to continue developing it in step with the rest of Cycles. For this purpose it follows the style of the rest of the Cycles code and can be built with a CMake option (`WITH_CYCLES_HYDRA_RENDER_DELEGATE=1`) similar to the existing standalone version of Cycles. Since Hydra render delegates need to be built against the exact USD version and other dependencies as the target application is using, this is intended to be built separate from Blender (`WITH_BLENDER=0` CMake option) and with support for library versions different from what Blender is using. As such the CMake build scripts for Windows had to be modified slightly, so that the Cycles Hydra render delegate can e.g. be built with MSVC 2017 again even though Blender requires MSVC 2019 now, and it's possible to specify custom paths to the USD SDK etc. The codebase supports building against the latest USD release 22.03 and all the way back to USD 20.08 (with some limitations). Reviewed By: brecht, LazyDodo Differential Revision: https://developer.blender.org/D14398
55 lines
1.6 KiB
C++
55 lines
1.6 KiB
C++
/* SPDX-License-Identifier: Apache-2.0
|
|
* Copyright 2022 NVIDIA Corporation
|
|
* Copyright 2022 Blender Foundation */
|
|
|
|
#pragma once
|
|
|
|
#include "hydra/config.h"
|
|
|
|
#include <pxr/imaging/hd/rprim.h>
|
|
|
|
HDCYCLES_NAMESPACE_OPEN_SCOPE
|
|
|
|
template<typename Base, typename CyclesBase> class HdCyclesGeometry : public Base {
|
|
public:
|
|
HdCyclesGeometry(const PXR_NS::SdfPath &rprimId
|
|
#if PXR_VERSION < 2102
|
|
,
|
|
const PXR_NS::SdfPath &instancerId
|
|
#endif
|
|
);
|
|
|
|
void Sync(PXR_NS::HdSceneDelegate *sceneDelegate,
|
|
PXR_NS::HdRenderParam *renderParam,
|
|
PXR_NS::HdDirtyBits *dirtyBits,
|
|
const PXR_NS::TfToken &reprToken) override;
|
|
|
|
PXR_NS::HdDirtyBits GetInitialDirtyBitsMask() const override;
|
|
|
|
virtual void Finalize(PXR_NS::HdRenderParam *renderParam) override;
|
|
|
|
protected:
|
|
void _InitRepr(const PXR_NS::TfToken &reprToken, PXR_NS::HdDirtyBits *dirtyBits) override;
|
|
|
|
PXR_NS::HdDirtyBits _PropagateDirtyBits(PXR_NS::HdDirtyBits bits) const override;
|
|
|
|
virtual void Populate(PXR_NS::HdSceneDelegate *sceneDelegate,
|
|
PXR_NS::HdDirtyBits dirtyBits,
|
|
bool &rebuild) = 0;
|
|
|
|
PXR_NS::HdInterpolation GetPrimvarInterpolation(PXR_NS::HdSceneDelegate *sceneDelegate,
|
|
const PXR_NS::TfToken &name) const;
|
|
|
|
CyclesBase *_geom = nullptr;
|
|
std::vector<CCL_NS::Object *> _instances;
|
|
|
|
private:
|
|
void Initialize(PXR_NS::HdRenderParam *renderParam);
|
|
|
|
void InitializeInstance(int index);
|
|
|
|
PXR_NS::GfMatrix4d _geomTransform;
|
|
};
|
|
|
|
HDCYCLES_NAMESPACE_CLOSE_SCOPE
|