Beispiel #1
0
	SSGILayer::SSGILayer()
	{
		ssgi_pp_ = MakeSharedPtr<SSGIPostProcess>();
		ssgi_blur_pp_ = MakeSharedPtr<BlurPostProcess<SeparableBilateralFilterPostProcess> >(4, 1.0f,
			SyncLoadRenderEffect("SSGI.fxml")->TechniqueByName("SSGIBlurX"),
			SyncLoadRenderEffect("SSGI.fxml")->TechniqueByName("SSGIBlurY"));
	}
Beispiel #2
0
	void RenderableTriangle::Init()
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		RenderEffectPtr effect = SyncLoadRenderEffect("RenderableHelper.fxml");
		technique_ = simple_forward_tech_ = effect->TechniqueByName("LineTec");
		v0_ep_ = effect->ParameterByName("v0");
		v1_ep_ = effect->ParameterByName("v1");
		v2_ep_ = effect->ParameterByName("v2");
		color_ep_ = effect->ParameterByName("color");
		mvp_param_ = effect->ParameterByName("mvp");

		float vertices[] =
		{
			0, 1, 2
		};

		ElementInitData init_data;
		init_data.row_pitch = sizeof(vertices);
		init_data.slice_pitch = 0;
		init_data.data = vertices;

		rl_ = rf.MakeRenderLayout();
		rl_->TopologyType(RenderLayout::TT_TriangleList);

		GraphicsBufferPtr vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindVertexStream(vb, make_tuple(vertex_element(VEU_Position, 0, EF_R32F)));

		tc_aabb_ = AABBox(float3(0, 0, 0), float3(0, 0, 0));

		*(effect->ParameterByName("pos_center")) = float3(0, 0, 0);
		*(effect->ParameterByName("pos_extent")) = float3(1, 1, 1);

		effect_attrs_ |= EA_SimpleForward;
	}
Beispiel #3
0
	SSRPostProcess::SSRPostProcess()
			: PostProcess(L"ScreenSpaceReflection")
	{
		input_pins_.push_back(std::make_pair("g_buffer_0_tex", TexturePtr()));
		input_pins_.push_back(std::make_pair("g_buffer_1_tex", TexturePtr()));
		input_pins_.push_back(std::make_pair("front_side_depth_tex", TexturePtr()));
		input_pins_.push_back(std::make_pair("front_side_tex", TexturePtr()));
		input_pins_.push_back(std::make_pair("foreground_depth_tex", TexturePtr()));

		params_.push_back(std::make_pair("min_samples", RenderEffectParameterPtr()));
		params_.push_back(std::make_pair("max_samples", RenderEffectParameterPtr()));

		RenderEffectPtr effect = SyncLoadRenderEffect("SSR.fxml");
		this->Technique(effect->TechniqueByName("ScreenSpaceReflectionPostProcess"));

		if (technique_ && technique_->Validate())
		{
			proj_param_ = effect->ParameterByName("proj");
			inv_proj_param_ = effect->ParameterByName("inv_proj");
			near_q_far_param_ = effect->ParameterByName("near_q_far");
			ray_length_param_ = effect->ParameterByName("ray_length");
		}

		this->SetParam(0, static_cast<int32_t>(20));
		this->SetParam(1, static_cast<int32_t>(30));
	}
