mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 14:49:19 +02:00
refractive material support contd.
This commit is contained in:
@@ -192,8 +192,7 @@ void GbufferBlitPass::UpdateConstants(nvrhi::ICommandList* command_list,
|
||||
|
||||
const auto& daylight = Global.DayLight;
|
||||
|
||||
m_sky->CalcLighting(constants.m_light_dir,
|
||||
constants.m_light_color);
|
||||
m_sky->CalcLighting(constants.m_light_dir, constants.m_light_color);
|
||||
constants.m_altitude = Global.pCamera.Pos.y;
|
||||
constants.m_time = Timer::GetTime();
|
||||
constants.m_vertical_fov =
|
||||
@@ -201,7 +200,8 @@ void GbufferBlitPass::UpdateConstants(nvrhi::ICommandList* command_list,
|
||||
|
||||
{
|
||||
float percipitation_intensity = glm::saturate(Global.Overcast - 1.);
|
||||
constants.m_rain_params.x = percipitation_intensity; // % amount of droplets
|
||||
constants.m_rain_params.x =
|
||||
percipitation_intensity; // % amount of droplets
|
||||
constants.m_rain_params.y =
|
||||
glm::mix(15., 1., percipitation_intensity); // Regeneration time
|
||||
static glm::vec4 wiper_timer_out;
|
||||
@@ -241,6 +241,13 @@ void GbufferBlitPass::UpdateConstants(nvrhi::ICommandList* command_list,
|
||||
command_list->writeBuffer(m_draw_constants, &constants, sizeof(constants));
|
||||
}
|
||||
|
||||
void GbufferBlitPass::UpdateSceneColorForRefraction(
|
||||
nvrhi::ICommandList* command_list) const {
|
||||
command_list->copyTexture(
|
||||
m_output_copy, nvrhi::TextureSlice().resolve(m_output_copy->getDesc()),
|
||||
m_output, nvrhi::TextureSlice().resolve(m_output->getDesc()));
|
||||
}
|
||||
|
||||
void GbufferBlitPass::Render(nvrhi::ICommandList* command_list,
|
||||
glm::dmat4& view, const glm::dmat4& projection) {
|
||||
UpdateConstants(command_list, view, projection);
|
||||
@@ -249,10 +256,6 @@ void GbufferBlitPass::Render(nvrhi::ICommandList* command_list,
|
||||
m_scene_depth, nvrhi::TextureSlice().resolve(m_scene_depth->getDesc()),
|
||||
m_gbuffer->m_gbuffer_depth,
|
||||
nvrhi::TextureSlice().resolve(m_scene_depth->getDesc()));
|
||||
command_list->copyTexture(
|
||||
m_output_copy, nvrhi::TextureSlice().resolve(m_output_copy->getDesc()),
|
||||
m_output,
|
||||
nvrhi::TextureSlice().resolve(m_output->getDesc()));
|
||||
}
|
||||
|
||||
void GbufferBlitPass::Render(nvrhi::ICommandList* command_list) {
|
||||
|
||||
@@ -18,6 +18,8 @@ struct GbufferBlitPass : public FullScreenPass, public MaResourceRegistry {
|
||||
void UpdateConstants(nvrhi::ICommandList* command_list, glm::dmat4& view,
|
||||
const glm::dmat4& projection);
|
||||
|
||||
void UpdateSceneColorForRefraction(nvrhi::ICommandList *command_list) const;
|
||||
|
||||
void Render(nvrhi::ICommandList* command_list, glm::dmat4& view,
|
||||
const glm::dmat4& projection);
|
||||
virtual void Render(nvrhi::ICommandList* command_list) override;
|
||||
|
||||
@@ -109,6 +109,7 @@ void NvRenderer::MaterialTemplate::Init(const YAML::Node &conf) {
|
||||
MaResourceMapping sampler_mapping_shadow{};
|
||||
m_pipelines.fill(nullptr);
|
||||
m_masked_shadow_texture = conf["masked_shadow_texture"].as<std::string>();
|
||||
m_enable_refraction = conf["refraction"].as<bool>(false);
|
||||
for (const auto it : conf["textures"]) {
|
||||
auto index = it.second["binding"].as<int>();
|
||||
m_texture_bindings.resize(
|
||||
|
||||
@@ -1584,13 +1584,17 @@ void NvRenderer::BindConstants(const RenderPass &pass,
|
||||
bool NvRenderer::BindMaterial(material_handle handle, DrawType draw_type,
|
||||
const RenderPass &pass,
|
||||
nvrhi::GraphicsState &gfx_state,
|
||||
float &alpha_threshold) {
|
||||
float &alpha_threshold, bool *out_is_refractive) {
|
||||
if (pass.m_type == RenderPassType::RendererWarmUp) return true;
|
||||
if (!handle || handle > m_material_cache.size()) {
|
||||
return false;
|
||||
}
|
||||
MaterialCache &cache = m_material_cache[handle - 1];
|
||||
|
||||
if(out_is_refractive) {
|
||||
*out_is_refractive = cache.m_template->m_enable_refraction;
|
||||
}
|
||||
|
||||
if (!cache.ShouldRenderInPass(pass)) return false;
|
||||
|
||||
auto pipeline_index = Constants::GetPipelineIndex(pass.m_type, draw_type);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "config.h"
|
||||
#include "gbufferblitpass.h"
|
||||
#include "motioncache.h"
|
||||
#include "nvrenderer/nvrenderer.h"
|
||||
#include "nvrendererbackend.h"
|
||||
@@ -1014,18 +1015,23 @@ void NvRenderer::Render(const Renderable& renderable, const RenderPass& pass,
|
||||
nvrhi::GraphicsState gfx_state;
|
||||
nvrhi::DrawArguments draw_arguments{};
|
||||
bool indexed;
|
||||
bool refractive;
|
||||
float alpha_threshold;
|
||||
if (!BindGeometry(item.m_geometry, pass, gfx_state, draw_arguments,
|
||||
indexed))
|
||||
continue;
|
||||
if (!BindMaterial(item.m_material, DrawType::Model, pass, gfx_state,
|
||||
alpha_threshold))
|
||||
alpha_threshold, &refractive))
|
||||
continue;
|
||||
|
||||
BindConstants(pass, gfx_state);
|
||||
|
||||
pass.m_command_list_draw->beginMarker(item.m_name.data());
|
||||
|
||||
if(refractive && pass.m_type == RenderPassType::Forward) {
|
||||
m_gbuffer_blit->UpdateSceneColorForRefraction(pass.m_command_list_draw);
|
||||
}
|
||||
|
||||
pass.m_command_list_draw->setGraphicsState(gfx_state);
|
||||
|
||||
auto transform = item.m_transform;
|
||||
|
||||
Reference in New Issue
Block a user