|
Blender V5.0
|
#include "RE_multires_bake.h"#include <atomic>#include "DNA_mesh_types.h"#include "DNA_modifier_types.h"#include "BLI_array.hh"#include "BLI_listbase.h"#include "BLI_math_base.hh"#include "BLI_math_geom.h"#include "BLI_math_matrix.hh"#include "BLI_math_vector.hh"#include "BLI_span.hh"#include "BLI_task.hh"#include "BLI_threads.h"#include "BKE_attribute.hh"#include "BKE_customdata.hh"#include "BKE_global.hh"#include "BKE_image.hh"#include "BKE_lib_id.hh"#include "BKE_mesh.hh"#include "BKE_mesh_tangent.hh"#include "BKE_multires.hh"#include "BKE_subdiv.hh"#include "BKE_subdiv_ccg.hh"#include "BKE_subdiv_eval.hh"#include "BKE_subdiv_foreach.hh"#include "BKE_subdiv_mesh.hh"#include "IMB_imbuf.hh"#include "IMB_imbuf_types.hh"#include "DEG_depsgraph.hh"#include "RE_texture_margin.h"Go to the source code of this file.
Namespaces | |
| namespace | blender |
| namespace | blender::render |
Functions | |
| void | RE_multires_bake_images (MultiresBakeRender &bake) |
This file is an implementation of a special baking mode which bakes data (normals, displacement) from the highest multi-resolution level to the current viewport subdivision level.
The initial historical reasoning for having such baker was:
The general idea of the algorithm is pretty simple:
SubdivCCG is used to access attributes at the highest multi-resolution subdivision level.
The core rasterization logic works on triangles and those triangles are fed to the rasterizer in a way that makes it easy to sample attributes in the SubdivCCG:
The way triangles are calculated when baking to the base level is pretty straightforward:
When baking to a non-0 subdivision level a special trick is used to know grid index and its UV coordinates in the base mesh: for every loop in the bake-level mesh the algorithm calculates this information using subdiv's foreach logic. This assumes that the bake level mesh is calculated using the same foreach logic.
This is a special option for the displacement baker.
When it is ON: displacement is calculated between the multi-resolution at the highest subdivision level and the bake-level mesh.
When it is OFF: displacement is calculated between the multi-resolution at the highest subdivision level and a mesh which is created from the bake level mesh by subdividing it further to reach the same subdivision level of the highest multi-resolution level. Additionally, the texture UV, and UV tangents are used from this "special" mesh.
Reuse mesh from the viewport as bake-level mesh.
It could be a bit challenging since mesh could be in sculpt mode, where it has own SubdivCCG and does not have UV map on the subdivided state. Additionally, it will make it harder to calculate tangent space as well.
Definition in file multires_bake.cc.
| void RE_multires_bake_images | ( | MultiresBakeRender & | bake | ) |
Definition at line 1702 of file multires_bake.cc.
References BKE_id_free(), and result.
Referenced by blender::ed::object::multiresbake_image_exec_locked(), and blender::ed::object::multiresbake_startjob().