Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jeroen@blender.org>2022-11-09 14:18:22 +0300
committerJeroen Bakker <jeroen@blender.org>2022-11-09 14:18:22 +0300
commitd63d2c8b9ea151750d38a391dc1083992b5d53c8 (patch)
tree3ce989a4aa6b9aa6c0842ab7dc95b0f41d5fb3a3
parent027ca9b91e84cd84e2714216d04ab9a02e52d494 (diff)
Use Material flag to identify virtual camera.
-rw-r--r--source/blender/draw/engines/eevee/eevee_materials.c11
-rw-r--r--source/blender/draw/intern/draw_manager_data.cc2
-rw-r--r--source/blender/gpu/GPU_material.h2
-rw-r--r--source/blender/gpu/intern/gpu_codegen.cc2
-rw-r--r--source/blender/gpu/intern/gpu_node_graph.c6
-rw-r--r--source/blender/gpu/shaders/material/gpu_shader_material_virtual_camera.glsl7
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc12
7 files changed, 21 insertions, 21 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c
index b134d7f6dc6..afb84f48bee 100644
--- a/source/blender/draw/engines/eevee/eevee_materials.c
+++ b/source/blender/draw/engines/eevee/eevee_materials.c
@@ -861,6 +861,17 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata,
continue;
}
+ /* Virtual cameras can only be used in the main scene. This needs to be a different
+ * DRW_state.*/
+ printf("%s: %d %d\n",
+ __func__,
+ DRW_state_is_opengl_render(),
+ GPU_material_flag_get(gpumat_array[i], GPU_MATFLAG_VIRTUAL_CAMERA));
+ if (DRW_state_is_opengl_render() &&
+ GPU_material_flag_get(gpumat_array[i], GPU_MATFLAG_VIRTUAL_CAMERA)) {
+ continue;
+ }
+
/* Do not render surface if we are rendering a volume object
* and do not have a surface closure. */
if (use_volume_material &&
diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc
index bae99a945d2..6183cf41a41 100644
--- a/source/blender/draw/intern/draw_manager_data.cc
+++ b/source/blender/draw/intern/draw_manager_data.cc
@@ -1836,7 +1836,7 @@ void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *mater
grp, tex->sampler_name, *tex->sky, eGPUSamplerState(tex->sampler_state));
}
else if (tex->camera) {
- /* Sky */
+ /* VirtualCamera */
DRW_shgroup_uniform_texture_ex(
grp, tex->sampler_name, *tex->camera, eGPUSamplerState(tex->sampler_state));
}
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h
index 48eb53d662f..0457b6bb9f2 100644
--- a/source/blender/gpu/GPU_material.h
+++ b/source/blender/gpu/GPU_material.h
@@ -83,6 +83,8 @@ typedef enum eGPUMaterialFlag {
GPU_MATFLAG_OBJECT_INFO = (1 << 10),
GPU_MATFLAG_AOV = (1 << 11),
+ GPU_MATFLAG_VIRTUAL_CAMERA = (1 << 12),
+
GPU_MATFLAG_BARYCENTRIC = (1 << 20),
/* Optimization to only add the branches of the principled shader that are necessary. */
diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc
index 2ce03f88693..aa0f86d46e4 100644
--- a/source/blender/gpu/intern/gpu_codegen.cc
+++ b/source/blender/gpu/intern/gpu_codegen.cc
@@ -394,7 +394,7 @@ void GPUCodegen::generate_resources()
}
else if (tex->camera) {
const char *name = info.name_buffer.append_sampler_name(tex->sampler_name);
- info.sampler(0, ImageType::FLOAT_2D, name, Frequency::PASS);
+ info.sampler(0, ImageType::FLOAT_2D, name, Frequency::BATCH);
}
else if (tex->tiled_mapping_name[0] != '\0') {
const char *name = info.name_buffer.append_sampler_name(tex->sampler_name);
diff --git a/source/blender/gpu/intern/gpu_node_graph.c b/source/blender/gpu/intern/gpu_node_graph.c
index 553ca219617..81b9d373951 100644
--- a/source/blender/gpu/intern/gpu_node_graph.c
+++ b/source/blender/gpu/intern/gpu_node_graph.c
@@ -498,6 +498,7 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph,
}
tex->colorband = colorband;
tex->sky = sky;
+ tex->camera = camera;
tex->sampler_state = sampler_state;
BLI_snprintf(tex->sampler_name, sizeof(tex->sampler_name), "samp%d", num_textures);
if (ELEM(link_type, GPU_NODE_LINK_IMAGE_TILED, GPU_NODE_LINK_IMAGE_TILED_MAPPING)) {
@@ -637,12 +638,11 @@ GPUNodeLink *GPU_image_camera(GPUMaterial *mat, Camera *camera, eGPUSamplerState
{
GPUNodeGraph *graph = gpu_material_node_graph(mat);
GPUNodeLink *link = gpu_node_link_create();
- GPUTexture *texture = camera->runtime.virtual_camera_stage ?
- NULL :
- GPU_offscreen_color_texture(camera->runtime.virtual_display_texture);
+ GPUTexture *texture = GPU_offscreen_color_texture(camera->runtime.virtual_display_texture);
link->link_type = GPU_NODE_LINK_IMAGE_CAMERA;
link->texture = gpu_node_graph_add_texture(
graph, NULL, NULL, NULL, NULL, &texture, link->link_type, sampler_state);
+ GPU_material_flag_set(mat, GPU_MATFLAG_VIRTUAL_CAMERA);
return link;
}
diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_virtual_camera.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_virtual_camera.glsl
index 26d15292e6a..05bc6f90686 100644
--- a/source/blender/gpu/shaders/material/gpu_shader_material_virtual_camera.glsl
+++ b/source/blender/gpu/shaders/material/gpu_shader_material_virtual_camera.glsl
@@ -4,13 +4,8 @@ void node_virtual_camera_empty(vec3 co, out vec4 color, out float alpha)
alpha = 0.0;
}
-void node_virtual_camera(vec3 co, sampler2D ima, float mix, out vec4 color, out float alpha)
+void node_virtual_camera(vec3 co, sampler2D ima, out vec4 color, out float alpha)
{
- if (mix == 1.0) {
- node_virtual_camera_empty(co, color, alpha);
- return;
- }
-
color = texture(ima, co.xy);
alpha = color.a;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc b/source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc
index f9af9356242..0220e773839 100644
--- a/source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc
+++ b/source/blender/nodes/shader/nodes/node_shader_virtual_camera.cc
@@ -30,18 +30,10 @@ static int node_shader_gpu_virtual_camera(GPUMaterial *mat,
Object *orig_object = DEG_get_original_object(object);
Camera *cam = static_cast<Camera *>(orig_object->data);
- const bool virtual_camera_stage = cam->runtime.virtual_camera_stage;
- const float stage_mix = virtual_camera_stage ? 1.0f : 0.0f;
-
node_shader_gpu_default_tex_coord(mat, node, &in[0].link);
- return GPU_stack_link(mat,
- node,
- "node_virtual_camera",
- in,
- out,
- GPU_image_camera(mat, cam, GPU_SAMPLER_DEFAULT),
- GPU_uniform(&stage_mix));
+ return GPU_stack_link(
+ mat, node, "node_virtual_camera", in, out, GPU_image_camera(mat, cam, GPU_SAMPLER_DEFAULT));
}
} // namespace blender::nodes::node_shader_virtual_camera_cc