2D rendering (big feature)
This commit is contained in:
parent
6d7ea4ebc5
commit
5a05b9d65e
21 changed files with 1075 additions and 22 deletions
36
resources/EngineResources/SpriteShaders/sprite_vertex.glsl
Normal file
36
resources/EngineResources/SpriteShaders/sprite_vertex.glsl
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#version 450
|
||||
|
||||
layout(location = 0) in vec2 inPos;
|
||||
layout(location = 1) in vec2 inUV;
|
||||
|
||||
layout(location = 0) out vec2 outUV;
|
||||
|
||||
|
||||
layout(push_constant) uniform pc {
|
||||
vec2 modelSize;
|
||||
vec2 position;
|
||||
vec2 screenSize;
|
||||
|
||||
} push_constants;
|
||||
|
||||
layout(set = 0, binding = 0) uniform ViewUniform{
|
||||
vec2 camPos;
|
||||
vec2 camScale;
|
||||
} viewUniform;
|
||||
|
||||
|
||||
void main() {
|
||||
vec2 ScaledPos = inPos * push_constants.modelSize;
|
||||
vec2 worldPos = push_constants.position + ScaledPos;
|
||||
worldPos += viewUniform.camPos;
|
||||
vec2 ndc = vec2(
|
||||
(worldPos.x / push_constants.screenSize.x) * 2.0 - 1.0,
|
||||
(worldPos.y / push_constants.screenSize.y) * 2.0 - 1.0
|
||||
);
|
||||
|
||||
ndc.y = -ndc.y;
|
||||
|
||||
|
||||
gl_Position = vec4(ndc * viewUniform.camScale, 0.0, 1.0);
|
||||
outUV = vec2(inUV.x, 1 - inUV.y);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue