废除WorldMatrix中的vp_size

This commit is contained in:
hyzboy 2019-07-17 12:01:20 +08:00
parent 8abe9c3d9d
commit e38d02f6e0
13 changed files with 19 additions and 45 deletions

View File

@ -12,12 +12,15 @@ constexpr uint32_t SCREEN_HEIGHT=128;
constexpr uint32_t VERTEX_COUNT=4;
constexpr float SSP=0.25;
constexpr float SSN=1-SSP;
constexpr float vertex_data[VERTEX_COUNT][2]=
{
{SCREEN_WIDTH*0, SCREEN_HEIGHT*0},
{SCREEN_WIDTH*1, SCREEN_HEIGHT*0},
{SCREEN_WIDTH*0, SCREEN_HEIGHT*1},
{SCREEN_WIDTH*1, SCREEN_HEIGHT*1}
{SCREEN_WIDTH*SSP, SCREEN_HEIGHT*SSP},
{SCREEN_WIDTH*SSN, SCREEN_HEIGHT*SSP},
{SCREEN_WIDTH*SSP, SCREEN_HEIGHT*SSN},
{SCREEN_WIDTH*SSN, SCREEN_HEIGHT*SSN}
};
constexpr uint32_t INDEX_COUNT=6;
@ -62,7 +65,7 @@ private:
bool InitMaterial()
{
material=shader_manage->CreateMaterial(OS_TEXT("res/shader/OnlyPosition.vert.spv"),
OS_TEXT("res/shader/glFragCoord.frag.spv"));
OS_TEXT("res/shader/FlatColor.frag.spv"));
if(!material)
return(false);
@ -75,9 +78,6 @@ private:
{
const VkExtent2D extent=sc_render_target->GetExtent();
wm.vp_size.x=extent.width;
wm.vp_size.y=extent.height;
wm.ortho=ortho(extent.width,extent.height);
ubo_mvp=device->CreateUBO(sizeof(WorldMatrix),&wm);

View File

@ -76,9 +76,6 @@ private:
{
const VkExtent2D extent=sc_render_target->GetExtent();
wm.vp_size.x=extent.width;
wm.vp_size.y=extent.height;
wm.ortho=ortho(extent.width,extent.height);
ubo_mvp=device->CreateUBO(sizeof(WorldMatrix),&wm);
@ -152,8 +149,6 @@ public:
void Resize(int w,int h)override
{
wm.vp_size.x=w;
wm.vp_size.y=h;
wm.ortho=ortho(w,h);
ubo_mvp->Write(&wm);

View File

@ -13,8 +13,6 @@ namespace hgl
struct WorldMatrix
{
alignas(8) Vector2f vp_size; //viewport尺寸
alignas(16) Matrix4f ortho; //2D正角视图矩阵
alignas(16) Matrix4f projection;

View File

@ -5,7 +5,6 @@ layout(location = 1) in vec3 Color;
layout(binding = 0) uniform WorldMatrix
{
vec2 vp_size;
mat4 ortho;
mat4 projection;
mat4 modelview;

View File

@ -6,11 +6,11 @@ layout(location = 2) in vec3 Normal;
layout(binding = 0) uniform WorldMatrix
{
mat4 two_dim;
mat4 ortho;
mat4 projection;
mat4 modelview;
mat4 mvp;
mat3 normal;
vec4 view_pos;
} world;
layout(push_constant) uniform Consts {

View File

@ -3,9 +3,13 @@
layout(location = 0) in vec2 Vertex;
layout(location = 1) in vec2 TexCoord;
layout(binding = 0) uniform WorldConfig
layout(binding = 0) uniform WorldMatrix
{
mat4 ortho;
mat4 projection;
mat4 modelview;
mat4 mvp;
vec4 view_pos;
} world;
layout(location = 0) out vec2 FragmentTexCoord;

View File

@ -4,7 +4,6 @@ layout(location = 0) in vec2 Vertex;
layout(binding = 0) uniform WorldMatrix
{
vec2 vp_size;
mat4 ortho;
mat4 projection;
mat4 modelview;

View File

@ -4,7 +4,7 @@ layout(location = 0) in vec3 Vertex;
layout(binding = 0) uniform WorldMatrix
{
mat4 two_dim;
mat4 ortho;
mat4 projection;
mat4 modelview;
mat4 mvp;

View File

@ -5,7 +5,6 @@ layout(location = 1) in vec4 Color;
layout(binding = 0) uniform WorldMatrix
{
vec2 vp_size;
mat4 ortho;
mat4 projection;
mat4 modelview;

View File

@ -7,7 +7,7 @@ layout(location = 3) in vec3 Tangent;
layout(binding = 0) uniform WorldMatrix
{
mat4 two_dim;
mat4 ortho;
mat4 projection;
mat4 modelview;
mat4 mvp;

View File

@ -1,18 +0,0 @@
#version 450
layout(binding = 0) uniform WorldMatrix
{
vec2 vp_size;
mat4 ortho;
mat4 projection;
mat4 modelview;
mat4 mvp;
vec4 view_pos;
} world;
layout (location = 0) out vec4 outFragcolor;
void main()
{
outFragcolor = vec4(gl_FragCoord.rg/world.vp_size,0.0,1.0);
}

View File

@ -18,4 +18,5 @@ glslangValidator -V -o Atomsphere.frag.spv Atomsphere.frag
glslangValidator -V -o gbuffer_opaque.vert.spv gbuffer_opaque.vert
glslangValidator -V -o gbuffer_opaque.frag.spv gbuffer_opaque.frag
glslangValidator -V -o glFragCoord.frag.spv glFragCoord.frag
glslangValidator -V -o gbuffer_composition.vert.spv gbuffer_composition.vert
glslangValidator -V -o gbuffer_composition.frag.spv gbuffer_composition.frag

View File

@ -28,9 +28,6 @@ namespace hgl
void Camera::Refresh()
{
matrix.vp_size.x=width;
matrix.vp_size.y=height;
if(type==CameraType::Perspective)
matrix.projection=perspective(fov,width/height,znear,zfar);
else