added axis at Cubemap test,tested ok! that texture files had mipmaps...next step should test autogen mipmaps.

This commit is contained in:
hyzboy 2022-01-07 17:14:34 +08:00
parent 1d499ffd5b
commit 2eef520786

View File

@ -25,6 +25,11 @@ private:
Material * material =nullptr; Material * material =nullptr;
MaterialInstance * material_instance =nullptr; MaterialInstance * material_instance =nullptr;
Material * axis_material =nullptr;
MaterialInstance * axis_mi =nullptr;
Pipeline * axis_pipeline =nullptr;
Pipeline * pipeline_solid =nullptr; Pipeline * pipeline_solid =nullptr;
GPUBuffer * ubo_light =nullptr; GPUBuffer * ubo_light =nullptr;
@ -33,6 +38,7 @@ private:
Sampler * sampler =nullptr; Sampler * sampler =nullptr;
TextureCube * texture =nullptr; TextureCube * texture =nullptr;
Renderable * ro_axis =nullptr;
Renderable * ro_cube =nullptr; Renderable * ro_cube =nullptr;
private: private:
@ -40,7 +46,18 @@ private:
bool InitMaterial() bool InitMaterial()
{ {
{ {
texture =db->LoadTextureCube(OS_TEXT("res/cubemap/Test/Test.TexCube"),false); axis_material=db->CreateMaterial(OS_TEXT("res/material/VertexColor3D"));
if(!axis_material)return(false);
axis_mi=db->CreateMaterialInstance(axis_material);
if(!axis_mi)return(false);
axis_pipeline=CreatePipeline(axis_mi,InlinePipeline::Solid3D,Prim::Lines);
if(!axis_pipeline)return(false);
}
{
texture =db->LoadTextureCube(OS_TEXT("res/cubemap/Storforsen4.TexCube"),false);
if(!texture) if(!texture)
return(false); return(false);
@ -50,9 +67,9 @@ 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_NEAREST, 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,
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
@ -98,6 +115,14 @@ private:
void CreateRenderObject() void CreateRenderObject()
{ {
{
struct AxisCreateInfo aci;
aci.size=200;
ro_axis=CreateRenderableAxis(db,axis_mi->GetVAB(),&aci);
}
const VAB *vab=material_instance->GetVAB(); const VAB *vab=material_instance->GetVAB();
{ {
@ -107,6 +132,22 @@ private:
} }
} }
bool InitUBO()
{
{
MaterialParameters *mp_global=axis_mi->GetMP(DescriptorSetsType::Global);
if(!mp_global)
return(false);
if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false);
mp_global->Update();
}
return(true);
}
void Add(Renderable *r,Pipeline *pl) void Add(Renderable *r,Pipeline *pl)
{ {
auto ri=db->CreateRenderableInstance(r,material_instance,pl); auto ri=db->CreateRenderableInstance(r,material_instance,pl);
@ -123,6 +164,8 @@ private:
bool InitScene() bool InitScene()
{ {
render_root.CreateSubNode(db->CreateRenderableInstance(ro_axis,axis_mi,axis_pipeline));
Add(ro_cube,pipeline_solid); Add(ro_cube,pipeline_solid);
render_root.RefreshMatrix(); render_root.RefreshMatrix();
@ -148,6 +191,9 @@ public:
if(!InitMaterial()) if(!InitMaterial())
return(false); return(false);
if(!InitUBO())
return(false);
CreateRenderObject(); CreateRenderObject();
if(!InitScene()) if(!InitScene())