added BlinnPhong.h
This commit is contained in:
parent
b9e70426a1
commit
ff6a644e8f
@ -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:
|
||||
|
||||
@ -48,9 +55,29 @@ 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);
|
||||
|
||||
|
22
inc/hgl/graph/mtl/BlinnPhong.h
Normal file
22
inc/hgl/graph/mtl/BlinnPhong.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include<hgl/graph/mtl/StdMaterial.h>
|
||||
#include<hgl/math/Vector.h>
|
||||
|
||||
namespace hgl
|
||||
{
|
||||
namespace graph
|
||||
{
|
||||
namespace mtl
|
||||
{
|
||||
namespace blinnphong
|
||||
{
|
||||
struct SunLight
|
||||
{
|
||||
Vector3f direction;
|
||||
Vector3f color;
|
||||
};//struct SunLight
|
||||
}//namespace blinnphong
|
||||
}//namespace mtl
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
@ -49,6 +49,8 @@ SOURCE_GROUP("Common" FILES ${SHADERGEN_COMMON_FILES})
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
SET(BLINN_PHONG_HEADER_FILES ${STD_MTL_HEADER_PATH}/BlinnPhong.h)
|
||||
|
||||
SET(STD_MTL_2D_SOURCE_FILES ${STD_MTL_HEADER_PATH}/Material2DCreateConfig.h
|
||||
2d/Std2DMaterial.h
|
||||
2d/Std2DMaterial.cpp
|
||||
@ -76,6 +78,9 @@ SET(STD_MTL_SOURCE ${STD_MTL_HEADER_PATH}/MaterialConfig.h
|
||||
MaterialFileLoader.cpp)
|
||||
|
||||
SOURCE_GROUP("Standard Material" FILES ${STD_MTL_SOURCE})
|
||||
|
||||
SOURCE_GROUP("Standard Material\\Light Model\\Blinn Phong" FILES ${BLINN_PHONG_HEADER_FILES})
|
||||
|
||||
SOURCE_GROUP("Standard Material\\2D" FILES ${STD_MTL_2D_SOURCE_FILES})
|
||||
SOURCE_GROUP("Standard Material\\3D" FILES ${STD_MTL_3D_SOURCE_FILES})
|
||||
|
||||
@ -93,6 +98,7 @@ add_cm_library(ULRE.ShaderGen "ULRE" ${DESC_INFO_HEADER_FILES}
|
||||
${SHADERGEN_COMMON_FILES}
|
||||
${SHADER_LIBRARY_FILES}
|
||||
${STD_MTL_SOURCE}
|
||||
${BLINN_PHONG_HEADER_FILES}
|
||||
${STD_MTL_2D_SOURCE_FILES}
|
||||
${STD_MTL_3D_SOURCE_FILES}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user