34 StaticShader prepass_[geometry_type_len][pipeline_type_len][lighting_type_len][shader_type_len]
51 return get_static_cache().
get();
55 get_static_cache().release();
66 return prepass_[int(geometry_type)][int(pipeline_type)][int(lighting_type)][int(shader_type)]
73 bool curvature =
false,
76 return resolve_[int(lighting_type)][cavity][curvature][shadow].get();
81 return shadow_[depth_pass][manifold][cap].get();
86 return volume_[smoke][interpolation][coba][slice].get();
95 "workbench_shadow_visibility_compute_dynamic_pass_type"};
132 static uint32_t pack_data(
float metallic,
float roughness,
float alpha);
134 bool is_transparent();
139 uint32_t full_alpha_ref = 0x00ff0000;
140 return (
packed_data & full_alpha_ref) != full_alpha_ref;
146 roughness =
sqrtf(roughness);
150 return (packed_alpha << 16u) | (packed_roughness << 8u) | packed_metallic;
236 static const int max_samples_ = 512;
241 int sample_count_ = 0;
242 bool curvature_enabled_ =
false;
243 bool cavity_enabled_ =
false;
250 void load_samples_buf(
int ssao_samples);
296 void load_jitter_tx(
int total_samples);
301 struct TextureSubPassKey {
311 bool operator==(TextureSubPassKey
const &rhs)
const
313 return this->texture == rhs.texture && this->sampler_state == rhs.sampler_state &&
314 this->geom_type == rhs.geom_type;
320 PassMain::Sub *passes_[geometry_type_len][shader_type_len] = {{
nullptr}};
326 bool is_empty_ =
false;
372 bool is_empty()
const;
388 bool is_empty()
const;
402 bool is_empty()
const;
405#define DEBUG_SHADOW_VOLUME 0
409 enum PassType { PASS = 0, FAIL, FORCED_FAIL, MAX };
411 class ShadowView :
public View {
412 bool force_fail_method_ =
false;
415 ShadowPass::PassType current_pass_type_ = PASS;
421 ShadowView() :
View(
"ShadowPass.View") {};
423 void setup(
View &view,
float3 light_direction,
bool force_fail_method);
424 bool debug_object_culling(
Object *ob);
425 void set_mode(PassType type);
431 bool debug_freeze)
override;
436 bool use_raytracing_;
437 bool needs_rt_update_;
442 PassMain pass_ps_ = {
"Shadow.Pass"};
443 PassMain fail_ps_ = {
"Shadow.Fail"};
446 PassMain forced_fail_ps_ = {
"Shadow.ForcedFail"};
448 PassSimple raytrace_ps_ = {
"Shadow.RayQuery"};
454 PassMain::Sub *&get_pass_ptr(PassType type,
bool manifold,
bool cap =
false);
466 const bool has_transp_mat);
475 bool force_fail_method);
486 Texture dummy_shadow_tx_ = {
"Volume.Dummy Shadow Tx"};
487 Texture dummy_volume_tx_ = {
"Volume.Dummy Volume Tx"};
488 Texture dummy_flag_tx_ = {
"Volume.Dummy Flag Tx"};
489 Texture dummy_coba_tx_ = {
"Volume.Dummy Coba Tx"};
511 void draw_slice_ps(
Manager &manager,
518 void draw_volume_ps(
Manager &manager,
529 bool enabled_ =
false;
542 static const int kernel_radius_ = 3;
543 static const int samples_len_ = (kernel_radius_ * 2 + 1) * (kernel_radius_ * 2 + 1);
545 bool enabled_ =
false;
560 PassSimple down_ps_ = {
"Workbench.DoF.DownSample"};
561 PassSimple down2_ps_ = {
"Workbench.DoF.DownSample2"};
562 PassSimple down3_ps_ = {
"Workbench.DoF.DownSample3"};
564 PassSimple blur2_ps_ = {
"Workbench.DoF.Blur2"};
565 PassSimple resolve_ps_ = {
"Workbench.DoF.Resolve"};
567 float aperture_size_ = 0;
569 float invsensor_size_ = 0;
583 void setup_samples();
588 bool enabled_ =
false;
590 float weight_accum_ = 0;
592 float weights_[9] = {0};
594 float weights_sum_ = 0;
596 Texture sample0_depth_tx_ = {
"sample0_depth_tx"};
597 Texture sample0_depth_in_front_tx_ = {
"sample0_depth_in_front_tx"};
599 Texture taa_accumulation_tx_ = {
"taa_accumulation_tx"};
600 Texture smaa_search_tx_ = {
"smaa_search_tx"};
601 Texture smaa_area_tx_ = {
"smaa_area_tx"};
605 Framebuffer taa_accumulation_fb_ = {
"taa_accumulation_fb"};
608 Framebuffer smaa_resolve_fb_ = {
"smaa_resolve_fb"};
609 Framebuffer overlay_depth_fb_ = {
"overlay_depth_fb"};
612 float smaa_mix_factor_ = 0;
614 PassSimple taa_accumulation_ps_ = {
"TAA.Accumulation"};
615 PassSimple smaa_edge_detect_ps_ = {
"SMAA.EdgeDetect"};
616 PassSimple smaa_aa_weight_ps_ = {
"SMAA.BlendWeights"};
617 PassSimple smaa_resolve_ps_ = {
"SMAA.Resolve"};
618 PassSimple overlay_depth_ps_ = {
"Overlay Depth"};
#define GPU_BATCH_DISCARD_SAFE(batch)
detail::PassBase< command::DrawMultiBuf > Sub
void setup_view(View &view, const SceneState &scene_state)
void init(const SceneState &scene_state)
void sync(const SceneState &scene_state, SceneResources &resources)
void setup_resolve_pass(PassSimple &pass, SceneResources &resources)
void init(const SceneState &scene_state, SceneResources &resources)
void sync(SceneResources &resources, const DRWContext *draw_ctx)
void init(const SceneState &scene_state, const DRWContext *draw_ctx)
MeshPass(const char *name)
void init_pass(SceneResources &resources, DRWState state, int clip_planes)
void init_subpasses(ePipelineType pipeline, eLightingType lighting, bool clip)
MeshPass gbuffer_in_front_ps_
TextureFromPool gbuffer_material_tx
gpu::Texture * deferred_ps_stencil_tx
Texture shadow_depth_stencil_tx
Framebuffer gbuffer_in_front_fb
TextureFromPool gbuffer_normal_tx
void sync(SceneResources &resources)
void init(const SceneState &scene_state)
StaticShader smaa_aa_weight
gpu::Shader * resolve_get(eLightingType lighting_type, bool cavity=false, bool curvature=false, bool shadow=false)
StaticShader taa_accumulation
gpu::Shader * prepass_get(eGeometryType geometry_type, ePipelineType pipeline_type, eLightingType lighting_type, eShaderType shader_type, bool clip)
StaticShader transparent_resolve
StaticShader shadow_visibility_static
gpu::Shader * volume_get(bool smoke, int interpolation, bool coba, bool slice)
gpu::Shader * shadow_get(bool depth_pass, bool manifold, bool cap=false)
StaticShader smaa_resolve
StaticShader dof_downsample
StaticShader smaa_edge_detect
StaticShader shadow_visibility_dynamic
StaticShader overlay_depth
static ShaderCache & get()
StaticShader shadow_raytrace
void init(const SceneState &scene_state, SceneResources &resources)
void object_sync(SceneState &scene_state, ObjectRef &ob_ref, ResourceHandleRange handle, const bool has_transp_mat)
void sync(SceneResources &resources)
TextureFromPool accumulation_tx
MeshPass accumulation_in_front_ps_
MeshPass accumulation_ps_
Framebuffer transparent_fb
TextureFromPool reveal_tx
void sync(SceneResources &resources)
void object_sync_volume(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, float3 color)
void object_sync_modifier(Manager &manager, SceneResources &resources, const SceneState &scene_state, ObjectRef &ob_ref, ModifierData *md)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
detail::Pass< command::DrawCommandBuf > PassSimple
detail::Pass< command::DrawMultiBuf > PassMain
StorageArrayBuffer< ObjectBounds, 128 > ObjectBoundsBuf
StorageArrayBuffer< ObjectInfos, 128 > ObjectInfosBuf
StorageArrayBuffer< uint, 4, true > VisibilityBuf
gpu::StaticShader StaticShader
bool operator==(const CameraData &a, const CameraData &b)
std::unique_ptr< TopLevelAS, TopLevelASDeleter > TopLevelASPtr
ImageGPUTextures get_material_texture(GPUSamplerState &sampler_state)
unsigned __int64 uint64_t
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
MatBase< float, 4, 4 > float4x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
@ V3D_SHADING_SINGLE_COLOR
void GPU_texture_free(gpu::Texture *texture)
VecBase< float, 3 > float3
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
static constexpr GPUSamplerState default_sampler()
static MatBase identity()
GPUSamplerState sampler_state
MaterialTexture()=default
Material(blender::Material &mat)
static uint32_t pack_data(float metallic, float roughness, float alpha)
bool use_per_material_batches
MaterialTexture image_paint_override
ObjectState(const DRWContext *draw_ctx, const SceneState &scene_state, const SceneResources &resources, Object *ob, Manager &manager)
eV3DShadingColorType color_type
bool show_missing_texture
static const int jitter_tx_size
UniformBuffer< WorldData > world_buf
Framebuffer clear_depth_only_fb
MaterialTexture missing_texture
StorageVectorBuffer< Material > material_buf
TextureRef depth_in_front_tx
gpu::Batch * volume_cube_batch
Texture dummy_tile_array_tx
TextureFromPool object_id_tx
std::string current_matcap_working_space
Framebuffer clear_in_front_fb
Texture dummy_tile_data_tx
UniformArrayBuffer< float4, 6 > clip_planes_buf
StringRefNull current_matcap
bool show_paint_bvh_debug
eLightingType lighting_type
bool reset_taa_next_sample
void init(const DRWContext *context, bool scene_updated, Object *camera_ob=nullptr)
Material material_attribute_color
float4x4 view_projection_matrix
Vector< float4 > clip_planes
Material material_override
eContextObjectMode object_mode