Beispiel #4
0
void RenderableLineBox::Init()
{
    RenderFactory& rf = Context::Instance().RenderFactoryInstance();

    RenderEffectPtr effect = SyncLoadRenderEffect("RenderableHelper.fxml");
    technique_ = simple_forward_tech_ = effect->TechniqueByName("LineTec");
    v0_ep_ = effect->ParameterByName("v0");
    v1_ep_ = effect->ParameterByName("v1");
    v2_ep_ = effect->ParameterByName("v2");
    v3_ep_ = effect->ParameterByName("v3");
    v4_ep_ = effect->ParameterByName("v4");
    v5_ep_ = effect->ParameterByName("v5");
    v6_ep_ = effect->ParameterByName("v6");
    v7_ep_ = effect->ParameterByName("v7");
    color_ep_ = effect->ParameterByName("color");
    mvp_param_ = effect->ParameterByName("mvp");

    float vertices[] =
    {
        0, 1, 2, 3, 4, 5, 6, 7
    };

    uint16_t indices[] =
    {
        0, 1, 1, 3, 3, 2, 2, 0,
        4, 5, 5, 7, 7, 6, 6, 4,
        0, 4, 1, 5, 2, 6, 3, 7
    };

    rl_ = rf.MakeRenderLayout();
    rl_->TopologyType(RenderLayout::TT_LineList);

    ElementInitData init_data;
    init_data.row_pitch = sizeof(vertices);
    init_data.slice_pitch = 0;
    init_data.data = vertices;

    GraphicsBufferPtr vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
    rl_->BindVertexStream(vb, std::make_tuple(vertex_element(VEU_Position, 0, EF_R32F)));

    init_data.row_pitch = sizeof(indices);
    init_data.slice_pitch = 0;
    init_data.data = indices;

    GraphicsBufferPtr ib = rf.MakeIndexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
    rl_->BindIndexStream(ib, EF_R16UI);

    tc_aabb_ = AABBox(float3(0, 0, 0), float3(0, 0, 0));

    *(effect->ParameterByName("pos_center")) = float3(0, 0, 0);
    *(effect->ParameterByName("pos_extent")) = float3(1, 1, 1);

    effect_attrs_ |= EA_SimpleForward;
}
Beispiel #5
0
	SSVOPostProcess::SSVOPostProcess()
			: PostProcess(L"SSVO")
	{
		input_pins_.emplace_back("g_buffer_tex", TexturePtr());
		input_pins_.emplace_back("depth_tex", TexturePtr());

		output_pins_.emplace_back("out_tex", TexturePtr());

		this->Technique(SyncLoadRenderEffect("SSVO.fxml")->TechniqueByName("SSVO"));

		proj_param_ = technique_->Effect().ParameterByName("proj");
		inv_proj_param_ = technique_->Effect().ParameterByName("inv_proj");
		far_plane_param_ = technique_->Effect().ParameterByName("far_plane");
	}
Beispiel #6
0
	GpuFftCS4::GpuFftCS4(uint32_t width, uint32_t height, bool forward)
			: width_(width), height_(height), forward_(forward)
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		src_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F);
		src_->Resize(3 * width * height * sizeof(float) * 2);

		dst_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F);
		dst_->Resize(3 * width * height * sizeof(float) * 2);

		tmp_buffer_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F);
		tmp_buffer_->Resize(3 * width * height * sizeof(float) * 2);

		quad_layout_ = rf.MakeRenderLayout();
		quad_layout_->TopologyType(RenderLayout::TT_TriangleStrip);

		float2 xyzs[] =
		{
			float2(-1, +1),
			float2(+1, +1),
			float2(-1, -1),
			float2(+1, -1)
		};
		ElementInitData init_data;
		init_data.row_pitch = sizeof(xyzs);
		init_data.slice_pitch = 0;
		init_data.data = xyzs;
		GraphicsBufferPtr quad_vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		quad_layout_->BindVertexStream(quad_vb, std::make_tuple(vertex_element(VEU_Position, 0, EF_GR32F)));

		tex_fb_ = rf.MakeFrameBuffer();

		effect_ = SyncLoadRenderEffect("FFT.fxml");
		buf2tex_tech_ = effect_->TechniqueByName("Buf2Tex");
		radix008a_tech_ = effect_->TechniqueByName("FFTRadix008A4");
		radix008a_first_tech_ = effect_->TechniqueByName("FFTRadix008AFirst4");
		radix008a_final_tech_ = effect_->TechniqueByName("FFTRadix008AFinal4");
		real_tex_ep_ = effect_->ParameterByName("real_tex");
		imag_tex_ep_ = effect_->ParameterByName("imag_tex");

		*(effect_->ParameterByName("input_buf")) = dst_;

		*(effect_->ParameterByName("tex_width_height")) = uint2(width, height);
		uint32_t n = width * height;
		*(effect_->ParameterByName("addr_offset")) = uint3(0 * n, 1 * n, 2 * n);

		*(effect_->ParameterByName("forward")) = static_cast<int32_t>(forward_);
		*(effect_->ParameterByName("scale")) = 1.0f / (width_ * height_);
	}
