add NormalMatrix in PushConstants
This commit is contained in:
parent
1a75ab0101
commit
8e6f672505
@ -1 +1 @@
|
||||
Subproject commit a03628acf307e07d383d8ab41c2a9ca73a052fb3
|
||||
Subproject commit 74e1d564be1a9c2af21b3fc2e4ca319e23b6616a
|
2
CMCore
2
CMCore
@ -1 +1 @@
|
||||
Subproject commit cdc2805477fc91ccebb87d56e5e9b8d7bcb492e6
|
||||
Subproject commit f895b3c3b08a4cb7abd3b2b8ca49faa9c8512f5a
|
@ -16,6 +16,7 @@ use_mgl(${ULRE_3RDPTY_ROOT_PATH}/MathGeoLib)
|
||||
include(use_cm_module)
|
||||
use_cm_module(Core)
|
||||
use_cm_module(Platform)
|
||||
use_cm_module(AssetsManage)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
include_directories(${ULRE_3RDPTY_ROOT_PATH}/jsoncpp/include)
|
||||
@ -24,6 +25,7 @@ ENDIF()
|
||||
|
||||
SET(ULRE CMCore
|
||||
CMPlatform
|
||||
CMAssetsManage
|
||||
ULRE.Util
|
||||
ULRE.Shader
|
||||
ULRE.RenderDevice.Vulkan
|
||||
|
@ -11,20 +11,20 @@ namespace hgl
|
||||
* 世界矩阵数据
|
||||
* @see res/shader/UBO_WorldMatrix.glsl
|
||||
*/
|
||||
struct WorldMatrix
|
||||
struct alignas(4) WorldMatrix
|
||||
{
|
||||
alignas(16) Matrix4f ortho; //2D正角视图矩阵
|
||||
Matrix4f ortho; //2D正角视图矩阵
|
||||
|
||||
alignas(16) Matrix4f projection;
|
||||
alignas(16) Matrix4f inverse_projection;
|
||||
Matrix4f projection;
|
||||
Matrix4f inverse_projection;
|
||||
|
||||
alignas(16) Matrix4f modelview;
|
||||
alignas(16) Matrix4f inverse_modelview;
|
||||
Matrix4f modelview;
|
||||
Matrix4f inverse_modelview;
|
||||
|
||||
alignas(16) Matrix4f mvp;
|
||||
alignas(16) Matrix4f inverse_map;
|
||||
Matrix4f mvp;
|
||||
Matrix4f inverse_map;
|
||||
|
||||
alignas(16) Vector4f view_pos; ///<眼睛坐标
|
||||
Vector4f view_pos; ///<眼睛坐标
|
||||
};//struct WorldMatrix
|
||||
}//namespace graph
|
||||
}//namespace hgl
|
||||
|
@ -65,9 +65,10 @@ enum class ShaderStage
|
||||
Compute =VK_SHADER_STAGE_COMPUTE_BIT
|
||||
};//enum class ShaderStage
|
||||
|
||||
struct PushConstant
|
||||
struct alignas(4) PushConstant
|
||||
{
|
||||
Matrix4f local_to_world;
|
||||
Matrix3f normal;
|
||||
};
|
||||
|
||||
inline void copy(VkExtent3D &e3d,const VkExtent2D &e2d)
|
||||
|
@ -1,4 +1,4 @@
|
||||
layout(binding = 0) uniform WorldMatrix // hgl/math/Math.h
|
||||
layout(std430,binding = 0,row_major) uniform WorldMatrix // hgl/math/Math.h
|
||||
{
|
||||
mat4 ortho;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
layout(push_constant) uniform Consts {
|
||||
layout(std430,push_constant,row_major) uniform Consts {
|
||||
mat4 local_to_world;
|
||||
mat3 normal;
|
||||
} pc;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include<hgl/graph/shader/node/vertex_input.h>
|
||||
#include<hgl/graph/shader/node/vector.h>
|
||||
#include<hgl/graph/shader/node/combo_vector.h>
|
||||
#include<hgl/assets/AssetsSource.h>
|
||||
|
||||
BEGIN_SHADER_NAMESPACE
|
||||
namespace
|
||||
@ -16,6 +17,26 @@ namespace
|
||||
UTF8String PushConstant;
|
||||
|
||||
UTF8String VSOutputLayout;
|
||||
|
||||
bool Load()
|
||||
{
|
||||
assets::AssetsSource *as=assets::GetSource("shader");
|
||||
|
||||
if(!as)
|
||||
return(false);
|
||||
|
||||
#ifndef USE_MOBILE_SHADER
|
||||
Header =UTF8String(as->Open("header_desktop.glsl"));
|
||||
#else
|
||||
Header =UTF8String(as->Open("header_mobile.glsl"));
|
||||
#endif//
|
||||
|
||||
UBOWorldMatrix =UTF8String(as->Open("UBO_WorldMatrix.glsl"));
|
||||
PushConstant =UTF8String(as->Open("push_constant_3d.glsl"));
|
||||
VSOutputLayout =UTF8String(as->Open("vertex_shader_output_layout.glsl"));
|
||||
|
||||
return(true);
|
||||
}
|
||||
}//namespace InlineShader
|
||||
|
||||
constexpr enum class API DEFAULT_RENDER_API =API::Vulkan;
|
||||
@ -77,6 +98,9 @@ namespace
|
||||
|
||||
bool CreateDefaultMaterial()
|
||||
{
|
||||
if(!InlineShader::Load())
|
||||
return(false);
|
||||
|
||||
if(!CreateDefaultVertexShader())return(false);
|
||||
if(!CreateDefaultFragmentVertex())return(false);
|
||||
|
||||
|
@ -7,11 +7,13 @@ namespace hgl
|
||||
|
||||
SceneOrient::SceneOrient()
|
||||
{
|
||||
pc.local_to_world=
|
||||
LocalMatrix=
|
||||
LocalToWorldMatrix=
|
||||
InverseLocalMatrix=
|
||||
InverseLocalToWorldMatrix=identity();
|
||||
pc.local_to_world =Matrix4f::identity;
|
||||
LocalMatrix =Matrix4f::identity;
|
||||
LocalToWorldMatrix =Matrix4f::identity;
|
||||
InverseLocalMatrix =Matrix4f::identity;
|
||||
InverseLocalToWorldMatrix =Matrix4f::identity;
|
||||
|
||||
pc.normal =Matrix3f::identity;
|
||||
}
|
||||
|
||||
Matrix4f &SceneOrient::SetLocalMatrix(const Matrix4f &m)
|
||||
@ -29,7 +31,8 @@ namespace hgl
|
||||
|
||||
InverseLocalToWorldMatrix=inverse(LocalToWorldMatrix);
|
||||
|
||||
pc.local_to_world=LocalToWorldMatrix;
|
||||
pc.local_to_world =LocalToWorldMatrix;
|
||||
pc.normal =pc.local_to_world.Float3x3Part();
|
||||
|
||||
return LocalToWorldMatrix;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user