fixed a example that is SceneTree, and then should support instance.
This commit is contained in:
parent
727d36f16b
commit
3e81d05c81
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 6c2f5b255c0c04e20531e2fc8ac7843df264fa5b
|
Subproject commit bfed461c84e7b780a3ab7a86d2c45e27b247f29f
|
@ -109,12 +109,12 @@ private:
|
|||||||
|
|
||||||
rb_config.Color.Set(1,1,1,1);
|
rb_config.Color.Set(1,1,1,1);
|
||||||
rb_config.OutColor.Set(0,0,0,0);
|
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[0]=0;
|
||||||
rb_config.Radius[1]=16;
|
rb_config.Radius[1]=16;
|
||||||
rb_config.Radius[2]=0;
|
rb_config.Radius[2]=0;
|
||||||
rb_config.Radius[3]=16;
|
rb_config.Radius[3]=16;
|
||||||
rb_config.LineWidth=1.5;
|
rb_config.LineWidth=2;
|
||||||
|
|
||||||
ubo_rb_config =db->CreateUBO(sizeof(RoundedBoxConfig), &rb_config);
|
ubo_rb_config =db->CreateUBO(sizeof(RoundedBoxConfig), &rb_config);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class TestApp:public CameraAppFramework
|
|||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Color4f color;
|
Color4f diffuse; //虽然shader中写vec3,但这里依然用Color4f
|
||||||
Color4f abiment;
|
Color4f abiment;
|
||||||
}color_material;
|
}color_material;
|
||||||
|
|
||||||
@ -47,14 +47,16 @@ public:
|
|||||||
start_time=GetDoubleTime();
|
start_time=GetDoubleTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
~TestApp()=default;
|
~TestApp()
|
||||||
|
{
|
||||||
|
SAFE_CLEAR(render_list);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool InitMaterial()
|
bool InitMaterial()
|
||||||
{
|
{
|
||||||
material=db->CreateMaterial(OS_TEXT("res/shader/VertexLight.vert"),
|
material=db->CreateMaterial(OS_TEXT("res/material/SimplestDirectionLight"));
|
||||||
OS_TEXT("res/shader/VertexColor.frag"));
|
|
||||||
if(!material)
|
if(!material)
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
@ -70,21 +72,29 @@ private:
|
|||||||
|
|
||||||
bool InitUBO()
|
bool InitUBO()
|
||||||
{
|
{
|
||||||
color_material.color.Set(1,1,1,1);
|
color_material.diffuse.Set(1,1,1);
|
||||||
color_material.abiment.Set(0.25,0.25,0.25,1.0);
|
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);
|
if(!ubo_color)return(false);
|
||||||
|
|
||||||
sun_direction=normalized(Vector3f(rand(),rand(),rand()));
|
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);
|
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);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -103,7 +113,7 @@ private:
|
|||||||
uint count;
|
uint count;
|
||||||
float size;
|
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++)
|
for(uint i=0;i<360;i++)
|
||||||
{
|
{
|
||||||
@ -131,6 +141,8 @@ public:
|
|||||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
render_list=new RenderList(device);
|
||||||
|
|
||||||
if(!InitMaterial())
|
if(!InitMaterial())
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
@ -152,16 +164,15 @@ public:
|
|||||||
{
|
{
|
||||||
CameraAppFramework::Draw();
|
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_root.RefreshMatrix(&rot);
|
||||||
render_list.Clear();
|
render_list->Expend(GetCameraInfo(),&render_root);
|
||||||
render_root.ExpendToList(&render_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildCommandBuffer(uint32 index)
|
void BuildCommandBuffer(uint32 index)
|
||||||
{
|
{
|
||||||
VulkanApplicationFramework::BuildCommandBuffer(index,&render_list);
|
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
|
||||||
}
|
}
|
||||||
};//class TestApp:public CameraAppFramework
|
};//class TestApp:public CameraAppFramework
|
||||||
|
|
||||||
|
2
res
2
res
@ -1 +1 @@
|
|||||||
Subproject commit fd0bd99c873a376121eb534b99fe7fbfb24c2fd2
|
Subproject commit 70b697f13ef20e957d51efcb0ff8632f4615e3c0
|
Loading…
x
Reference in New Issue
Block a user