Expose TAA as a shader def

This commit is contained in:
Marco Buono 2023-05-28 17:09:14 -03:00
parent eadb217ecf
commit 348e2ce401
2 changed files with 12 additions and 0 deletions

View File

@ -7,6 +7,7 @@ use bevy_app::{App, Plugin};
use bevy_asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle};
use bevy_core_pipeline::{
core_3d::{AlphaMask3d, Opaque3d, Transparent3d},
experimental::taa::TemporalAntiAliasSettings,
prepass::NormalPrepass,
tonemapping::{DebandDither, Tonemapping},
};
@ -387,6 +388,7 @@ pub fn queue_material_meshes<M: Material>(
Option<&DebandDither>,
Option<&EnvironmentMapLight>,
Option<&NormalPrepass>,
Option<&TemporalAntiAliasSettings>,
&mut RenderPhase<Opaque3d>,
&mut RenderPhase<AlphaMask3d>,
&mut RenderPhase<Transparent3d>,
@ -401,6 +403,7 @@ pub fn queue_material_meshes<M: Material>(
dither,
environment_map,
normal_prepass,
taa_settings,
mut opaque_phase,
mut alpha_mask_phase,
mut transparent_phase,
@ -417,6 +420,10 @@ pub fn queue_material_meshes<M: Material>(
view_key |= MeshPipelineKey::NORMAL_PREPASS;
}
if taa_settings.is_some() {
view_key |= MeshPipelineKey::TAA;
}
let environment_map_loaded = match environment_map {
Some(environment_map) => environment_map.is_loaded(&images),
None => false,

View File

@ -585,6 +585,7 @@ bitflags::bitflags! {
const ALPHA_MASK = (1 << 6);
const ENVIRONMENT_MAP = (1 << 7);
const DEPTH_CLAMP_ORTHO = (1 << 8);
const TAA = (1 << 9);
const BLEND_RESERVED_BITS = Self::BLEND_MASK_BITS << Self::BLEND_SHIFT_BITS; // ← Bitmask reserving bits for the blend state
const BLEND_OPAQUE = (0 << Self::BLEND_SHIFT_BITS); // ← Values are just sequential within the mask, and can range from 0 to 3
const BLEND_PREMULTIPLIED_ALPHA = (1 << Self::BLEND_SHIFT_BITS); //
@ -799,6 +800,10 @@ impl SpecializedMeshPipeline for MeshPipeline {
shader_defs.push("ENVIRONMENT_MAP".into());
}
if key.contains(MeshPipelineKey::TAA) {
shader_defs.push("TAA".into());
}
let format = if key.contains(MeshPipelineKey::HDR) {
ViewTarget::TEXTURE_FORMAT_HDR
} else {