Beispiel #7
0
SSGIPostProcess::SSGIPostProcess()
    : PostProcess(L"SSGI")
{
    input_pins_.push_back(std::make_pair("g_buffer_tex", TexturePtr()));
    input_pins_.push_back(std::make_pair("depth_tex", TexturePtr()));
    input_pins_.push_back(std::make_pair("shading_tex", TexturePtr()));

    output_pins_.push_back(std::make_pair("out_tex", TexturePtr()));

    this->Technique(SyncLoadRenderEffect("SSGI.fxml")->TechniqueByName("SSGI"));

    proj_param_ = technique_->Effect().ParameterByName("proj");
    inv_proj_param_ = technique_->Effect().ParameterByName("inv_proj");
    far_plane_param_ = technique_->Effect().ParameterByName("far_plane");
}
Beispiel #8
0
	SSGIPostProcess::SSGIPostProcess()
			: PostProcess(L"SSGI")
	{
		input_pins_.emplace_back("g_buffer_tex", TexturePtr());
		input_pins_.emplace_back("depth_tex", TexturePtr());
		input_pins_.emplace_back("shading_tex", TexturePtr());

		output_pins_.emplace_back("out_tex", TexturePtr());

		auto effect = SyncLoadRenderEffect("SSGI.fxml");
		this->Technique(effect, effect->TechniqueByName("SSGI"));

		proj_param_ = effect->ParameterByName("proj");
		inv_proj_param_ = effect->ParameterByName("inv_proj");
		far_plane_param_ = effect->ParameterByName("far_plane");
	}
Beispiel #9
0
	LensFlareRenderable::LensFlareRenderable()
		: RenderableHelper(L"LensFlare")
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		rl_ = rf.MakeRenderLayout();
		rl_->TopologyType(RenderLayout::TT_TriangleList);

		std::vector<float3> vertices;
		for (int i = 0; i < SUN_FLARENUM; ++ i)
		{
			vertices.push_back(float3(-1, +1, i + 0.1f));
			vertices.push_back(float3(+1, +1, i + 0.1f));
			vertices.push_back(float3(-1, -1, i + 0.1f));
			vertices.push_back(float3(+1, -1, i + 0.1f));
		}

		ElementInitData init_data;
		init_data.data = &vertices[0];
		init_data.slice_pitch = init_data.row_pitch = static_cast<uint32_t>(vertices.size() * sizeof(vertices[0]));

		GraphicsBufferPtr pos_vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindVertexStream(pos_vb, std::make_tuple(vertex_element(VEU_Position, 0, EF_BGR32F)));

		std::vector<uint32_t> indices;
		for (int i = 0; i < SUN_FLARENUM; ++ i)
		{
			indices.push_back(i * 4 + 2);
			indices.push_back(i * 4 + 0);
			indices.push_back(i * 4 + 1);

			indices.push_back(i * 4 + 1);
			indices.push_back(i * 4 + 3);
			indices.push_back(i * 4 + 2);
		}

		init_data.data = &indices[0];
		init_data.slice_pitch = init_data.row_pitch = static_cast<uint32_t>(indices.size() * sizeof(indices[0]));

		GraphicsBufferPtr ib = rf.MakeIndexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindIndexStream(ib, EF_R32UI);

		simple_forward_tech_ = SyncLoadRenderEffect("LensFlare.fxml")->TechniqueByName("LensFlare");
		technique_ = simple_forward_tech_;

		effect_attrs_ |= EA_SimpleForward;
	}
Beispiel #10
0
	SSSBlurPP::SSSBlurPP()
			: PostProcess(L"SSSBlurPP")
	{
		RenderDeviceCaps const & caps = Context::Instance().RenderFactoryInstance().RenderEngineInstance().DeviceCaps();
		mrt_blend_support_ = (caps.max_simultaneous_rts > 1) && caps.independent_blend_support;

		input_pins_.emplace_back("src_tex", TexturePtr());
		input_pins_.emplace_back("depth_tex", TexturePtr());

		output_pins_.emplace_back("output", TexturePtr());

		params_.emplace_back("strength", nullptr);
		params_.emplace_back("correction", nullptr);

		RenderEffectPtr effect = SyncLoadRenderEffect("SSS.fxml");
		copy_tech_ = effect->TechniqueByName("Copy");
		blur_x_tech_ = effect->TechniqueByName("BlurX");
		if (mrt_blend_support_)
		{
			std::string blur_y_name = "BlurY1";
			for (uint32_t i = 0; i < 3; ++ i)
			{
				blur_y_name[5] = static_cast<char>('1' + i);
				blur_y_techs_[i] = effect->TechniqueByName(blur_y_name);
			}
		}
		else
		{
			blur_y_techs_[0] = blur_x_tech_;
			std::string accum_name = "Accum1";
			for (uint32_t i = 0; i < 3; ++ i)
			{
				accum_name[5] = static_cast<char>('1' + i);
				accum_techs_[i] = effect->TechniqueByName(accum_name);
			}
		}
		this->Technique(effect, blur_x_tech_);

		RenderFactory& rf = Context::Instance().RenderFactoryInstance();
		blur_x_fb_ = rf.MakeFrameBuffer();
		blur_y_fb_ = rf.MakeFrameBuffer();

		src_tex_param_ = effect->ParameterByName("src_tex");
		step_param_ = effect->ParameterByName("step");
		far_plane_param_ = effect->ParameterByName("far_plane");
	}
