看起来似乎完全正确的DEPTH TEST/MASK
This commit is contained in:
parent
f3a8028e7c
commit
fc67299042
@ -169,7 +169,7 @@ private:
|
||||
const VkFormat position_format =FMT_RGBA16F;
|
||||
const VkFormat color_format =FMT_RGBA16F;
|
||||
const VkFormat normal_format =FMT_RGBA16F;
|
||||
const VkFormat depth_format =FMT_D16UN;
|
||||
const VkFormat depth_format =FMT_D32F;
|
||||
|
||||
gbuffer.position=device->CreateAttachmentTextureColor(position_format, gbuffer.extent.width,gbuffer.extent.height);
|
||||
gbuffer.color =device->CreateAttachmentTextureColor(color_format, gbuffer.extent.width,gbuffer.extent.height);
|
||||
|
@ -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
|
||||
{
|
||||
@ -33,8 +33,7 @@ private:
|
||||
*ro_cone;
|
||||
|
||||
vulkan::Pipeline *pipeline_line =nullptr,
|
||||
*pipeline_solid =nullptr,
|
||||
*pipeline_twoside =nullptr;
|
||||
*pipeline_solid =nullptr;
|
||||
|
||||
private:
|
||||
|
||||
@ -156,22 +155,14 @@ private:
|
||||
return(false);
|
||||
|
||||
db->Add(pipeline_solid);
|
||||
|
||||
pipeline_creater->SetCullMode(VK_CULL_MODE_NONE);
|
||||
pipeline_twoside=pipeline_creater->Create();
|
||||
|
||||
if(!pipeline_twoside)
|
||||
return(false);
|
||||
|
||||
db->Add(pipeline_twoside);
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool InitScene()
|
||||
{
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_line,descriptor_sets,ro_plane_grid));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_dome));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_twoside,descriptor_sets,ro_torus));
|
||||
//render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_dome));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_torus));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cube ),translate(-10, 0, 5)*scale(10,10,10));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_sphere ),translate( 10, 0, 5)*scale(10,10,10));
|
||||
render_root.Add(db->CreateRenderableInstance(pipeline_solid,descriptor_sets,ro_cylinder ),translate( 0, 16, 0));
|
||||
|
@ -277,8 +277,8 @@ public:
|
||||
camera.height=h;
|
||||
camera.center.Set(0,0,0,1);
|
||||
camera.eye.Set(100,100,0,1); //xyz三个值不要一样,以方便调试
|
||||
camera.znear=-1;
|
||||
camera.zfar=1;
|
||||
camera.znear=0.01f;
|
||||
camera.zfar=1024;
|
||||
|
||||
camera.Refresh(); //更新矩阵计算
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace hgl
|
||||
float height; ///<视图高
|
||||
|
||||
float fov=60; ///<水平FOV
|
||||
float znear=-1,zfar=1; ///<Z轴上离眼睛的距离
|
||||
float znear=0.01,zfar=1024; ///<Z轴上离眼睛的距离
|
||||
|
||||
Vector4f eye; ///<眼睛坐标
|
||||
Vector4f center; ///<视点坐标
|
||||
|
@ -97,23 +97,6 @@ namespace hgl
|
||||
0.0f, 0.0f, -1.0f, 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成一个透视矩阵
|
||||
* @param aspect_ratio 宽高比
|
||||
* @param field_of_view 视野
|
||||
*/
|
||||
inline Matrix4f perspective(float field_of_view,
|
||||
float aspect_ratio)
|
||||
{
|
||||
const float f = 1.0f / tan( hgl_ang2rad( 0.5f * field_of_view ) );
|
||||
|
||||
return Matrix4f(
|
||||
f / aspect_ratio, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, -f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, -1.0f, 0.0f,
|
||||
0.0f, 0.0f, -1.0f, 0.0f);
|
||||
}
|
||||
|
||||
inline Matrix4f translate(const Vector3f &v)
|
||||
{
|
||||
return Matrix4f::Translate(v);
|
||||
|
@ -19,7 +19,7 @@ namespace hgl
|
||||
Matrix4f result( side.x, side.y, side.z, 0.0f,
|
||||
nup.x, nup.y, nup.z, 0.0f,
|
||||
-forward.x, -forward.y, -forward.z/2.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.5f, 1.0f);
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
return result*translate(-eye.xyz());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user