added BlinnPhong.h
This commit is contained in:
@@ -120,7 +120,7 @@ public:
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Resize(int w,int h)override
|
||||
void Resize(uint w,uint h)override
|
||||
{
|
||||
VulkanApplicationFramework::Resize(w,h);
|
||||
|
||||
|
@@ -26,7 +26,7 @@ private:
|
||||
Material * mtl_vtx_lum =nullptr;
|
||||
MaterialInstance * mi_plane_grid =nullptr;
|
||||
Pipeline * pipeline_vtx_lum =nullptr;
|
||||
Primitive * ro_plane_grid =nullptr;
|
||||
Primitive * prim_plane_grid =nullptr;
|
||||
|
||||
Material * mtl_vtx_color =nullptr;
|
||||
MaterialInstance * mi_line =nullptr;
|
||||
@@ -158,7 +158,7 @@ private:
|
||||
pgci.lum=0.5;
|
||||
pgci.sub_lum=0.75;
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,mtl_vtx_lum->GetDefaultVIL(),&pgci);
|
||||
prim_plane_grid=CreatePlaneGrid(db,mtl_vtx_lum->GetDefaultVIL(),&pgci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -189,7 +189,7 @@ private:
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
Add(ro_plane_grid,mi_plane_grid,pipeline_vtx_lum);
|
||||
Add(prim_plane_grid,mi_plane_grid,pipeline_vtx_lum);
|
||||
Add(ro_line,mi_line,pipeline_vtx_color);
|
||||
|
||||
camera->pos=Vector3f(32,32,32);
|
||||
|
@@ -19,7 +19,7 @@ private:
|
||||
Material * material =nullptr;
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
Primitive * ro_plane_grid =nullptr;
|
||||
Primitive * prim_plane_grid =nullptr;
|
||||
MaterialInstance * material_instance[3]{};
|
||||
|
||||
private:
|
||||
@@ -62,14 +62,14 @@ private:
|
||||
pgci.lum=0.5;
|
||||
pgci.sub_lum=1.0;
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
||||
prim_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
||||
|
||||
return ro_plane_grid;
|
||||
return prim_plane_grid;
|
||||
}
|
||||
|
||||
Renderable *Add(MaterialInstance *mi,const Matrix4f &mat)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(ro_plane_grid,mi,pipeline);
|
||||
Renderable *ri=db->CreateRenderable(prim_plane_grid,mi,pipeline);
|
||||
|
||||
if(!ri)
|
||||
return(nullptr);
|
||||
|
@@ -38,7 +38,7 @@ private:
|
||||
|
||||
Pipeline * pipeline =nullptr;
|
||||
|
||||
Primitive * ro_plane_grid =nullptr;
|
||||
Primitive * prim_plane_grid =nullptr;
|
||||
|
||||
Primitive * ro_line =nullptr;
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
pgci.lum=0.5;
|
||||
pgci.sub_lum=0.75;
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
||||
prim_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -115,7 +115,7 @@ private:
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
Add(ro_plane_grid,mi_plane_grid);
|
||||
Add(prim_plane_grid,mi_plane_grid);
|
||||
Add(ro_line,mi_line);
|
||||
|
||||
camera->pos=Vector3f(32,32,32);
|
||||
|
@@ -19,12 +19,19 @@ static Color4f white_color(1,1,1,1);
|
||||
|
||||
class TestApp:public SceneAppFramework
|
||||
{
|
||||
private:
|
||||
private: //plane grid
|
||||
|
||||
Material * mtl_vertex_lum =nullptr;
|
||||
MaterialInstance * mi_plane_grid =nullptr;
|
||||
Pipeline * p_line =nullptr;
|
||||
Primitive * ro_plane_grid =nullptr;
|
||||
Primitive * prim_plane_grid =nullptr;
|
||||
|
||||
private: //sphere
|
||||
|
||||
Material * mtl_sun_light =nullptr;
|
||||
MaterialInstance * mi_sphere =nullptr;
|
||||
Pipeline * p_sphere =nullptr;
|
||||
Primitive * prim_sphere =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@@ -47,10 +54,30 @@ private:
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Add(Primitive *r,MaterialInstance *mi)
|
||||
|
||||
bool InitBlinnPhongSunLightMP()
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(r,mi,p_line);
|
||||
mtl::Material3DCreateConfig cfg(device->GetDeviceAttribute(),"BlinnPhong3D",Prim::Triangles);
|
||||
|
||||
cfg.local_to_world=true;
|
||||
|
||||
mtl_sun_light=db->LoadMaterial("Std3D/BlinnPhong/SunLightPureColor",&cfg);
|
||||
if(!mtl_sun_light)return(false);
|
||||
|
||||
mi_sphere=db->CreateMaterialInstance(mtl_sun_light);
|
||||
if(!mi_sphere)return(false);
|
||||
|
||||
p_sphere=CreatePipeline(mtl_sun_light,InlinePipeline::Solid3D,Prim::Triangles);
|
||||
|
||||
if(!p_sphere)
|
||||
return(false);
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
Renderable *Add(Primitive *r,MaterialInstance *mi,Pipeline *p)
|
||||
{
|
||||
Renderable *ri=db->CreateRenderable(r,mi,p);
|
||||
|
||||
if(!ri)
|
||||
{
|
||||
@@ -67,6 +94,7 @@ private:
|
||||
{
|
||||
using namespace inline_geometry;
|
||||
|
||||
//Plane Grid
|
||||
{
|
||||
struct PlaneGridCreateInfo pgci;
|
||||
|
||||
@@ -76,7 +104,12 @@ private:
|
||||
pgci.lum=0.5;
|
||||
pgci.sub_lum=0.75;
|
||||
|
||||
ro_plane_grid=CreatePlaneGrid(db,mtl_vertex_lum->GetDefaultVIL(),&pgci);
|
||||
prim_plane_grid=CreatePlaneGrid(db,mtl_vertex_lum->GetDefaultVIL(),&pgci);
|
||||
}
|
||||
|
||||
//Sphere
|
||||
{
|
||||
prim_sphere=CreateSphere(db,mi_sphere->GetVIL(),16);
|
||||
}
|
||||
|
||||
return(true);
|
||||
@@ -84,7 +117,8 @@ private:
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
Add(ro_plane_grid,mi_plane_grid);
|
||||
Add(prim_plane_grid,mi_plane_grid,p_line);
|
||||
Add(prim_sphere,mi_sphere,p_sphere);
|
||||
|
||||
camera->pos=Vector3f(32,32,32);
|
||||
camera_control->SetTarget(Vector3f(0,0,0));
|
||||
@@ -106,6 +140,9 @@ public:
|
||||
if(!InitVertexLumMP())
|
||||
return(false);
|
||||
|
||||
if(!InitBlinnPhongSunLightMP())
|
||||
return(false);
|
||||
|
||||
if(!CreateRenderObject())
|
||||
return(false);
|
||||
|
||||
|
Reference in New Issue
Block a user