Beispiel #11
0
	RenderableSkyBox::RenderableSkyBox()
		: RenderableHelper(L"SkyBox")
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		RenderEffectPtr effect = SyncLoadRenderEffect("SkyBox.fxml");
		if (deferred_effect_)
		{
			this->BindDeferredEffect(effect);
			depth_tech_ = effect->TechniqueByName("DepthSkyBoxTech");
			gbuffer_rt0_tech_ = effect->TechniqueByName("GBufferSkyBoxRT0Tech");
			gbuffer_rt1_tech_ = effect->TechniqueByName("GBufferSkyBoxRT1Tech");
			gbuffer_mrt_tech_ = effect->TechniqueByName("GBufferSkyBoxMRTTech");
			special_shading_tech_ = effect->TechniqueByName("SkyBoxTech");
			this->Technique(gbuffer_rt0_tech_);

			effect_attrs_ |= EA_SpecialShading;
		}
		else
		{
			this->Technique(effect->TechniqueByName("SkyBoxTech"));
		}

		float3 xyzs[] =
		{
			float3(1.0f, 1.0f, 1.0f),
			float3(1.0f, -1.0f, 1.0f),
			float3(-1.0f, 1.0f, 1.0f),
			float3(-1.0f, -1.0f, 1.0f),
		};

		ElementInitData init_data;
		init_data.row_pitch = sizeof(xyzs);
		init_data.slice_pitch = 0;
		init_data.data = xyzs;

		rl_ = rf.MakeRenderLayout();
		rl_->TopologyType(RenderLayout::TT_TriangleStrip);

		GraphicsBufferPtr vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindVertexStream(vb, make_tuple(vertex_element(VEU_Position, 0, EF_BGR32F)));

		pos_aabb_ = MathLib::compute_aabbox(&xyzs[0], &xyzs[4]);
		tc_aabb_ = AABBox(float3(0, 0, 0), float3(0, 0, 0));
	}
Beispiel #12
0
	MultiResLayer::MultiResLayer()
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		{
			rl_quad_ = rf.MakeRenderLayout();
			rl_quad_->TopologyType(RenderLayout::TT_TriangleStrip);

			float3 pos[] = 
			{
				float3(+1, +1, 1),
				float3(-1, +1, 1),
				float3(+1, -1, 1),
				float3(-1, -1, 1)
			};

			ElementInitData init_data;
			init_data.row_pitch = static_cast<uint32_t>(sizeof(pos));
			init_data.slice_pitch = 0;
			init_data.data = &pos[0];
			rl_quad_->BindVertexStream(rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data),
				make_tuple(vertex_element(VEU_Position, 0, EF_BGR32F)));
		}

		gbuffer_to_depth_derivate_pp_ = SyncLoadPostProcess("MultiRes.ppml", "GBuffer2DepthDerivate");
		depth_derivate_mipmap_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "DepthDerivateMipMap");
		gbuffer_to_normal_cone_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "GBuffer2NormalCone");
		normal_cone_mipmap_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "NormalConeMipMap");

		RenderEffectPtr subsplat_stencil_effect = SyncLoadRenderEffect("MultiRes.fxml");
		subsplat_stencil_tech_ = subsplat_stencil_effect->TechniqueByName("SetSubsplatStencil");

		subsplat_cur_lower_level_param_ = subsplat_stencil_effect->ParameterByName("cur_lower_level");
		subsplat_is_not_first_last_level_param_ = subsplat_stencil_effect->ParameterByName("is_not_first_last_level");
		subsplat_depth_deriv_tex_param_ = subsplat_stencil_effect->ParameterByName("depth_deriv_tex");
		subsplat_normal_cone_tex_param_ = subsplat_stencil_effect->ParameterByName("normal_cone_tex");
		subsplat_depth_normal_threshold_param_ = subsplat_stencil_effect->ParameterByName("depth_normal_threshold");
		subsplat_far_plane_param_ = subsplat_stencil_effect->ParameterByName("far_plane");

		upsampling_pp_ = SyncLoadPostProcess("MultiRes.ppml", "Upsampling");
	}
