used Vector3f instead Vector4f because noramlized(Vector3f) != normalized(Vector4f)

This commit is contained in:
hyzboy 2022-01-18 12:10:02 +08:00
parent 3594a88232
commit 1d81121d30
8 changed files with 32 additions and 34 deletions

2
CMCore

@ -1 +1 @@
Subproject commit cb9f4430091567f00b26d6064dd85ffcbcef0522
Subproject commit caaefe206bcea74aa1e4ed6f3fd7e8dec1b1ab45

@ -1 +1 @@
Subproject commit 729f752d7cd93593ec59b5adaa2f981571253dc2
Subproject commit 6b739c9105ba9767c4bcc14ee9cbf044b9537240

View File

@ -1,5 +1,5 @@
// Cubemap
// CubeÌùͼ²âÊÔ
// Cubemap
// Cube贴图测试
#include"VulkanAppFramework.h"
#include<hgl/filesystem/FileSystem.h>
@ -121,7 +121,7 @@ private:
envmap_mi=db->CreateMaterialInstance(envmap_material);
if(!envmap_mi)return(false);
{
{
MaterialParameters *mp_texture=envmap_mi->GetMP(DescriptorSetsType::Value);
if(!mp_texture)
@ -200,7 +200,12 @@ public:
if(!CameraAppFramework::Init(SCREEN_WIDTH,SCREEN_HEIGHT))
return(false);
render_list=new RenderList(device);
camera->pos=Vector3f(10,10,0);
camera->target=Vector3f(0,0,0);
camera->Refresh(); //更新矩阵计算
render_list=new RenderList(device);
if(!InitMaterial())
return(false);

View File

@ -44,17 +44,6 @@ private:
if(!pipeline)
return(false);
{
MaterialParameters *mp_global=material_instance->GetMP(DescriptorSetsType::Global);
if(!mp_global)
return(false);
if(!mp_global->BindUBO("g_camera",GetCameraInfoBuffer()))return(false);
mp_global->Update();
}
return(true);
}
@ -98,7 +87,6 @@ private:
pgci.side_color.Set(0,0,1,1);
ro_plane_grid[2]=CreateRenderablePlaneGrid(db,vab,&pgci);
camera->pos=Vector4f(200,200,200,1.0);
}
bool InitScene()
@ -107,6 +95,9 @@ private:
Add(ro_plane_grid[1],rotate(HGL_RAD_90,0,1,0));
Add(ro_plane_grid[2],rotate(HGL_RAD_90,1,0,0));
camera->pos=Vector3f(200,200,200);
camera->Refresh();
render_root.RefreshMatrix();
render_list->Expend(camera->info,&render_root);
@ -140,6 +131,9 @@ public:
void BuildCommandBuffer(uint32 index)
{
render_root.RefreshMatrix();
render_list->Expend(GetCameraInfo(),&render_root);
VulkanApplicationFramework::BuildCommandBuffer(index,render_list);
}

View File

@ -333,7 +333,6 @@ public:
{
camera=new WalkerCamera;
camera->type=CameraType::Perspective;
camera->width=w;
camera->height=h;
camera->vp_width=w;
@ -396,12 +395,12 @@ public:
SubmitDraw(index);
if(isPush(KeyboardButton::W ))camera->Up (move_speed);else
if(isPush(KeyboardButton::S ))camera->Down (move_speed);else
if(isPush(KeyboardButton::W ))camera->Forward (move_speed);else
if(isPush(KeyboardButton::S ))camera->Backward (move_speed);else
if(isPush(KeyboardButton::A ))camera->Left (move_speed);else
if(isPush(KeyboardButton::D ))camera->Right (move_speed);else
if(isPush(KeyboardButton::R ))camera->Forward (move_speed);else
if(isPush(KeyboardButton::F ))camera->Backward (move_speed);else
if(isPush(KeyboardButton::R ))camera->Up (move_speed);else
if(isPush(KeyboardButton::F ))camera->Down (move_speed);else
if(isPush(KeyboardButton::Left ))camera->HoriRotate( move_speed);else
if(isPush(KeyboardButton::Right ))camera->HoriRotate(-move_speed);else

View File

@ -14,7 +14,7 @@ namespace hgl
{
MVPMatrix matrix;
Vector4f WorldCenter;
Vector3f WorldCenter;
float distance_to_camera_square;
// float distance_to_camera;

View File

@ -12,21 +12,21 @@ namespace hgl
*/
struct MVPMatrix
{
Matrix4f l2w; ///< Local to World
//Matrix4f normal; ///<transpose(inverse(mat3(l2w)));
Matrix4f model; ///< model: Local to World
//Matrix4f normal; ///<transpose(inverse(mat3(model)));
Matrix3x4f normal; ///<这里用3x4在Shader中是3x3(但实际它是3x4保存)
Matrix4f mv; ///< view * local_to_world
Matrix4f mvp; ///< projection * view * local_to_world
Matrix4f mv; ///< view * model
Matrix4f mvp; ///< projection * view * model
public:
void Set(const Matrix4f &w,const Matrix4f &vp,const Matrix4f &v)
void Set(const Matrix4f &local_to_world,const Matrix4f &view_projection,const Matrix4f &view)
{
l2w=w;
normal=transpose(inverse(l2w));
mv=v*l2w;
mvp=vp*l2w;
model =local_to_world;
normal =transpose(inverse(model));
mv =view*model;
mvp =view_projection*model;
}
CompOperatorMemcmp(const MVPMatrix &);

2
res

@ -1 +1 @@
Subproject commit 635a89acbd2e6c65bf67109aa049aaf209a39418
Subproject commit d7c22490949ff4b2f27aa3fd90d23e5c82639d1e