改进SceneTree范例,使用实体带方向光球体
This commit is contained in:
parent
80dd4f6010
commit
fbac9f03c6
@ -1 +1 @@
|
||||
Subproject commit 06a42e93940fd2a377d5c4cbf5c4c8662d31ce3a
|
||||
Subproject commit bf7152aee5cffa219c6675c03d1e075b9c98c3bf
|
@ -11,8 +11,8 @@
|
||||
using namespace hgl;
|
||||
using namespace hgl::graph;
|
||||
|
||||
constexpr uint32_t SCREEN_WIDTH=128;
|
||||
constexpr uint32_t SCREEN_HEIGHT=128;
|
||||
constexpr uint32_t SCREEN_WIDTH=1280;
|
||||
constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
class TestApp:public CameraAppFramework
|
||||
{
|
||||
@ -42,8 +42,8 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition3D.vert.spv"),
|
||||
OS_TEXT("res/shader/FlatColor.frag.spv"));
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition3D.vert"),
|
||||
OS_TEXT("res/shader/FlatColor.frag"));
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
@ -138,7 +138,7 @@ private:
|
||||
|
||||
material_instance->BindUBO("color_material",ubo_color);
|
||||
|
||||
if(!InitCameraUBO(material_instance,"world"))
|
||||
if(!material_instance->BindUBO("world",GetCameraMatrixBuffer()))
|
||||
return(false);
|
||||
|
||||
material_instance->Update();
|
||||
|
@ -17,7 +17,13 @@ constexpr uint32_t SCREEN_HEIGHT=720;
|
||||
|
||||
class TestApp:public CameraAppFramework
|
||||
{
|
||||
Color4f color;
|
||||
struct
|
||||
{
|
||||
Vector4f color;
|
||||
Vector4f abiment;
|
||||
}color_material;
|
||||
|
||||
Vector3f sun_direction;
|
||||
|
||||
private:
|
||||
|
||||
@ -30,6 +36,7 @@ private:
|
||||
vulkan::MaterialInstance * material_instance =nullptr;
|
||||
|
||||
vulkan::Buffer * ubo_color =nullptr;
|
||||
vulkan::Buffer * ubo_sun =nullptr;
|
||||
|
||||
vulkan::Renderable * renderable_object =nullptr;
|
||||
|
||||
@ -48,8 +55,8 @@ private:
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition3D.vert"),
|
||||
OS_TEXT("res/shader/FlatColor.frag"));
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/LightPosition3D.vert"),
|
||||
OS_TEXT("res/shader/VertexColor.frag"));
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
@ -62,22 +69,30 @@ private:
|
||||
|
||||
void CreateRenderObject()
|
||||
{
|
||||
struct CubeCreateInfo cci;
|
||||
renderable_object=CreateRenderableSphere(db,material,40);
|
||||
|
||||
renderable_object=CreateRenderableCube(db,material,&cci);
|
||||
db->Add(renderable_object);
|
||||
}
|
||||
|
||||
bool InitUBO()
|
||||
{
|
||||
if(!InitCameraUBO(material_instance,"world"))
|
||||
return(false);
|
||||
|
||||
color.Set(1,1,0,1);
|
||||
ubo_color=device->CreateUBO(sizeof(Color4f),&color);
|
||||
LCG lcg;
|
||||
|
||||
color_material.color=Vector4f(1,1,1,1.0);
|
||||
color_material.abiment.Set(0.25,0.25,0.25,1.0);
|
||||
ubo_color=device->CreateUBO(sizeof(color_material),&color_material);
|
||||
|
||||
sun_direction=Vector3f::RandomDir(lcg);
|
||||
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
|
||||
|
||||
material_instance->BindUBO("world",GetCameraMatrixBuffer());
|
||||
material_instance->BindUBO("color_material",ubo_color);
|
||||
material_instance->BindUBO("sun",ubo_sun);
|
||||
|
||||
material_instance->Update();
|
||||
|
||||
db->Add(ubo_color);
|
||||
db->Add(ubo_sun);
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -88,7 +103,7 @@ private:
|
||||
pipeline_creater->SetDepthTest(true);
|
||||
pipeline_creater->SetDepthWrite(true);
|
||||
pipeline_creater->CloseCullFace();
|
||||
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_LINE);
|
||||
pipeline_creater->SetPolygonMode(VK_POLYGON_MODE_FILL);
|
||||
pipeline_creater->Set(PRIM_TRIANGLES);
|
||||
|
||||
pipeline_line=pipeline_creater->Create();
|
||||
|
@ -82,6 +82,9 @@ private:
|
||||
vulkan::Material * material =nullptr;
|
||||
vulkan::MaterialInstance * material_instance =nullptr;
|
||||
|
||||
vulkan::Material * pbr_material =nullptr;
|
||||
vulkan::MaterialInstance * pbr_material_instance =nullptr;
|
||||
|
||||
vulkan::Pipeline * pipeline_wireframe =nullptr;
|
||||
vulkan::Pipeline * pipeline_lines =nullptr;
|
||||
|
||||
@ -100,10 +103,15 @@ private:
|
||||
|
||||
private:
|
||||
|
||||
bool InitPBRMaterial()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool InitMaterial()
|
||||
{
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition3D.vert.spv"),
|
||||
OS_TEXT("res/shader/FlatColor.frag.spv"));
|
||||
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition3D.vert"),
|
||||
OS_TEXT("res/shader/FlatColor.frag"));
|
||||
if(!material)
|
||||
return(false);
|
||||
|
||||
|
2
res
2
res
@ -1 +1 @@
|
||||
Subproject commit 23685cd868ff941da4f0974035c8f4aa23594e03
|
||||
Subproject commit 69343b3bc6fb464f89ec22eca52c379dec58ac68
|
Loading…
x
Reference in New Issue
Block a user