update use pbr material in LoadStaticMesh
This commit is contained in:
parent
0d6f7758ec
commit
d4bee40b78
@ -84,12 +84,13 @@ class TestApp:public CameraAppFramework
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
Vector4f color;
|
Vector4f color;
|
||||||
Vector4f abiment;
|
float metallic;
|
||||||
}color_material;
|
float roughness;
|
||||||
|
}pbr_material;
|
||||||
|
|
||||||
Vector3f sun_direction;
|
Vector3f sun_direction;
|
||||||
|
|
||||||
vulkan::Buffer * ubo_color =nullptr;
|
vulkan::Buffer * ubo_pbr_material =nullptr;
|
||||||
vulkan::Buffer * ubo_sun =nullptr;
|
vulkan::Buffer * ubo_sun =nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -206,9 +207,11 @@ private:
|
|||||||
{
|
{
|
||||||
LCG lcg;
|
LCG lcg;
|
||||||
|
|
||||||
color_material.color=Vector4f(1,1,1,1.0);
|
pbr_material.color=Vector4f(1,1,1,1.0);
|
||||||
color_material.abiment.Set(0.25,0.25,0.25,1.0);
|
pbr_material.metallic=0.5;
|
||||||
ubo_color=device->CreateUBO(sizeof(color_material),&color_material);
|
pbr_material.roughness=0.5;
|
||||||
|
|
||||||
|
ubo_pbr_material=device->CreateUBO(sizeof(pbr_material),&pbr_material);
|
||||||
|
|
||||||
sun_direction=Vector3f::RandomDir(lcg);
|
sun_direction=Vector3f::RandomDir(lcg);
|
||||||
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
|
ubo_sun=device->CreateUBO(sizeof(sun_direction),&sun_direction);
|
||||||
@ -219,11 +222,11 @@ private:
|
|||||||
mp_solid.material_instance->BindUBO("world",GetCameraMatrixBuffer());
|
mp_solid.material_instance->BindUBO("world",GetCameraMatrixBuffer());
|
||||||
mp_solid.material_instance->BindUBO("fs_world",GetCameraMatrixBuffer());
|
mp_solid.material_instance->BindUBO("fs_world",GetCameraMatrixBuffer());
|
||||||
|
|
||||||
mp_solid.material_instance->BindUBO("color_material",ubo_color);
|
mp_solid.material_instance->BindUBO("pbr_material",ubo_pbr_material);
|
||||||
mp_solid.material_instance->BindUBO("sun",ubo_sun);
|
mp_solid.material_instance->BindUBO("sun",ubo_sun);
|
||||||
mp_solid.material_instance->Update();
|
mp_solid.material_instance->Update();
|
||||||
|
|
||||||
db->Add(ubo_color);
|
db->Add(ubo_pbr_material);
|
||||||
db->Add(ubo_sun);
|
db->Add(ubo_sun);
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
@ -268,11 +271,9 @@ public:
|
|||||||
|
|
||||||
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))//,model_data->bounding_box))
|
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))//,model_data->bounding_box))
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
camera.zfar=10240;
|
if(!InitMP(&mp_solid, PRIM_TRIANGLES, OS_TEXT("res/shader/pbr_Light.vert"),
|
||||||
|
OS_TEXT("res/shader/pbr_DirectionLight.frag")))
|
||||||
if(!InitMP(&mp_solid, PRIM_TRIANGLES, OS_TEXT("res/shader/LightPosition3D.vert"),
|
|
||||||
OS_TEXT("res/shader/DirectionLight.frag")))
|
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
if(!InitMP(&mp_line, PRIM_LINES, OS_TEXT("res/shader/PositionColor3D.vert"),
|
if(!InitMP(&mp_line, PRIM_LINES, OS_TEXT("res/shader/PositionColor3D.vert"),
|
||||||
|
@ -307,7 +307,7 @@ public:
|
|||||||
camera.vp_width=w;
|
camera.vp_width=w;
|
||||||
camera.vp_height=h;
|
camera.vp_height=h;
|
||||||
camera.center.Set(0,0,0,1);
|
camera.center.Set(0,0,0,1);
|
||||||
camera.eye.Set(0,100,100,1); //xyz三个值不要一样,以方便调试
|
camera.eye.Set(10,10,10,1); //xyz三个值不要一样,以方便调试
|
||||||
|
|
||||||
camera.Refresh(); //更新矩阵计算
|
camera.Refresh(); //更新矩阵计算
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user