Blender  V3.3
eevee_film.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2021 Blender Foundation.
3  */
4 
19 #pragma once
20 
21 #include "DRW_render.h"
22 
23 #include "eevee_shader_shared.hh"
24 
25 namespace blender::eevee {
26 
27 class Instance;
28 
29 /* -------------------------------------------------------------------- */
33 class Film {
34  public:
36  AOVsInfoDataBuf aovs_info;
38  static constexpr bool use_box_filter = false;
39 
40  private:
41  Instance &inst_;
42 
44  Texture color_accum_tx_;
45  Texture value_accum_tx_;
47  Texture depth_tx_;
49  SwapChain<Texture, 2> combined_tx_;
51  GPUTexture *combined_src_tx_ = nullptr;
52  GPUTexture *combined_dst_tx_ = nullptr;
54  SwapChain<Texture, 2> weight_tx_;
56  GPUTexture *weight_src_tx_ = nullptr;
57  GPUTexture *weight_dst_tx_ = nullptr;
59  bool force_disable_reprojection_ = false;
60 
61  DRWPass *accumulate_ps_ = nullptr;
62 
63  FilmDataBuf data_;
64 
66 
67  public:
68  Film(Instance &inst) : inst_(inst){};
69  ~Film(){};
70 
71  void init(const int2 &full_extent, const rcti *output_rect);
72 
73  void sync();
74  void end_sync();
75 
77  void accumulate(const DRWView *view);
78 
80  void display();
81 
82  float *read_pass(eViewLayerEEVEEPassType pass_type);
83  float *read_aov(ViewLayerAOV *aov);
84 
86  {
87  return data_.render_extent;
88  }
89 
90  float2 pixel_jitter_get() const;
91 
92  float background_opacity_get() const
93  {
94  return data_.background_opacity;
95  }
96 
98 
99  static bool pass_is_value(eViewLayerEEVEEPassType pass_type)
100  {
101  switch (pass_type) {
102  case EEVEE_RENDER_PASS_Z:
106  return true;
107  default:
108  return false;
109  }
110  }
111 
113  {
114  switch (pass_type) {
123  return true;
124  default:
125  return false;
126  }
127  }
128 
129  /* Returns layer offset in the accumulation texture. -1 if the pass is not enabled. */
131  {
132  switch (pass_type) {
134  return data_.combined_id;
135  case EEVEE_RENDER_PASS_Z:
136  return data_.depth_id;
138  return data_.mist_id;
140  return data_.normal_id;
142  return data_.diffuse_light_id;
144  return data_.diffuse_color_id;
146  return data_.specular_light_id;
148  return data_.specular_color_id;
150  return data_.volume_light_id;
152  return data_.emission_id;
154  return data_.environment_id;
156  return data_.shadow_id;
158  return data_.ambient_occlusion_id;
160  return -1; /* TODO */
162  return data_.vector_id;
163  default:
164  return -1;
165  }
166  }
167 
168  static const char *pass_to_render_pass_name(eViewLayerEEVEEPassType pass_type)
169  {
170  switch (pass_type) {
172  return RE_PASSNAME_COMBINED;
173  case EEVEE_RENDER_PASS_Z:
174  return RE_PASSNAME_Z;
176  return RE_PASSNAME_MIST;
178  return RE_PASSNAME_NORMAL;
190  return RE_PASSNAME_EMIT;
194  return RE_PASSNAME_SHADOW;
196  return RE_PASSNAME_AO;
198  BLI_assert_msg(0, "Cryptomatte is not implemented yet.");
199  return ""; /* TODO */
201  return RE_PASSNAME_VECTOR;
202  default:
203  BLI_assert(0);
204  return "";
205  }
206  }
207 
208  private:
209  void init_aovs();
210  void sync_mist();
211 
215  void update_sample_table();
216 };
217 
220 } // namespace blender::eevee
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
eViewLayerEEVEEPassType
@ EEVEE_RENDER_PASS_AO
@ EEVEE_RENDER_PASS_NORMAL
@ EEVEE_RENDER_PASS_DIFFUSE_LIGHT
@ EEVEE_RENDER_PASS_VOLUME_LIGHT
@ EEVEE_RENDER_PASS_DIFFUSE_COLOR
@ EEVEE_RENDER_PASS_CRYPTOMATTE
@ EEVEE_RENDER_PASS_Z
@ EEVEE_RENDER_PASS_ENVIRONMENT
@ EEVEE_RENDER_PASS_COMBINED
@ EEVEE_RENDER_PASS_SPECULAR_LIGHT
@ EEVEE_RENDER_PASS_VECTOR
@ EEVEE_RENDER_PASS_SPECULAR_COLOR
@ EEVEE_RENDER_PASS_EMIT
@ EEVEE_RENDER_PASS_MIST
@ EEVEE_RENDER_PASS_SHADOW
#define RE_PASSNAME_COMBINED
#define RE_PASSNAME_NORMAL
#define RE_PASSNAME_VECTOR
#define RE_PASSNAME_EMIT
#define RE_PASSNAME_GLOSSY_COLOR
#define RE_PASSNAME_GLOSSY_DIRECT
#define RE_PASSNAME_SHADOW
#define RE_PASSNAME_MIST
#define RE_PASSNAME_ENVIRONMENT
#define RE_PASSNAME_DIFFUSE_COLOR
#define RE_PASSNAME_AO
#define RE_PASSNAME_Z
#define RE_PASSNAME_VOLUME_LIGHT
#define RE_PASSNAME_DIFFUSE_DIRECT
static AppView * view
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Texture
float2 pixel_jitter_get() const
Definition: eevee_film.cc:438
void accumulate(const DRWView *view)
Definition: eevee_film.cc:541
static bool pass_is_value(eViewLayerEEVEEPassType pass_type)
Definition: eevee_film.hh:99
int pass_id_get(eViewLayerEEVEEPassType pass_type) const
Definition: eevee_film.hh:130
static bool pass_is_float3(eViewLayerEEVEEPassType pass_type)
Definition: eevee_film.hh:112
Film(Instance &inst)
Definition: eevee_film.hh:68
float * read_pass(eViewLayerEEVEEPassType pass_type)
Definition: eevee_film.cc:606
static const char * pass_to_render_pass_name(eViewLayerEEVEEPassType pass_type)
Definition: eevee_film.hh:168
int2 render_extent_get() const
Definition: eevee_film.hh:85
AOVsInfoDataBuf aovs_info
Definition: eevee_film.hh:36
void init(const int2 &full_extent, const rcti *output_rect)
Definition: eevee_film.cc:165
float * read_aov(ViewLayerAOV *aov)
Definition: eevee_film.cc:84
eViewLayerEEVEEPassType enabled_passes_get() const
Definition: eevee_film.cc:459
float background_opacity_get() const
Definition: eevee_film.hh:92
static constexpr bool use_box_filter
Definition: eevee_film.hh:38
A running instance of the engine.
T * data_
Definition: eval_output.h:163