32 View view = {
"DefaultView"};
53 if (material_count > dummy_gpu_materials.
size()) {
54 dummy_gpu_materials.
resize(material_count,
nullptr);
56 return dummy_gpu_materials.
begin();
61 scene_state.
init(camera_ob);
62 shadow_ps.
init(scene_state, resources);
63 resources.
init(scene_state);
65 outline_ps.
init(scene_state);
66 dof_ps.
init(scene_state);
67 anti_aliasing_ps.
init(scene_state);
74 opaque_ps.
sync(scene_state, resources);
75 transparent_ps.
sync(scene_state, resources);
76 transparent_depth_ps.
sync(scene_state, resources);
79 volume_ps.
sync(resources);
80 outline_ps.
sync(resources);
81 dof_ps.
sync(resources);
82 anti_aliasing_ps.
sync(scene_state, resources);
139 is_object_data_visible =
false;
147 if (is_object_data_visible) {
152 const float3 half_extent = bounds.
max - center;
155 emitter_handle = handle;
160 emitter_handle = handle;
203 if (scene_state.
xray_mode || is_transparent) {
210 draw_callback(transparent_depth_ps.
main_ps_);
228 bool show_missing_texture =
false)
233 if (show_missing_texture && (!texture || !texture->gpu.texture)) {
238 mesh_pass.get_subpass(eGeometryType::MESH, texture).draw(batch, handle, material_index);
244 bool has_transparent_material =
false;
249 gpu::Batch **batches;
260 if (batches[i] ==
nullptr) {
264 int material_slot = i;
266 has_transparent_material = has_transparent_material || mat.is_transparent();
296 has_transparent_material = has_transparent_material || mat.is_transparent();
303 shadow_ps.
object_sync(scene_state, ob_ref, handle, has_transparent_material);
321 mat.base_color =
batch.debug_color();
336 mat.base_color =
batch.debug_color();
353 PassMain::Sub &pass =
354 mesh_pass.get_subpass(eGeometryType::POINTCLOUD).sub(
"Point Cloud SubPass");
355 gpu::Batch *batch = point_cloud_sub_pass_setup(pass, ob_ref.object);
356 pass.draw(batch, handle, material_index);
379 PassMain::Sub &pass =
380 mesh_pass.get_subpass(eGeometryType::CURVES, &texture).sub(
"Hair SubPass");
381 pass.push_constant(
"emitter_object_id", int(emitter_handle.raw));
382 gpu::Batch *batch = hair_sub_pass_setup(pass, scene_state.scene, ob_ref.object, psys, md);
383 pass.draw(batch, handle, material_index);
397 PassMain::Sub &pass = mesh_pass.get_subpass(eGeometryType::CURVES).sub(
"Curves SubPass");
398 gpu::Batch *batch = curves_sub_pass_setup(pass, scene_state.scene, ob_ref.object);
399 pass.draw(batch, handle, material_index);
404 GPUTexture *depth_tx,
405 GPUTexture *depth_in_front_tx,
429 anti_aliasing_ps.
draw(
manager, view, scene_state, resources, depth_in_front_tx);
433 anti_aliasing_ps.
setup_view(view, scene_state);
451 transparent_ps.
draw(
manager, view, resources, resolution);
452 transparent_depth_ps.
draw(
manager, view, resources);
457 anti_aliasing_ps.
draw(
manager, view, scene_state, resources, depth_in_front_tx);
463 GPUTexture *depth_tx,
464 GPUTexture *depth_in_front_tx,
475 GPUTexture *depth_tx,
476 GPUTexture *depth_in_front_tx,
488 resources.
init(scene_state);
489 dof_ps.
init(scene_state);
490 anti_aliasing_ps.
sync(scene_state, resources);
534 reinterpret_cast<WORKBENCH_Data *
>(vedata)->instance->begin_sync();
546 reinterpret_cast<WORKBENCH_Data *
>(vedata)->instance->object_sync(*manager, ref);
596 const int2 size = {
int(viewport_size.
x),
int(viewport_size.
y)};
602 if (dtxl->
color ==
nullptr) {
606 "txl.color", size.x, size.y, 1,
GPU_RGBA16F, usage,
nullptr);
621 {GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_TEXTURE(dtxl->color)});
624 {GPU_ATTACHMENT_TEXTURE(dtxl->depth), GPU_ATTACHMENT_NONE});
627 {GPU_ATTACHMENT_NONE, GPU_ATTACHMENT_TEXTURE(dtxl->color)});
635 const char *viewname,
655 const char *viewname,
681 z = winmat[3][2] / (
z + winmat[2][2]);
689 float range =
fabsf(far - near);
696 z =
z * range - near;
746 auto workbench_render_cache =
struct Material * BKE_material_default_empty(void)
struct Material * BKE_object_material_get_eval(struct Object *ob, short act)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
General operations, lookup, etc. for blender objects.
A BVH for high poly meshes.
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Object * DEG_get_evaluated_object(const Depsgraph *depsgraph, Object *object)
@ eModifierType_ParticleSystem
#define RE_PASSNAME_COMBINED
@ V3D_SHADING_TEXTURE_COLOR
@ V3D_SHADING_VERTEX_COLOR
@ V3D_SHADING_MATERIAL_COLOR
@ V3D_SHADING_OBJECT_COLOR
@ V3D_SHADING_RANDOM_COLOR
@ V3D_SHADING_SINGLE_COLOR
char DRWViewportEmptyList
#define DRW_VIEWPORT_DATA_SIZE(ty)
eGPUBackendType GPU_backend_get_type()
bool GPU_framebuffer_check_valid(GPUFrameBuffer *framebuffer, char err_out[256])
#define GPU_ATTACHMENT_TEXTURE(_texture)
void GPU_framebuffer_clear_depth_stencil(GPUFrameBuffer *fb, float clear_depth, uint clear_stencil)
void GPU_framebuffer_read_depth(GPUFrameBuffer *framebuffer, int x, int y, int width, int height, eGPUDataFormat data_format, void *r_data)
#define GPU_ATTACHMENT_NONE
void GPU_framebuffer_multi_clear(GPUFrameBuffer *framebuffer, const float(*clear_colors)[4])
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void GPU_framebuffer_read_color(GPUFrameBuffer *framebuffer, int x, int y, int width, int height, int channels, int slot, eGPUDataFormat data_format, void *r_data)
#define GPU_framebuffer_ensure_config(_fb,...)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
@ GPU_TEXTURE_USAGE_GENERAL
Contains defines and structs used throughout the imbuf module.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object instance
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
void resize(const int64_t new_size)
void ensure(GPUAttachment depth=GPU_ATTACHMENT_NONE, GPUAttachment color1=GPU_ATTACHMENT_NONE, GPUAttachment color2=GPU_ATTACHMENT_NONE, GPUAttachment color3=GPU_ATTACHMENT_NONE, GPUAttachment color4=GPU_ATTACHMENT_NONE, GPUAttachment color5=GPU_ATTACHMENT_NONE, GPUAttachment color6=GPU_ATTACHMENT_NONE, GPUAttachment color7=GPU_ATTACHMENT_NONE, GPUAttachment color8=GPU_ATTACHMENT_NONE)
ResourceHandle resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void acquire(int2 extent, eGPUTextureFormat format, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL)
void wrap(GPUTexture *tex)
A running instance of the engine.
void setup_view(View &view, const SceneState &scene_state)
void init(const SceneState &scene_state)
void draw(Manager &manager, View &view, const SceneState &scene_state, SceneResources &resources, GPUTexture *depth_in_front_tx)
void sync(const SceneState &scene_state, SceneResources &resources)
void sync(SceneResources &resources)
void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution)
void init(const SceneState &scene_state)
void draw(Manager &manager, GPUTexture *depth_tx, GPUTexture *depth_in_front_tx, GPUTexture *color_tx)
void draw_image_render(Manager &manager, GPUTexture *depth_tx, GPUTexture *depth_in_front_tx, GPUTexture *color_tx, RenderEngine *engine=nullptr)
Material get_material(ObjectRef ob_ref, eV3DShadingColorType color_type, int slot=0)
void init(Object *camera_ob=nullptr)
TransparentDepthPass transparent_depth_ps
void draw_viewport(Manager &manager, GPUTexture *depth_tx, GPUTexture *depth_in_front_tx, GPUTexture *color_tx)
void draw_to_mesh_pass(ObjectRef &ob_ref, bool is_transparent, F draw_callback)
TransparentPass transparent_ps
void curves_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state)
GPUMaterial ** get_dummy_gpu_materials(int material_count)
AntiAliasingPass anti_aliasing_ps
void draw_mesh(ObjectRef &ob_ref, Material &material, gpu::Batch *batch, ResourceHandle handle, const MaterialTexture *texture=nullptr, bool show_missing_texture=false)
void object_sync(Manager &manager, ObjectRef &ob_ref)
void sculpt_sync(ObjectRef &ob_ref, ResourceHandle handle, const ObjectState &object_state)
void mesh_sync(ObjectRef &ob_ref, ResourceHandle handle, const ObjectState &object_state)
Vector< GPUMaterial * > dummy_gpu_materials
void hair_sync(Manager &manager, ObjectRef &ob_ref, ResourceHandle emitter_handle, const ObjectState &object_state, ParticleSystem *psys, ModifierData *md)
void point_cloud_sync(Manager &manager, ObjectRef &ob_ref, const ObjectState &object_state)
void sync(const SceneState &scene_state, SceneResources &resources)
MeshPass gbuffer_in_front_ps_
void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution, class ShadowPass *shadow_pass)
void draw(Manager &manager, SceneResources &resources)
void sync(SceneResources &resources)
void init(const SceneState &scene_state)
void init(const SceneState &scene_state, SceneResources &resources)
void object_sync(SceneState &scene_state, ObjectRef &ob_ref, ResourceHandle handle, const bool has_transp_mat)
void draw(Manager &manager, View &view, SceneResources &resources)
void sync(const SceneState &scene_state, SceneResources &resources)
MeshPass accumulation_in_front_ps_
void sync(const SceneState &scene_state, SceneResources &resources)
void draw(Manager &manager, View &view, SceneResources &resources, int2 resolution)
MeshPass accumulation_ps_
void sync(SceneResources &resources)
void object_sync_volume(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, float3 color)
void draw(Manager &manager, View &view, SceneResources &resources)
void object_sync_modifier(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, ModifierData *md)
local_group_size(16, 16) .push_constant(Type texture
const Depsgraph * depsgraph
blender::gpu::Batch * DRW_cache_object_surface_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
blender::gpu::Batch * DRW_cache_mesh_surface_vertpaint_get(Object *ob)
blender::gpu::Batch ** DRW_cache_object_surface_material_get(Object *ob, GPUMaterial **gpumat_array, uint gpumat_array_len)
int DRW_cache_object_material_count_get(const Object *ob)
blender::gpu::Batch * DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
blender::gpu::Batch ** DRW_cache_mesh_surface_texpaint_get(Object *ob)
blender::draw::Manager * DRW_manager_get()
Object * DRW_object_get_dupli_parent(const Object *)
bool DRW_state_is_viewport_image_render()
DefaultFramebufferList * DRW_viewport_framebuffer_list_get()
const float * DRW_viewport_size_get()
bool DRW_object_is_renderable(const Object *ob)
void DRW_render_instance_buffer_finish()
int DRW_object_visibility_in_active_context(const Object *ob)
bool DRW_state_is_scene_render()
bool DRW_object_is_visible_psys_in_active_context(const Object *object, const ParticleSystem *psys)
DefaultTextureList * DRW_viewport_texture_list_get()
void DRW_render_to_image(RenderEngine *engine, Depsgraph *depsgraph)
const DRWContextState * DRW_context_state_get()
DupliObject * DRW_object_get_dupli(const Object *)
void DRW_viewport_request_redraw()
void DRW_render_object_iter(void *vedata, RenderEngine *engine, Depsgraph *depsgraph, void(*callback)(void *vedata, Object *ob, RenderEngine *engine, Depsgraph *depsgraph))
const DRWView * DRW_view_default_get()
float DRW_view_near_distance_get(const DRWView *view)
bool DRW_view_is_persp_get(const DRWView *view)
float DRW_view_far_distance_get(const DRWView *view)
void DRW_view_default_set(const DRWView *view)
DRWView * DRW_view_create(const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4], DRWCallVisibilityFn *visibility_fn)
void DRW_view_set_active(const DRWView *view)
#define SCULPT_DEBUG_DRAW
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
BLI_INLINE float fb(float length, float L)
void RE_GetCameraModelMatrix(const Render *re, const Object *camera, float r_modelmat[4][4])
void RE_GetCameraWindow(Render *re, const Object *camera, float r_winmat[4][4])
Object * RE_GetCamera(Render *re)
void RE_engine_report(RenderEngine *engine, int type, const char *msg)
bool RE_engine_test_break(RenderEngine *engine)
void RE_engine_register_pass(RenderEngine *engine, Scene *scene, ViewLayer *view_layer, const char *name, int channels, const char *chanid, eNodeSocketDatatype type)
pbvh::Tree * pbvh_get(Object &object)
Bounds< float3 > bounds_get(const Tree &pbvh)
Vector< SculptBatch > sculpt_batches_get(const Object *ob, SculptBatchFeature features)
@ SCULPT_BATCH_VERTEX_COLOR
CartesianBasis invert(const CartesianBasis &basis)
T midpoint(const T &a, const T &b)
VecBase< float, 4 > float4
vertex_in(0, Type::VEC2, "pos") .push_constant(Type ratio draw_mesh
RenderPass * RE_pass_find_by_name(RenderLayer *rl, const char *name, const char *viewname)
const char * RE_GetActiveRenderView(Render *re)
GPUFrameBuffer * depth_only_fb
GPUFrameBuffer * color_only_fb
GPUFrameBuffer * default_fb
GPUTexture * depth_in_front
struct FluidDomainSettings * domain
ImBufFloatBuffer float_buffer
DrawEngineType * engine_type
DRWViewportEmptyList * psl
DRWViewportEmptyList * stl
workbench::Instance * instance
DRWViewportEmptyList * txl
DRWViewportEmptyList * fbl
const c_style_mat & ptr() const
DupliObject * dupli_object
bool use_per_material_batches
MaterialTexture image_paint_override
eV3DShadingColorType color_type
bool show_missing_texture
void init(const SceneState &scene_state)
MaterialTexture missing_texture
StorageVectorBuffer< Material > material_buf
TextureRef depth_in_front_tx
TextureFromPool object_id_tx
Framebuffer clear_in_front_fb
void init(Object *camera_ob=nullptr)
bool reset_taa_next_sample
Material material_attribute_color
Material material_override
static void workbench_draw_scene(void *vedata)
DrawEngineType draw_engine_workbench
static void workbench_cache_init(void *vedata)
RenderEngineType DRW_engine_viewport_workbench_type
static void workbench_render_update_passes(RenderEngine *engine, Scene *scene, ViewLayer *view_layer)
static void workbench_id_update(void *vedata, ID *id)
static void workbench_instance_free(void *instance)
static void workbench_engine_init(void *vedata)
static void workbench_view_update(void *vedata)
static void write_render_z_output(RenderLayer *layer, const char *viewname, GPUFrameBuffer *fb, const rcti *rect, const float4x4 &winmat)
static void workbench_render_to_image(void *vedata, RenderEngine *engine, RenderLayer *layer, const rcti *rect)
static void workbench_cache_finish(void *vedata)
static void write_render_color_output(RenderLayer *layer, const char *viewname, GPUFrameBuffer *fb, const rcti *rect)
static bool workbench_render_framebuffers_init()
static const DrawEngineDataSize workbench_data_size
static void workbench_engine_free()
static void workbench_cache_populate(void *vedata, Object *object)