继续ds(未完成)
This commit is contained in:
parent
60d31a4886
commit
dcc41f2073
@ -35,15 +35,11 @@ private:
|
|||||||
vulkan::Pipeline * pipeline;
|
vulkan::Pipeline * pipeline;
|
||||||
};//
|
};//
|
||||||
|
|
||||||
SubpassParam sp_gbuffer_opaque;
|
SubpassParam sp_gbuffer;
|
||||||
SubpassParam sp_gbuffer_alpha_test;
|
SubpassParam sp_composition;
|
||||||
SubpassParam sp_ds_composition;
|
|
||||||
|
|
||||||
vulkan::Renderable *ro_sphere;
|
vulkan::Renderable *ro_sphere;
|
||||||
|
|
||||||
vulkan::Buffer * ubo_atomsphere =nullptr;
|
|
||||||
AtomsphereData atomsphere_data;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool InitSubpass(SubpassParam *sp,const OSString &vs,const OSString &fs)
|
bool InitSubpass(SubpassParam *sp,const OSString &vs,const OSString &fs)
|
||||||
@ -60,50 +56,37 @@ private:
|
|||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateRenderObject()
|
bool InitGBufferPipeline(SubpassParam *sp)
|
||||||
{
|
{
|
||||||
ro_sphere=CreateRenderableSphere(db,material,128);
|
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,sp->material,device->GetRenderPass(),device->GetExtent());
|
||||||
}
|
pipeline_creater->SetDepthTest(true);
|
||||||
|
pipeline_creater->SetDepthWrite(true);
|
||||||
|
pipeline_creater->SetCullMode(VK_CULL_MODE_BACK_BIT);
|
||||||
|
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||||
|
sp->pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
bool InitAtomsphereUBO(vulkan::DescriptorSets *desc_set,uint bindpoint)
|
if(!sp->pipeline)
|
||||||
{
|
|
||||||
atomsphere_data.position.Set(0,0.1f,-1.0f);
|
|
||||||
atomsphere_data.intensity=22.0f;
|
|
||||||
atomsphere_data.scattering_direction=0.758f;
|
|
||||||
|
|
||||||
ubo_atomsphere=db->CreateUBO(sizeof(AtomsphereData),&atomsphere_data);
|
|
||||||
|
|
||||||
if(!ubo_atomsphere)
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
return desc_set->BindUBO(bindpoint,*ubo_atomsphere);
|
db->Add(sp->pipeline);
|
||||||
}
|
|
||||||
|
|
||||||
bool InitUBO()
|
delete pipeline_creater;
|
||||||
{
|
|
||||||
if(!InitCameraUBO(descriptor_sets,material->GetUBO("world")))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!InitAtomsphereUBO(descriptor_sets,material->GetUBO("sun")))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
descriptor_sets->Update();
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitPipeline()
|
bool InitCompositionPipeline(SubpassParam *sp)
|
||||||
{
|
{
|
||||||
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,material,device->GetRenderPass(),device->GetExtent());
|
vulkan::PipelineCreater *pipeline_creater=new vulkan::PipelineCreater(device,sp->material,device->GetRenderPass(),device->GetExtent());
|
||||||
pipeline_creater->SetDepthTest(true);
|
pipeline_creater->SetDepthTest(false);
|
||||||
pipeline_creater->SetDepthWrite(true);
|
pipeline_creater->SetDepthWrite(false);
|
||||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||||
pipeline_solid=pipeline_creater->Create();
|
sp->pipeline=pipeline_creater->Create();
|
||||||
|
|
||||||
if(!pipeline_solid)
|
if(!sp->pipeline)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
db->Add(pipeline_solid);
|
db->Add(sp->pipeline);
|
||||||
|
|
||||||
delete pipeline_creater;
|
delete pipeline_creater;
|
||||||
return(true);
|
return(true);
|
||||||
@ -111,14 +94,35 @@ private:
|
|||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
InitSubpass(&sp_gbuffer_opaque, OS_TEXT("gbuffer_opaque.vert.spv"), OS_TEXT("gbuffer_opaque.frag.spv") );
|
InitSubpass(&sp_gbuffer, OS_TEXT("gbuffer_opaque.vert.spv"),OS_TEXT("gbuffer_opaque.frag.spv"));
|
||||||
//InitSubpass(&sp_gbuffer_alpha_test, OS_TEXT("sp_gbuffer_alpha_test.vert.spv"), OS_TEXT("sp_gbuffer_alpha_test.frag.spv") );
|
InitSubpass(&sp_composition, OS_TEXT("ds_composition.vert.spv"),OS_TEXT("ds_composition.frag.spv"));
|
||||||
InitSubpass(&sp_ds_composition, OS_TEXT("ds_composition.vert.spv"), OS_TEXT("ds_composition.frag.spv") );
|
|
||||||
|
InitGBufferPipeline(&sp_gbuffer);
|
||||||
|
InitCompositionPipeline(&sp_composition);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitScene()
|
void CreateRenderObject(vulkan::Material *mtl)
|
||||||
{
|
{
|
||||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_sphere),scale(1000));
|
ro_sphere=CreateRenderableSphere(db,mtl,128);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitUBO(SubpassParam *sp)
|
||||||
|
{
|
||||||
|
if(!InitCameraUBO(sp->desc_sets,sp->material->GetUBO("world")))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
sp->desc_sets->Update();
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InitScene(SubpassParam *sp)
|
||||||
|
{
|
||||||
|
if(!InitUBO(sp))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
CreateRenderObject(sp->material);
|
||||||
|
|
||||||
|
render_root.Add(db->CreateRenderableInstance(sp->pipeline,sp->desc_sets,ro_sphere),scale(1000));
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
render_root.ExpendToList(&render_list);
|
render_root.ExpendToList(&render_list);
|
||||||
@ -136,15 +140,7 @@ public:
|
|||||||
if(!InitMaterial())
|
if(!InitMaterial())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
CreateRenderObject();
|
if(!InitScene(&sp_gbuffer))
|
||||||
|
|
||||||
if(!InitUBO())
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!InitPipeline())
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!InitScene())
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -133,12 +133,7 @@ public:
|
|||||||
void InitCommandBuffer()
|
void InitCommandBuffer()
|
||||||
{
|
{
|
||||||
if(cmd_buf)
|
if(cmd_buf)
|
||||||
{
|
SAFE_CLEAR_OBJECT_ARRAY(cmd_buf,swap_chain_count);
|
||||||
for(uint i=0;i<swap_chain_count;i++)
|
|
||||||
delete cmd_buf[i];
|
|
||||||
|
|
||||||
delete[] cmd_buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
swap_chain_count=device->GetSwapChainImageCount();
|
swap_chain_count=device->GetSwapChainImageCount();
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user