Beispiel #13
0
	GpuFftCS5::GpuFftCS5(uint32_t width, uint32_t height, bool forward)
			: width_(width), height_(height), forward_(forward)
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();

		tmp_real_tex_[0] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr);
		tmp_imag_tex_[0] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr);

		tmp_real_tex_[1] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr);
		tmp_imag_tex_[1] = rf.MakeTexture2D(width, height, 1, 1, EF_ABGR32F, 1, 0, EAH_GPU_Read | EAH_GPU_Unordered, nullptr);

		effect_ = SyncLoadRenderEffect("FFT.fxml");
		radix008a_tech_ = effect_->TechniqueByName("FFTRadix008A5");
		radix008a_final_x_tech_ = effect_->TechniqueByName("FFTRadix008AFinalX5");
		radix008a_final_y_tech_ = effect_->TechniqueByName("FFTRadix008AFinalY5");

		*(effect_->ParameterByName("tex_width_height")) = uint2(width - 1, height - 1);

		*(effect_->ParameterByName("forward")) = static_cast<int32_t>(forward_);
		*(effect_->ParameterByName("scale")) = 1.0f / (width_ * height_);
	}
Beispiel #14
0
	SDSMCascadedShadowLayer::SDSMCascadedShadowLayer()
		: frame_index_(0)
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();
		RenderDeviceCaps const & caps = rf.RenderEngineInstance().DeviceCaps();
		cs_support_ = caps.cs_support && (caps.max_shader_model >= ShaderModel(5, 0));

		if (cs_support_)
		{
			interval_buff_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Write | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_GR32F);
			scale_buff_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Write | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_BGR32F);
			bias_buff_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Write | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_BGR32F);
			cascade_min_buff_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Write | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_BGR32F);
			cascade_max_buff_ = rf.MakeVertexBuffer(BU_Dynamic, EAH_GPU_Read | EAH_GPU_Write | EAH_GPU_Unordered | EAH_GPU_Structured, nullptr, EF_BGR32F);

			interval_buff_->Resize(MAX_NUM_CASCADES * sizeof(float2));
			scale_buff_->Resize(MAX_NUM_CASCADES * sizeof(float3));
			bias_buff_->Resize(MAX_NUM_CASCADES * sizeof(float3));
			cascade_min_buff_->Resize(MAX_NUM_CASCADES * sizeof(float3));
			cascade_max_buff_->Resize(MAX_NUM_CASCADES * sizeof(float3));

			for (uint32_t i = 0; i < 2; ++ i)
			{
				interval_cpu_buffs_[i] = rf.MakeVertexBuffer(BU_Dynamic, EAH_CPU_Read, nullptr);
				scale_cpu_buffs_[i] = rf.MakeVertexBuffer(BU_Dynamic, EAH_CPU_Read, nullptr);
				bias_cpu_buffs_[i] = rf.MakeVertexBuffer(BU_Dynamic, EAH_CPU_Read, nullptr);

				interval_cpu_buffs_[i]->Resize(interval_buff_->Size());
				scale_cpu_buffs_[i]->Resize(scale_buff_->Size());
				bias_cpu_buffs_[i]->Resize(bias_buff_->Size());
			}

			RenderEffectPtr effect = SyncLoadRenderEffect("CascadedShadow.fxml");

			clear_z_bounds_tech_ = effect->TechniqueByName("ClearZBounds");
			reduce_z_bounds_from_depth_tech_ = effect->TechniqueByName("ReduceZBoundsFromDepth");
			compute_log_cascades_from_z_bounds_tech_ = effect->TechniqueByName("ComputeLogCascadesFromZBounds");
			clear_cascade_bounds_tech_ = effect->TechniqueByName("ClearCascadeBounds");
			reduce_bounds_from_depth_tech_ = effect->TechniqueByName("ReduceBoundsFromDepth");
			compute_custom_cascades_tech_ = effect->TechniqueByName("ComputeCustomCascades");

			interval_buff_param_ = effect->ParameterByName("interval_buff");
			interval_buff_uint_param_ = effect->ParameterByName("interval_buff_uint");
			interval_buff_read_param_ = effect->ParameterByName("interval_buff_read");
			scale_buff_param_ = effect->ParameterByName("scale_buff");
			bias_buff_param_ = effect->ParameterByName("bias_buff");
			cascade_min_buff_uint_param_ = effect->ParameterByName("cascade_min_buff_uint");
			cascade_max_buff_uint_param_ = effect->ParameterByName("cascade_max_buff_uint");
			cascade_min_buff_read_param_ = effect->ParameterByName("cascade_min_buff_read");
			cascade_max_buff_read_param_ = effect->ParameterByName("cascade_max_buff_read");
			depth_tex_param_ = effect->ParameterByName("depth_tex");
			num_cascades_param_ = effect->ParameterByName("num_cascades");
			inv_depth_width_height_param_ = effect->ParameterByName("inv_depth_width_height");
			near_far_param_ = effect->ParameterByName("near_far");
			upper_left_param_ = effect->ParameterByName("upper_left");
			xy_dir_param_ = effect->ParameterByName("xy_dir");
			view_to_light_view_proj_param_ = effect->ParameterByName("view_to_light_view_proj");
			light_space_border_param_ = effect->ParameterByName("light_space_border");
			max_cascade_scale_param_ = effect->ParameterByName("max_cascade_scale");
		}
		else
		{
			reduce_z_bounds_from_depth_pp_ = SyncLoadPostProcess("CascadedShadow.ppml", "reduce_z_bounds_from_depth");
			reduce_z_bounds_from_depth_mip_map_pp_ = SyncLoadPostProcess("CascadedShadow.ppml", "reduce_z_bounds_from_depth_mip_map");
			compute_log_cascades_from_z_bounds_pp_ = SyncLoadPostProcess("CascadedShadow.ppml", "compute_log_cascades_from_z_bounds");

			interval_tex_ = rf.MakeTexture2D(MAX_NUM_CASCADES, 1, 1, 1, EF_GR16F, 1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);
			for (uint32_t i = 0; i < 2; ++ i)
			{
				interval_cpu_texs_[i] = rf.MakeTexture2D(MAX_NUM_CASCADES, 1, 1, 1, EF_GR16F, 1, 0, EAH_CPU_Read, nullptr);
			}
		}
	}
