Fix rendering of Final render for Storm delegate #61

Merged
Bogdan Nagirniak merged 11 commits from BLEN-437 into hydra-render 2023-07-12 23:18:03 +02:00
8 changed files with 27 additions and 15 deletions
Showing only changes of commit fd68f0ca34 - Show all commits

View File

@ -246,13 +246,13 @@ void FinalEngineGL::render1(Depsgraph *depsgraph)
{
prepare_for_render(depsgraph);
//pxr::TraceCollector::GetInstance().SetEnabled(true);
// pxr::TraceCollector::GetInstance().SetEnabled(true);
auto d = pxr::GlfDrawTarget::New(resolution_);
d->Bind();
d->AddAttachment("color", GL_RGBA, GL_FLOAT, GL_RGBA);
engine_->Execute(render_index_.get(), &tasks_);
//d->Unbind();
// d->Unbind();
std::vector<float> &pixels = render_images_["Combined"];
char elapsed_time[32];
@ -281,8 +281,8 @@ void FinalEngineGL::render1(Depsgraph *depsgraph)
GLuint rendered_texture;
//glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
//update_render_result();
// glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pixels.data());
// update_render_result();
pxr::TraceCollector::GetInstance().SetEnabled(false);
}

View File

@ -178,7 +178,7 @@ bool BlenderSceneDelegate::GetDoubleSided(pxr::SdfPath const &id)
pxr::HdCullStyle BlenderSceneDelegate::GetCullStyle(pxr::SdfPath const &id)
{
CLOG_INFO(LOG_RENDER_HYDRA_SCENE, 3, "%s", id.GetText());
return mesh_data(id)->cull_style;
return mesh_data(id)->cull_style(id);
}
pxr::SdfPath BlenderSceneDelegate::GetInstancerId(pxr::SdfPath const &prim_id)

View File

@ -89,6 +89,11 @@ pxr::VtValue MaterialData::get_material_resource() const
return material_network_map_;
}
pxr::HdCullStyle MaterialData::cull_style() const
{
return double_sided ? pxr::HdCullStyle::HdCullStyleNothing : pxr::HdCullStyle::HdCullStyleBack;
BogdanNagirniak marked this conversation as resolved
Review

Check please value with mesh::cull_style()

Check please value with `mesh::cull_style()`
}
void MaterialData::export_mtlx()
{
/* Call of python function hydra.export_mtlx() */

View File

@ -3,7 +3,7 @@
#pragma once
#include "pxr/base/tf/hashmap.h"
#include <pxr/imaging/hd/enums.h>
#include <pxr/usd/sdf/assetPath.h>
#include <pxr/usd/sdf/path.h>
@ -27,6 +27,7 @@ class MaterialData : public IdData {
pxr::VtValue get_data(pxr::TfToken const &key) const override;
pxr::VtValue get_material_resource() const;
pxr::HdCullStyle cull_style() const;
bool double_sided = true;

View File

@ -149,6 +149,15 @@ pxr::SdfPath MeshData::material_id(pxr::SdfPath const &id) const
return sm.mat_data->prim_id;
}
pxr::HdCullStyle MeshData::cull_style(pxr::SdfPath const &id) const
{
const SubMesh &sm = submesh(id);
if (sm.mat_data) {
return sm.mat_data->cull_style();
}
return pxr::HdCullStyle::HdCullStyleDontCare;
}
bool MeshData::double_sided(pxr::SdfPath const &id) const
{
const SubMesh &sm = submesh(id);
@ -163,7 +172,8 @@ void MeshData::update_double_sided(MaterialData *mat_data)
for (int i = 0; i < submeshes_.size(); ++i) {
if (submeshes_[i].mat_data == mat_data) {
scene_delegate_->GetRenderIndex().GetChangeTracker().MarkRprimDirty(
submesh_prim_id(i), pxr::HdChangeTracker::DirtyDoubleSided);
submesh_prim_id(i),
pxr::HdChangeTracker::DirtyDoubleSided | pxr::HdChangeTracker::DirtyCullStyle);
ID_LOG(1, "%d", i);
}
}

View File

@ -38,13 +38,12 @@ class MeshData : public ObjectData {
pxr::HdMeshTopology mesh_topology(pxr::SdfPath const &id) const;
pxr::HdPrimvarDescriptorVector primvar_descriptors(pxr::HdInterpolation interpolation) const;
pxr::SdfPath material_id(pxr::SdfPath const &id) const;
pxr::HdCullStyle cull_style(pxr::SdfPath const &id) const;
bool double_sided(pxr::SdfPath const &id) const;
void update_double_sided(MaterialData *mat_data);
void available_materials(Set<pxr::SdfPath> &paths) const;
pxr::SdfPathVector submesh_paths() const;
pxr::HdCullStyle cull_style = pxr::HdCullStyleBack;
private:
pxr::SdfPath submesh_prim_id(int index) const;
const SubMesh &submesh(pxr::SdfPath const &id) const;

View File

@ -176,11 +176,8 @@ void WorldData::write_transform()
{
transform = pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -90), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0),
pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(1.0, 0.0, 0.0), -180), pxr::GfVec3d());
transform *= pxr::GfMatrix4d(pxr::GfRotation(pxr::GfVec3d(0.0, 0.0, 1.0), 90.0), pxr::GfVec3d());
}
} // namespace blender::render::hydra