fixed a example that is SceneTree, and then should support instance.

This commit is contained in:
hyzboy 2022-03-28 16:10:24 +08:00
parent 727d36f16b
commit 3e81d05c81
4 changed files with 32 additions and 21 deletions

2
CMCore

@ -1 +1 @@
Subproject commit 6c2f5b255c0c04e20531e2fc8ac7843df264fa5b
Subproject commit bfed461c84e7b780a3ab7a86d2c45e27b247f29f

View File

@ -109,12 +109,12 @@ private:
rb_config.Color.Set(1,1,1,1);
rb_config.OutColor.Set(0,0,0,0);
rb_config.InColor.Use(COLOR::MozillaOrange,1.0);
rb_config.InColor=GetColor4f(COLOR::MozillaOrange,1.0);
rb_config.Radius[0]=0;
rb_config.Radius[1]=16;
rb_config.Radius[2]=0;
rb_config.Radius[3]=16;
rb_config.LineWidth=1.5;
rb_config.LineWidth=2;
ubo_rb_config =db->CreateUBO(sizeof(RoundedBoxConfig), &rb_config);

View File

@ -17,7 +17,7 @@ class TestApp:public CameraAppFramework
{
struct
{
Color4f color;
Color4f diffuse; //虽然shader中写vec3但这里依然用Color4f
Color4f abiment;
}color_material;
@ -46,15 +46,17 @@ public:
{
start_time=GetDoubleTime();
}
~TestApp()=default;
~TestApp()
{
SAFE_CLEAR(render_list);
}
private:
bool InitMaterial()
{
material=db->CreateMaterial(OS_TEXT("res/shader/VertexLight.vert"),
OS_TEXT("res/shader/VertexColor.frag"));
material=db->CreateMaterial(OS_TEXT("res/material/SimplestDirectionLight"));
if(!material)
return(false);
@ -70,21 +72,29 @@ private:
bool InitUBO()
{
color_material.color.Set(1,1,1,1);
color_material.abiment.Set(0.25,0.25,0.25,1.0);
color_material.diffuse.Set(1,1,1);
color_material.abiment.Set(0.25,0.25,0.25);
ubo_color=device->CreateUBO(sizeof(color_material),&color_material);
ubo_color=db->CreateUBO(sizeof(color_material),&color_material);
if(!ubo_color)return(false);
sun_direction=normalized(Vector3f(rand(),rand(),rand()));
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
ubo_sun=db->CreateUBO(sizeof(sun_direction),&sun_direction);
if(!ubo_sun)return(false);
material_instance->BindUBO("color_material",ubo_color);
material_instance->BindUBO("sun",ubo_sun);
{
MaterialParameters *mp=material_instance->GetMP(DescriptorSetsType::Value);
material_instance->Update();
if(!mp)return(false);
mp->BindUBO("material",ubo_color);
mp->BindUBO("sun",ubo_sun);
mp->Update();
}
BindCameraUBO(material_instance);
return(true);
}
@ -103,7 +113,7 @@ private:
uint count;
float size;
RenderableInstance *ri=db->CreateRenderableInstance(pipeline,material_instance,renderable_object);
RenderableInstance *ri=db->CreateRenderableInstance(renderable_object,material_instance,pipeline);
for(uint i=0;i<360;i++)
{
@ -131,6 +141,8 @@ public:
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
return(false);
render_list=new RenderList(device);
if(!InitMaterial())
return(false);
@ -152,16 +164,15 @@ public:
{
CameraAppFramework::Draw();
Matrix4f rot=rotate(GetDoubleTime()-start_time,camera.up_vector);
Matrix4f rot=rotate(GetDoubleTime()-start_time,camera->world_up);
render_root.RefreshMatrix(&rot);
render_list.Clear();
render_root.ExpendToList(&render_list);
render_list->Expend(GetCameraInfo(),&render_root);
}
void BuildCommandBuffer(uint32 index)
{
VulkanApplicationFramework::BuildCommandBuffer(index,&render_list);
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
}
};//class TestApp:public CameraAppFramework

2
res

@ -1 +1 @@
Subproject commit fd0bd99c873a376121eb534b99fe7fbfb24c2fd2
Subproject commit 70b697f13ef20e957d51efcb0ff8632f4615e3c0