tested EnvCubemap OK!
This commit is contained in:
parent
b7714d8a83
commit
1b2a78dee2
@ -22,15 +22,18 @@ private:
|
|||||||
SceneNode render_root;
|
SceneNode render_root;
|
||||||
RenderList * render_list =nullptr;
|
RenderList * render_list =nullptr;
|
||||||
|
|
||||||
Material * material =nullptr;
|
Material * sky_material =nullptr;
|
||||||
MaterialInstance * material_instance =nullptr;
|
MaterialInstance * sky_mi =nullptr;
|
||||||
|
|
||||||
|
|
||||||
Material * axis_material =nullptr;
|
Material * axis_material =nullptr;
|
||||||
MaterialInstance * axis_mi =nullptr;
|
MaterialInstance * axis_mi =nullptr;
|
||||||
|
|
||||||
|
Material * envmap_material =nullptr;
|
||||||
|
MaterialInstance * envmap_mi =nullptr;
|
||||||
|
|
||||||
Pipeline * axis_pipeline =nullptr;
|
Pipeline * axis_pipeline =nullptr;
|
||||||
Pipeline * sky_pipeline =nullptr;
|
Pipeline * sky_pipeline =nullptr;
|
||||||
|
Pipeline * solid_pipeline =nullptr;
|
||||||
|
|
||||||
GPUBuffer * ubo_light =nullptr;
|
GPUBuffer * ubo_light =nullptr;
|
||||||
GPUBuffer * ubo_phong =nullptr;
|
GPUBuffer * ubo_phong =nullptr;
|
||||||
@ -40,6 +43,7 @@ private:
|
|||||||
|
|
||||||
Renderable * ro_axis =nullptr;
|
Renderable * ro_axis =nullptr;
|
||||||
Renderable * ro_cube =nullptr;
|
Renderable * ro_cube =nullptr;
|
||||||
|
Renderable * ro_sphere =nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -57,7 +61,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
texture =db->LoadTextureCube(OS_TEXT("res/cubemap/Test.TexCube"),false);
|
texture =db->LoadTextureCube(OS_TEXT("res/cubemap/Storforsen4.TexCube"),false);
|
||||||
|
|
||||||
if(!texture)
|
if(!texture)
|
||||||
return(false);
|
return(false);
|
||||||
@ -67,8 +71,8 @@ private:
|
|||||||
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||||
nullptr,
|
nullptr,
|
||||||
0,
|
0,
|
||||||
VK_FILTER_NEAREST,
|
VK_FILTER_LINEAR,
|
||||||
VK_FILTER_NEAREST,
|
VK_FILTER_LINEAR,
|
||||||
VK_SAMPLER_MIPMAP_MODE_LINEAR,
|
VK_SAMPLER_MIPMAP_MODE_LINEAR,
|
||||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
|
||||||
@ -88,14 +92,14 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
material=db->CreateMaterial(OS_TEXT("res/material/Skybox"));
|
sky_material=db->CreateMaterial(OS_TEXT("res/material/Skybox"));
|
||||||
if(!material)return(false);
|
if(!sky_material)return(false);
|
||||||
|
|
||||||
material_instance=db->CreateMaterialInstance(material);
|
sky_mi=db->CreateMaterialInstance(sky_material);
|
||||||
if(!material_instance)return(false);
|
if(!sky_mi)return(false);
|
||||||
|
|
||||||
{
|
{
|
||||||
MaterialParameters *mp_texture=material_instance->GetMP(DescriptorSetsType::Value);
|
MaterialParameters *mp_texture=sky_mi->GetMP(DescriptorSetsType::Value);
|
||||||
|
|
||||||
if(!mp_texture)
|
if(!mp_texture)
|
||||||
return(false);
|
return(false);
|
||||||
@ -105,10 +109,32 @@ private:
|
|||||||
|
|
||||||
mp_texture->Update();
|
mp_texture->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sky_pipeline=CreatePipeline(sky_mi,InlinePipeline::Sky,Prim::Triangles);
|
||||||
|
if(!sky_pipeline)return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sky_pipeline=CreatePipeline(material_instance,InlinePipeline::Sky,Prim::Triangles);
|
{
|
||||||
if(!sky_pipeline)return(false);
|
envmap_material=db->CreateMaterial(OS_TEXT("res/material/EnvCubemap"));
|
||||||
|
if(!envmap_material)return(false);
|
||||||
|
|
||||||
|
envmap_mi=db->CreateMaterialInstance(envmap_material);
|
||||||
|
if(!envmap_mi)return(false);
|
||||||
|
|
||||||
|
{
|
||||||
|
MaterialParameters *mp_texture=envmap_mi->GetMP(DescriptorSetsType::Value);
|
||||||
|
|
||||||
|
if(!mp_texture)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
if(!mp_texture->BindSampler("EnvCubemap" ,texture, sampler))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
mp_texture->Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
solid_pipeline=CreatePipeline(envmap_mi,InlinePipeline::Solid3D,Prim::Triangles);
|
||||||
|
}
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -123,61 +149,38 @@ private:
|
|||||||
ro_axis=CreateRenderableAxis(db,axis_mi->GetVAB(),&aci);
|
ro_axis=CreateRenderableAxis(db,axis_mi->GetVAB(),&aci);
|
||||||
}
|
}
|
||||||
|
|
||||||
const VAB *vab=material_instance->GetVAB();
|
|
||||||
|
|
||||||
{
|
{
|
||||||
struct CubeCreateInfo cci;
|
struct CubeCreateInfo cci;
|
||||||
|
|
||||||
ro_cube=CreateRenderableCube(db,vab,&cci);
|
ro_cube=CreateRenderableCube(db,sky_mi->GetVAB(),&cci);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ro_sphere=CreateRenderableSphere(db,envmap_mi->GetVAB(),64);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitUBO()
|
bool InitUBO()
|
||||||
{
|
{
|
||||||
{
|
if(!BindCameraUBO(sky_mi))return(false);
|
||||||
MaterialParameters *mp_global=axis_mi->GetMP(DescriptorSetsType::Global);
|
if(!BindCameraUBO(envmap_mi))return(false);
|
||||||
|
|
||||||
if(!mp_global)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false);
|
|
||||||
|
|
||||||
mp_global->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
|
|
||||||
|
|
||||||
if(!mp_global)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false);
|
|
||||||
|
|
||||||
mp_global->Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Add(Renderable *r,Pipeline *pl)
|
SceneNode *Add(Renderable *r,MaterialInstance *mi,Pipeline *pl)
|
||||||
{
|
{
|
||||||
auto ri=db->CreateRenderableInstance(r,material_instance,pl);
|
auto ri=db->CreateRenderableInstance(r,mi,pl);
|
||||||
|
|
||||||
render_root.CreateSubNode(ri);
|
return render_root.CreateSubNode(ri);
|
||||||
}
|
|
||||||
|
|
||||||
void Add(Renderable *r,Pipeline *pl,const Matrix4f &mat)
|
|
||||||
{
|
|
||||||
auto ri=db->CreateRenderableInstance(r,material_instance,pl);
|
|
||||||
|
|
||||||
render_root.CreateSubNode(mat,ri);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InitScene()
|
bool InitScene()
|
||||||
{
|
{
|
||||||
render_root.CreateSubNode(db->CreateRenderableInstance(ro_axis,axis_mi,axis_pipeline));
|
Add(ro_axis,axis_mi,axis_pipeline);
|
||||||
|
Add(ro_cube,sky_mi,sky_pipeline);
|
||||||
Add(ro_cube,sky_pipeline);
|
Add(ro_sphere,envmap_mi,solid_pipeline)->SetLocalMatrix(scale(5,5,5));
|
||||||
|
|
||||||
render_root.RefreshMatrix();
|
render_root.RefreshMatrix();
|
||||||
render_list->Expend(GetCameraInfo(),&render_root);
|
render_list->Expend(GetCameraInfo(),&render_root);
|
||||||
|
2
res
2
res
@ -1 +1 @@
|
|||||||
Subproject commit 0b2bcee35cdee99d3109773f519160e5b2f2ede0
|
Subproject commit 0d4aad76920037cdaf8aca01c236eb1ee63a74d0
|
Loading…
x
Reference in New Issue
Block a user