Beispiel #15
0
	RenderDecal::RenderDecal(TexturePtr const & normal_tex, TexturePtr const & diffuse_tex, float3 const & diffuse_clr,
			TexturePtr const & specular_tex, float3 const & specular_level, float shininess)
		: RenderableHelper(L"Decal")
	{
		this->BindDeferredEffect(SyncLoadRenderEffect("Decal.fxml"));

		gbuffer_alpha_test_rt0_tech_ = deferred_effect_->TechniqueByName("DecalGBufferAlphaTestRT0Tech");
		gbuffer_alpha_test_rt1_tech_ = deferred_effect_->TechniqueByName("DecalGBufferAlphaTestRT1Tech");
		gbuffer_alpha_test_mrt_tech_ = deferred_effect_->TechniqueByName("DecalGBufferAlphaTestMRTTech");
		technique_ = gbuffer_alpha_test_rt0_tech_;

		pos_aabb_ = AABBox(float3(-1, -1, -1), float3(1, 1, 1));
		tc_aabb_ = AABBox(float3(0, 0, 0), float3(1, 1, 0));

		float3 xyzs[] =
		{
			pos_aabb_.Corner(0), pos_aabb_.Corner(1), pos_aabb_.Corner(2), pos_aabb_.Corner(3),
			pos_aabb_.Corner(4), pos_aabb_.Corner(5), pos_aabb_.Corner(6), pos_aabb_.Corner(7)
		};

		uint16_t indices[] =
		{
			0, 2, 3, 3, 1, 0,
			5, 7, 6, 6, 4, 5,
			4, 0, 1, 1, 5, 4,
			4, 6, 2, 2, 0, 4,
			2, 6, 7, 7, 3, 2,
			1, 3, 7, 7, 5, 1
		};

		RenderFactory& rf = Context::Instance().RenderFactoryInstance();
		rl_ = rf.MakeRenderLayout();
		rl_->TopologyType(RenderLayout::TT_TriangleList);

		ElementInitData init_data;
		init_data.row_pitch = sizeof(xyzs);
		init_data.slice_pitch = 0;
		init_data.data = xyzs;

		GraphicsBufferPtr vb = rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindVertexStream(vb, make_tuple(vertex_element(VEU_Position, 0, EF_BGR32F)));

		init_data.row_pitch = sizeof(indices);
		init_data.slice_pitch = 0;
		init_data.data = indices;

		GraphicsBufferPtr ib = rf.MakeIndexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data);
		rl_->BindIndexStream(ib, EF_R16UI);

		model_mat_ = float4x4::Identity();
		effect_attrs_ |= EA_AlphaTest;

		inv_mv_ep_ = technique_->Effect().ParameterByName("inv_mv");
		g_buffer_rt0_tex_param_ = deferred_effect_->ParameterByName("g_buffer_rt0_tex");

		normal_tex_ = normal_tex;
		diffuse_tex_ = diffuse_tex;
		diffuse_clr_ = diffuse_clr;
		specular_tex_ = specular_tex;
		specular_level_ = specular_level.x();
		shininess_ = shininess;
	}
