|
Blender V4.3
|
#include <cstring>#include "MEM_guardedalloc.h"#include "DNA_scene_types.h"#include "BLI_listbase.h"#include "BLI_math_color.h"#include "BLI_math_geom.h"#include "BLI_math_matrix.h"#include "BLI_threads.h"#include "BKE_attribute.hh"#include "BKE_ccg.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_legacy_derived_mesh.hh"#include "BKE_mesh_tangent.hh"#include "BKE_modifier.hh"#include "BKE_multires.hh"#include "BKE_subsurf.hh"#include "DEG_depsgraph.hh"#include "RE_multires_bake.h"#include "RE_pipeline.h"#include "RE_texture_margin.h"#include "IMB_imbuf.hh"#include "IMB_imbuf_types.hh"Go to the source code of this file.
Classes | |
| struct | MultiresBakeResult |
| struct | MResolvePixelData |
| struct | MBakeRast |
| struct | MHeightBakeData |
| struct | MNormalBakeData |
| struct | BakeImBufuserData |
| struct | MultiresBakeQueue |
| struct | MultiresBakeThread |
Typedefs | |
| using | MPassKnownData |
| using | MInitBakeData = void *(*)(MultiresBakeRender *bkr, ImBuf *ibuf) |
| using | MFreeBakeData = void (*)(void *bake_data) |
| using | MFlushPixel = void (*)(const MResolvePixelData *data, const int x, const int y) |
Functions | |
| static void | multiresbake_get_normal (const MResolvePixelData *data, const int tri_num, const int vert_index, float r_normal[3]) |
| static void | init_bake_rast (MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, MFlushPixel flush_pixel, bool *do_update) |
| static void | flush_pixel (const MResolvePixelData *data, const int x, const int y) |
| static void | set_rast_triangle (const MBakeRast *bake_rast, const int x, const int y) |
| static void | rasterize_half (const MBakeRast *bake_rast, const float s0_s, const float t0_s, const float s1_s, const float t1_s, const float s0_l, const float t0_l, const float s1_l, const float t1_l, const int y0_in, const int y1_in, const int is_mid_right) |
| static void | bake_rasterize (const MBakeRast *bake_rast, const float st0_in[2], const float st1_in[2], const float st2_in[2]) |
| static int | multiresbake_test_break (MultiresBakeRender *bkr) |
| static int | multires_bake_queue_next_tri (MultiresBakeQueue *queue) |
| static void * | do_multires_bake_thread (void *data_v) |
| static void | init_ccgdm_arrays (DerivedMesh *dm) |
| static void | do_multires_bake (MultiresBakeRender *bkr, Image *ima, ImageTile *tile, ImBuf *ibuf, bool require_tangent, MPassKnownData passKnownData, MInitBakeData initBakeData, MFreeBakeData freeBakeData, MultiresBakeResult *result) |
| static void | interp_bilinear_grid (const CCGKey &key, CCGElem *grid, float crn_x, float crn_y, int mode, float res[3]) |
| static void | get_ccgdm_data (const blender::OffsetIndices< int > lores_polys, DerivedMesh *hidm, const int *index_mp_to_orig, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3]) |
| static void | interp_bilinear_mpoly (const blender::Span< blender::float3 > vert_positions, const blender::Span< blender::float3 > vert_normals, const blender::Span< int > corner_verts, const blender::IndexRange face, const float u, const float v, const int mode, float res[3]) |
| static void | interp_barycentric_corner_tri (const blender::Span< blender::float3 > vert_positions, const blender::Span< blender::float3 > vert_normals, const blender::Span< int > corner_verts, const blender::int3 &corner_tri, const float u, const float v, const int mode, float res[3]) |
| static void * | init_heights_data (MultiresBakeRender *bkr, ImBuf *ibuf) |
| static void | free_heights_data (void *bake_data) |
| static void | apply_heights_callback (const blender::Span< blender::float3 > vert_positions, const blender::Span< blender::float3 > vert_normals, const blender::OffsetIndices< int > faces, const blender::Span< int > corner_verts, const blender::Span< blender::int3 > corner_tris, const blender::Span< int > tri_faces, const blender::Span< blender::float2 > uv_map, DerivedMesh *hires_dm, void *thread_data_v, void *bake_data, ImBuf *ibuf, const int tri_index, const int lvl, const float st[2], float[3][3], const int x, const int y) |
| static void * | init_normal_data (MultiresBakeRender *bkr, ImBuf *) |
| static void | free_normal_data (void *bake_data) |
| static void | apply_tangmat_callback (const blender::Span< blender::float3 >, const blender::Span< blender::float3 >, const blender::OffsetIndices< int > faces, const blender::Span< int >, const blender::Span< blender::int3 > corner_tris, const blender::Span< int > tri_faces, const blender::Span< blender::float2 > uv_map, DerivedMesh *hires_dm, void *, void *bake_data, ImBuf *ibuf, const int tri_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y) |
| static void | bake_ibuf_filter (ImBuf *ibuf, char *mask, const int margin, const char margin_type, DerivedMesh *dm, const float uv_offset[2]) |
| static void | bake_ibuf_normalize_displacement (ImBuf *ibuf, const float *displacement, const char *mask, float displacement_min, float displacement_max) |
| static void | count_images (MultiresBakeRender *bkr) |
| static void | bake_images (MultiresBakeRender *bkr, MultiresBakeResult *result) |
| static void | finish_images (MultiresBakeRender *bkr, MultiresBakeResult *result) |
| void | RE_multires_bake_images (MultiresBakeRender *bkr) |
| using MFlushPixel = void (*)(const MResolvePixelData *data, const int x, const int y) |
Definition at line 100 of file multires_bake.cc.
| using MFreeBakeData = void (*)(void *bake_data) |
Definition at line 62 of file multires_bake.cc.
| using MInitBakeData = void *(*)(MultiresBakeRender *bkr, ImBuf *ibuf) |
Definition at line 61 of file multires_bake.cc.
| using MPassKnownData |
Definition at line 43 of file multires_bake.cc.
|
static |
Definition at line 868 of file multires_bake.cc.
References ImBuf::byte_buffer, clamp_v2(), ImBufByteBuffer::data, ImBufFloatBuffer::data, dot_v3v3(), ImBuf::float_buffer, get_ccgdm_data(), MultiresBakeThread::height_max, MultiresBakeThread::height_min, MHeightBakeData::heights, interp_barycentric_corner_tri(), interp_bilinear_mpoly(), len, max_ff(), min_ff(), MHeightBakeData::orig_index_mp_to_orig, resolve_quad_uv_v2(), resolve_tri_uv_v2(), MHeightBakeData::ssdm, sub_v3_v3v3(), unit_float_to_uchar_clamp, ImBuf::x, and x.
Referenced by bake_images().
|
static |
MultiresBake callback for normals' baking.
General idea:
norm(vec) / 2 + (0.5, 0.5, 0.5). Definition at line 991 of file multires_bake.cc.
References add_v3_v3(), ImBuf::byte_buffer, clamp_v2(), ImBufByteBuffer::data, ImBufFloatBuffer::data, ImBuf::float_buffer, get_ccgdm_data(), mul_v3_m3v3(), normalize_v3_length(), MNormalBakeData::orig_index_mp_to_orig, resolve_quad_uv_v2(), resolve_tri_uv_v2(), rgb_float_to_uchar(), ImBuf::x, and x.
Referenced by bake_images().
|
static |
Definition at line 1382 of file multires_bake.cc.
References BKE_imbuf_alpha_test(), IMB_filter_extend(), IMB_rectfill_alpha(), ImBuf::planes, R_BAKE_ADJACENT_FACES, R_BAKE_EXTEND, R_IMF_PLANES_RGBA, and RE_generate_texturemargin_adjacentfaces_dm().
Referenced by finish_images().
|
static |
Definition at line 1417 of file multires_bake.cc.
References ImBuf::byte_buffer, ImBufByteBuffer::data, ImBufFloatBuffer::data, fabsf, FILTER_MASK_USED, ImBuf::float_buffer, mask(), max_ff(), unit_float_to_uchar_clamp, ImBuf::x, and ImBuf::y.
Referenced by finish_images().
|
static |
Definition at line 1494 of file multires_bake.cc.
References apply_heights_callback(), apply_tangmat_callback(), BKE_image_acquire_ibuf(), BKE_image_release_ibuf(), BKE_imageuser_default(), do_multires_bake(), FLT_MAX, free_heights_data(), free_normal_data(), Image::id, ID_TAG_DOIT, MultiresBakeRender::image, init_heights_data(), init_normal_data(), LISTBASE_FOREACH, BakeImBufuserData::mask_buffer, MultiresBakeRender::mode, RE_BAKE_AO, RE_BAKE_DISPLACEMENT, RE_BAKE_NORMALS, ID::tag, ImageUser::tile, tile, Image::tiles, ImBuf::userdata, ImBuf::x, and ImBuf::y.
Referenced by RE_multires_bake_images().
|
static |
Definition at line 294 of file multires_bake.cc.
References ceilf, MBakeRast::h, int, rasterize_half(), MBakeRast::w, and w().
Referenced by do_multires_bake_thread().
|
static |
Definition at line 1462 of file multires_bake.cc.
References MultiresBakeRender::array, BLI_addtail(), BLI_genericNodeN(), BLI_listbase_clear(), Image::id, ID_TAG_DOIT, MultiresBakeRender::image, MultiresBakeRender::len, MultiresBakeRender::ob_image, ID::tag, and MultiresBakeRender::tot_image.
Referenced by RE_multires_bake_images().
|
static |
Definition at line 470 of file multires_bake.cc.
References BKE_id_free(), BKE_image_get_tile_uv(), BKE_mesh_calc_loop_tangent_ex(), BKE_mesh_new_nomain(), MultiresBakeThread::bkr, BLI_listbase_count(), BLI_spin_end(), BLI_spin_init(), BLI_system_thread_count(), BLI_threadpool_end(), BLI_threadpool_init(), BLI_threadpool_insert(), CD_ORCO, CD_PROP_BOOL, CD_PROP_FLOAT2, CD_PROP_INT32, CD_TANGENT, Mesh::corners_num, CustomData_get_layer_index(), CustomData_get_layer_named(), blender::Span< T >::data(), DM_get_loop_data_layer(), do_multires_bake_thread(), MultiresBakeRender::do_update, DerivedMesh::edgeData, Mesh::edges_num, faces, Mesh::faces_num, FLT_MAX, flush_pixel(), DerivedMesh::getCornerEdgeArray, DerivedMesh::getCornerVertArray, DerivedMesh::getEdgeArray, DerivedMesh::getLoopDataArray, DerivedMesh::getNumEdges, DerivedMesh::getNumLoops, DerivedMesh::getNumPolys, DerivedMesh::getNumVerts, DerivedMesh::getPolyArray, DerivedMesh::getVertArray, DerivedMesh::getVertDataArray, handles, MultiresBakeRender::hires_dm, MultiresBakeRender::image, init_bake_rast(), init_ccgdm_arrays(), DerivedMesh::loopData, MultiresBakeRender::lores_dm, MultiresBakeRender::lvl, max_ff(), min_ff(), DerivedMesh::polyData, blender::Span< T >::size(), DerivedMesh::tangent_mask, MultiresBakeRender::threads, tile, Image::tiles, Mesh::verts_num, ImBuf::x, and ImBuf::y.
Referenced by bake_images().
|
static |
Definition at line 392 of file multires_bake.cc.
References MultiresBakeRender::array, bake_rasterize(), MultiresBakeRender::baked_faces, MultiresBakeRender::baked_objects, BLI_spin_lock(), BLI_spin_unlock(), MultiresBakeRender::do_update, float, IB_DISPLAY_BUFFER_INVALID, IB_RECT_INVALID, MultiresBakeRender::len, multires_bake_queue_next_tri(), multiresbake_test_break(), MultiresBakeRender::ob_image, MultiresBakeRender::progress, sub_v2_v2v2(), and MultiresBakeRender::tot_obj.
Referenced by do_multires_bake().
|
static |
Definition at line 1562 of file multires_bake.cc.
References bake_ibuf_filter(), bake_ibuf_normalize_displacement(), MultiresBakeRender::bake_margin, MultiresBakeRender::bake_margin_type, BKE_image_acquire_ibuf(), BKE_image_get_tile_uv(), BKE_image_mark_dirty(), BKE_image_release_ibuf(), BKE_imageuser_default(), ImBufFloatBuffer::data, DEG_id_tag_update(), BakeImBufuserData::displacement_buffer, ImBuf::float_buffer, IB_DISPLAY_BUFFER_INVALID, IB_MIPMAP_INVALID, IB_RECT_INVALID, Image::id, MultiresBakeRender::image, imb_freemipmapImBuf(), LISTBASE_FOREACH, MultiresBakeRender::lores_dm, BakeImBufuserData::mask_buffer, MEM_freeN(), ImBuf::mipmap, MultiresBakeRender::mode, RE_BAKE_DISPLACEMENT, ImageUser::tile, tile, Image::tiles, ImBuf::userdata, ImBuf::userflags, ImBuf::x, and ImBuf::y.
Referenced by RE_multires_bake_images().
|
static |
Definition at line 160 of file multires_bake.cc.
References cross_v3_v3v3(), invert_m3_m3(), mul_v3_fl(), multiresbake_get_normal(), resolve_tri_uv_v2(), v, w(), and zero_m3().
Referenced by do_multires_bake(), init_bake_rast(), and set_rast_triangle().
|
static |
Definition at line 851 of file multires_bake.cc.
References MEM_freeN(), DerivedMesh::release, and MHeightBakeData::ssdm.
Referenced by bake_images().
|
static |
Definition at line 976 of file multires_bake.cc.
References MEM_freeN().
Referenced by bake_images().
|
static |
Definition at line 688 of file multires_bake.cc.
References CLAMP, col, DerivedMesh::getGridData, DerivedMesh::getGridKey, DerivedMesh::getGridOffset, DerivedMesh::getGridSize, interp_bilinear_grid(), mdisp_rot_face_to_crn(), size(), and v.
Referenced by apply_heights_callback(), and apply_tangmat_callback().
|
static |
Definition at line 142 of file multires_bake.cc.
References data, MBakeRast::data, MBakeRast::do_update, flush_pixel(), MBakeRast::flush_pixel, MBakeRast::h, BakeImBufuserData::mask_buffer, MBakeRast::texels, ImBuf::userdata, MBakeRast::w, ImBuf::x, and ImBuf::y.
Referenced by do_multires_bake().
|
static |
Definition at line 453 of file multires_bake.cc.
References DerivedMesh::getGridData, DerivedMesh::getGridKey, DerivedMesh::getGridOffset, and DerivedMesh::getGridSize.
Referenced by do_multires_bake(), and init_heights_data().
|
static |
Definition at line 813 of file multires_bake.cc.
References CD_ORIGINDEX, CLAMP, BakeImBufuserData::displacement_buffer, DerivedMesh::getPolyDataArray, MHeightBakeData::heights, init_ccgdm_arrays(), SubsurfModifierData::levels, MultiresBakeRender::lores_dm, MultiresBakeRender::lvl, MHeightBakeData::orig_index_mp_to_orig, SubsurfModifierData::quality, SubsurfModifierData::renderLevels, MultiresBakeRender::scene, MHeightBakeData::ssdm, subsurf_make_derived_from_derived(), SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES, MultiresBakeRender::tot_lvl, MultiresBakeRender::use_lores_mesh, ImBuf::userdata, SubsurfModifierData::uv_smooth, ImBuf::x, and ImBuf::y.
Referenced by bake_images().
|
static |
Definition at line 963 of file multires_bake.cc.
References CD_ORIGINDEX, DerivedMesh::getPolyDataArray, MultiresBakeRender::lores_dm, and MNormalBakeData::orig_index_mp_to_orig.
Referenced by bake_images().
|
static |
Definition at line 786 of file multires_bake.cc.
References copy_v3_v3(), interp_barycentric_tri_v3(), and v.
Referenced by apply_heights_callback().
|
static |
Definition at line 656 of file multires_bake.cc.
References CCG_grid_elem_co(), CCG_grid_elem_no(), copy_v3_v3(), CCGKey::grid_size, int, interp_bilinear_quad_v3(), and v.
Referenced by get_ccgdm_data().
|
static |
Definition at line 759 of file multires_bake.cc.
References copy_v3_v3(), interp_bilinear_quad_v3(), and v.
Referenced by apply_heights_callback().
|
static |
Definition at line 374 of file multires_bake.cc.
References BLI_spin_lock(), and BLI_spin_unlock().
Referenced by do_multires_bake_thread().
|
static |
Definition at line 125 of file multires_bake.cc.
References copy_v3_v3().
Referenced by flush_pixel().
|
static |
Definition at line 340 of file multires_bake.cc.
References G, and MultiresBakeRender::stop.
Referenced by do_multires_bake_thread().
|
static |
Definition at line 244 of file multires_bake.cc.
References ceilf, fabsf, MBakeRast::h, int, set_rast_triangle(), MBakeRast::w, w(), x, and y.
Referenced by bake_rasterize().
| void RE_multires_bake_images | ( | MultiresBakeRender * | bkr | ) |
Definition at line 1627 of file multires_bake.cc.
References bake_images(), count_images(), finish_images(), and result.
Referenced by blender::ed::object::multiresbake_image_exec_locked(), and blender::ed::object::multiresbake_startjob().
Definition at line 228 of file multires_bake.cc.
References MBakeRast::data, MBakeRast::do_update, FILTER_MASK_USED, flush_pixel(), MBakeRast::h, MBakeRast::texels, MBakeRast::w, w(), and x.
Referenced by rasterize_half().