forked from blender/blender
Fix rendering of Final render for Storm delegate #61
@ -114,7 +114,7 @@ void FinalEngine::prepare_for_render(Depsgraph *depsgraph)
|
|||||||
std::vector<float>(resolution_[0] * resolution_[1] * 4)); /* 4 - number of channels. */
|
std::vector<float>(resolution_[0] * resolution_[1] * 4)); /* 4 - number of channels. */
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalEngineGL::render0(Depsgraph *depsgraph)
|
void FinalEngineGL::render(Depsgraph *depsgraph)
|
||||||
{
|
{
|
||||||
prepare_for_render(depsgraph);
|
prepare_for_render(depsgraph);
|
||||||
|
|
||||||
@ -124,14 +124,15 @@ void FinalEngineGL::render0(Depsgraph *depsgraph)
|
|||||||
resolution_[1],
|
resolution_[1],
|
||||||
1,
|
1,
|
||||||
GPU_RGBA32F,
|
GPU_RGBA32F,
|
||||||
GPU_TEXTURE_USAGE_GENERAL,
|
GPU_TEXTURE_USAGE_ATTACHMENT,
|
||||||
nullptr);
|
nullptr);
|
||||||
GPU_texture_filter_mode(texture, true);
|
GPU_texture_filter_mode(texture, true);
|
||||||
GPU_texture_mipmap_mode(texture, true, true);
|
GPU_texture_mipmap_mode(texture, true, true);
|
||||||
GPU_framebuffer_texture_attach(framebuffer, texture, 0, 0);
|
|
||||||
|
|
||||||
GPU_framebuffer_bind(framebuffer);
|
GPU_framebuffer_bind(framebuffer);
|
||||||
float clear_color[4] = {0.0, 0.0, 0.0, 0.0};
|
GPU_framebuffer_texture_attach(framebuffer, texture, 0, 0);
|
||||||
|
|
||||||
|
float clear_color[4] = {0.1f, 0.1f, 0.1f, 1.0f};
|
||||||
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0);
|
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0);
|
||||||
|
|
||||||
engine_->Execute(render_index_.get(), &tasks_);
|
engine_->Execute(render_index_.get(), &tasks_);
|
||||||
@ -175,16 +176,16 @@ void FinalEngineGL::render0(Depsgraph *depsgraph)
|
|||||||
GPU_texture_free(texture);
|
GPU_texture_free(texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalEngineGL::render(Depsgraph *depsgraph)
|
void FinalEngineGL::render0(Depsgraph *depsgraph)
|
||||||
{
|
{
|
||||||
prepare_for_render(depsgraph);
|
prepare_for_render(depsgraph);
|
||||||
|
|
||||||
GLuint framebuffer = 0, tex_color = 0, tex_depth = 0;
|
GLuint fbo = 0, tex_color = 0, tex_depth = 0;
|
||||||
glGenFramebuffers(1, &framebuffer);
|
glGenFramebuffers(1, &fbo);
|
||||||
glGenTextures(1, &tex_color);
|
glGenTextures(1, &tex_color);
|
||||||
glGenTextures(1, &tex_depth);
|
glGenTextures(1, &tex_depth);
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||||
|
|
||||||
// Set tex_color as GL_COLOR_ATTACHMENT0
|
// Set tex_color as GL_COLOR_ATTACHMENT0
|
||||||
glBindTexture(GL_TEXTURE_2D, tex_color);
|
glBindTexture(GL_TEXTURE_2D, tex_color);
|
||||||
@ -194,30 +195,53 @@ void FinalEngineGL::render(Depsgraph *depsgraph)
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_color, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex_color, 0);
|
||||||
|
|
||||||
// Set tex_depth as GL_DEPTH_ATTACHMENT
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex_depth);
|
GLuint rbo = 0;
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glGenRenderbuffers(1, &rbo);
|
||||||
0,
|
glBindRenderbuffer(GL_RENDERBUFFER, rbo);
|
||||||
GL_DEPTH_COMPONENT32,
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, resolution_[0], resolution_[1]);
|
||||||
resolution_[0],
|
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||||
resolution_[1],
|
|
||||||
0,
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rbo);
|
||||||
GL_DEPTH_COMPONENT,
|
|
||||||
GL_FLOAT,
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
0);
|
printf("ERROR::FRAMEBUFFER:: Framebuffer is not complete!\n");
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
}
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
//// Set tex_depth as GL_DEPTH_ATTACHMENT
|
||||||
//glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tex_depth, 0);
|
//glBindTexture(GL_TEXTURE_2D, tex_depth);
|
||||||
|
//glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
// 0,
|
||||||
|
// GL_DEPTH_COMPONENT32,
|
||||||
|
// resolution_[0],
|
||||||
|
// resolution_[1],
|
||||||
|
// 0,
|
||||||
|
// GL_DEPTH_COMPONENT,
|
||||||
|
// GL_FLOAT,
|
||||||
|
// 0);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
////glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex_depth, 0);
|
||||||
|
|
||||||
// Generate vertex array
|
// Generate vertex array
|
||||||
GLuint vao;
|
GLuint vao;
|
||||||
glGenVertexArrays(1, &vao);
|
glGenVertexArrays(1, &vao);
|
||||||
glBindVertexArray(vao);
|
glBindVertexArray(vao);
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||||
|
|
||||||
|
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
|
||||||
|
//glClearDepthf(1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
//glDepthFunc(GL_LESS);
|
||||||
|
|
||||||
engine_->Execute(render_index_.get(), &tasks_);
|
engine_->Execute(render_index_.get(), &tasks_);
|
||||||
|
|
||||||
std::vector<float> &pixels = render_images_["Combined"];
|
std::vector<float> &pixels = render_images_["Combined"];
|
||||||
|
@ -117,9 +117,9 @@ static PyObject *engine_sync_func(PyObject * /*self*/, PyObject *args)
|
|||||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
||||||
engine->sync(depsgraph, context);
|
engine->sync(depsgraph, context);
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,9 +135,9 @@ static PyObject *engine_sync_usd_func(PyObject * /*self*/, PyObject *args)
|
|||||||
boost::python::extract<pxr::UsdStageRefPtr> extract(pystage);
|
boost::python::extract<pxr::UsdStageRefPtr> extract(pystage);
|
||||||
pxr::UsdStagePtr stage = extract();
|
pxr::UsdStagePtr stage = extract();
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
||||||
engine->sync_usd(stage);
|
engine->sync_usd(stage);
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,12 +152,13 @@ static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args)
|
|||||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
|
||||||
|
|
||||||
/* Allow Blender to execute other Python scripts. */
|
/* Allow Blender to execute other Python scripts. */
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
engine->render(depsgraph);
|
engine->render(depsgraph);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx", engine);
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,12 +173,13 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args)
|
|||||||
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
|
||||||
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
|
||||||
|
|
||||||
|
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx", engine);
|
||||||
|
|
||||||
/* Allow Blender to execute other Python scripts. */
|
/* Allow Blender to execute other Python scripts. */
|
||||||
Py_BEGIN_ALLOW_THREADS;
|
Py_BEGIN_ALLOW_THREADS;
|
||||||
engine->render(depsgraph, context);
|
engine->render(depsgraph, context);
|
||||||
Py_END_ALLOW_THREADS;
|
Py_END_ALLOW_THREADS;
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx", engine);
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +210,10 @@ static PyObject *engine_set_sync_setting_func(PyObject * /*self*/, PyObject *arg
|
|||||||
}
|
}
|
||||||
|
|
||||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||||
engine->set_sync_setting(key, get_setting_val(pyval));
|
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
|
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
|
||||||
|
engine->set_sync_setting(key, get_setting_val(pyval));
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +226,10 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
|
|||||||
}
|
}
|
||||||
|
|
||||||
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
|
||||||
engine->set_render_setting(key, get_setting_val(pyval));
|
|
||||||
|
|
||||||
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
|
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
|
||||||
|
engine->set_render_setting(key, get_setting_val(pyval));
|
||||||
|
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user