Beispiel #16
0
	MultiResSILLayer::MultiResSILLayer()
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();
		RenderEngine& re = rf.RenderEngineInstance();
		RenderDeviceCaps const & caps = re.DeviceCaps();

		{
			rl_quad_ = rf.MakeRenderLayout();
			rl_quad_->TopologyType(RenderLayout::TT_TriangleStrip);

			std::vector<float3> pos;
			std::vector<uint16_t> index;

			pos.push_back(float3(+1, +1, 1));
			pos.push_back(float3(-1, +1, 1));
			pos.push_back(float3(+1, -1, 1));
			pos.push_back(float3(-1, -1, 1));

			ElementInitData init_data;
			init_data.row_pitch = static_cast<uint32_t>(pos.size() * sizeof(pos[0]));
			init_data.slice_pitch = 0;
			init_data.data = &pos[0];
			rl_quad_->BindVertexStream(rf.MakeVertexBuffer(BU_Static, EAH_GPU_Read | EAH_Immutable, &init_data),
				make_tuple(vertex_element(VEU_Position, 0, EF_BGR32F)));
		}

		vpl_tex_ = rf.MakeTexture2D(VPL_COUNT, 4, 1, 1, EF_ABGR16F, 1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);	

		gbuffer_to_depth_derivate_pp_ = SyncLoadPostProcess("MultiRes.ppml", "GBuffer2DepthDerivate");
		depth_derivate_mipmap_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "DepthDerivateMipMap");
		gbuffer_to_normal_cone_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "GBuffer2NormalCone");
		normal_cone_mipmap_pp_ =  SyncLoadPostProcess("MultiRes.ppml", "NormalConeMipMap");

		RenderEffectPtr subsplat_stencil_effect = SyncLoadRenderEffect("MultiRes.fxml");
		subsplat_stencil_tech_ = subsplat_stencil_effect->TechniqueByName("SetSubsplatStencil");

		subsplat_cur_lower_level_param_ = subsplat_stencil_effect->ParameterByName("cur_lower_level");
		subsplat_is_not_first_last_level_param_ = subsplat_stencil_effect->ParameterByName("is_not_first_last_level");
		subsplat_depth_deriv_tex_param_ = subsplat_stencil_effect->ParameterByName("depth_deriv_tex");
		subsplat_normal_cone_tex_param_ = subsplat_stencil_effect->ParameterByName("normal_cone_tex");
		subsplat_depth_normal_threshold_param_ = subsplat_stencil_effect->ParameterByName("depth_normal_threshold");

		RenderEffectPtr vpls_lighting_effect = SyncLoadRenderEffect("VPLsLighting.fxml");
		vpls_lighting_instance_id_tech_ = vpls_lighting_effect->TechniqueByName("VPLsLightingInstanceID");
		vpls_lighting_no_instance_id_tech_ = vpls_lighting_effect->TechniqueByName("VPLsLightingNoInstanceID");

		vpl_view_param_ = vpls_lighting_effect->ParameterByName("view");
		vpl_proj_param_ = vpls_lighting_effect->ParameterByName("proj");
		vpl_depth_near_far_invfar_param_ = vpls_lighting_effect->ParameterByName("depth_near_far_invfar");
		vpl_light_pos_es_param_ = vpls_lighting_effect->ParameterByName("light_pos_es");
		vpl_light_color_param_ = vpls_lighting_effect->ParameterByName("light_color");
		vpl_light_falloff_param_ = vpls_lighting_effect->ParameterByName("light_falloff");
		vpl_x_coord_param_ = vpls_lighting_effect->ParameterByName("x_coord");
		vpl_gbuffer_tex_param_ = vpls_lighting_effect->ParameterByName("gbuffer_tex");
		vpl_depth_tex_param_ = vpls_lighting_effect->ParameterByName("depth_tex");
		*(vpls_lighting_effect->ParameterByName("vpls_tex")) = vpl_tex_;
		*(vpls_lighting_effect->ParameterByName("vpl_params")) = float2(1.0f / VPL_COUNT, 0.5f / VPL_COUNT);

		upsampling_pp_ = SyncLoadPostProcess("MultiRes.ppml", "Upsampling");

		rl_vpl_ = SyncLoadModel("indirect_light_proxy.meshml", EAH_GPU_Read | EAH_Immutable, CreateModelFactory<RenderModel>(), CreateMeshFactory<StaticMesh>())->Mesh(0)->GetRenderLayout();
		if (caps.instance_id_support)
		{
			rl_vpl_->NumInstances(VPL_COUNT);
		}
	}
Beispiel #17
0
	ProceduralTerrain::ProceduralTerrain()
		: HQTerrainRenderable(SyncLoadRenderEffect("ProceduralTerrain.fxml"))
	{
		RenderFactory& rf = Context::Instance().RenderFactoryInstance();
		RenderEngine& re = rf.RenderEngineInstance();
		RenderDeviceCaps const & caps = re.DeviceCaps();

		ElementFormat height_fmt;
		if (caps.pack_to_rgba_required)
		{
			if (caps.rendertarget_format_support(EF_ABGR8, 1, 0))
			{
				height_fmt = EF_ABGR8;
			}
			else
			{
				BOOST_ASSERT(caps.rendertarget_format_support(EF_ARGB8, 1, 0));
				height_fmt = EF_ARGB8;
			}
		}
		else
		{
			if (caps.rendertarget_format_support(EF_R16F, 1, 0))
			{
				height_fmt = EF_R16F;
			}
			else
			{
				BOOST_ASSERT(caps.rendertarget_format_support(EF_R32F, 1, 0));
				height_fmt = EF_R32F;
			}
		}
		height_map_tex_ = rf.MakeTexture2D(COARSE_HEIGHT_MAP_SIZE, COARSE_HEIGHT_MAP_SIZE, 1, 1, height_fmt,
			1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);
		height_map_cpu_tex_ = rf.MakeTexture2D(height_map_tex_->Width(0), height_map_tex_->Height(0),
			1, 1, height_map_tex_->Format(), 1, 0, EAH_CPU_Read, nullptr);

		ElementFormat gradient_fmt;
		if (EF_R16F == height_fmt)
		{
			gradient_fmt = EF_GR16F;
		}
		else if (EF_R32F == height_fmt)
		{
			gradient_fmt = EF_GR32F;
		}
		else
		{
			gradient_fmt = height_fmt;
		}
		gradient_map_tex_ = rf.MakeTexture2D(COARSE_HEIGHT_MAP_SIZE, COARSE_HEIGHT_MAP_SIZE, 1, 1, gradient_fmt,
			1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);
		gradient_map_cpu_tex_ = rf.MakeTexture2D(gradient_map_tex_->Width(0), gradient_map_tex_->Height(0),
			1, 1, gradient_map_tex_->Format(), 1, 0, EAH_CPU_Read, nullptr);

		ElementFormat mask_fmt;
		if (caps.texture_format_support(EF_ABGR8))
		{
			mask_fmt = EF_ABGR8;
		}
		else
		{
			BOOST_ASSERT(caps.texture_format_support(EF_ARGB8));
			mask_fmt = EF_ARGB8;
		}
		mask_map_tex_ = rf.MakeTexture2D(COARSE_HEIGHT_MAP_SIZE, COARSE_HEIGHT_MAP_SIZE, 1, 1, mask_fmt,
			1, 0, EAH_GPU_Read | EAH_GPU_Write, nullptr);
		mask_map_cpu_tex_ = rf.MakeTexture2D(mask_map_tex_->Width(0), mask_map_tex_->Height(0),
			1, 1, mask_map_tex_->Format(), 1, 0, EAH_CPU_Read, nullptr);

		height_pp_ = SyncLoadPostProcess("ProceduralTerrain.ppml", "height");
		gradient_pp_ = SyncLoadPostProcess("ProceduralTerrain.ppml", "gradient");
		mask_pp_ = SyncLoadPostProcess("ProceduralTerrain.ppml", "mask");

		height_pp_->OutputPin(0, height_map_tex_);

		gradient_pp_->InputPin(0, height_map_tex_);
		gradient_pp_->OutputPin(0, gradient_map_tex_);

		mask_pp_->InputPin(0, height_map_tex_);
		mask_pp_->InputPin(1, gradient_map_tex_);
		mask_pp_->OutputPin(0, mask_map_tex_);
	}