Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
prism/engine/shaders/scenecapture.vert.nocompile.glsl

55 lines
1.5 KiB
Text
Raw Normal View History

2021-05-09 20:04:41 -04:00
layout (location = 0) in vec3 inPosition;
layout (location = 1) in vec3 inNormal;
layout (location = 2) in vec2 inUV;
layout (location = 0) out vec3 outFragPos;
layout (location = 1) out vec3 outNormal;
layout (location = 2) out vec2 outUV;
layout (location = 3) out flat int outMaterialId;
layout (location = 4) out vec4 fragPosLightSpace;
layout (location = 5) out vec4 fragPostSpotLightSpace[max_spot_lights];
struct Material {
vec4 color, info;
};
struct Light {
vec4 positionType;
vec4 directionPower;
vec4 color;
};
layout(std430, binding = 5) buffer readonly SceneInformation {
vec4 camPos;
mat4 projection, lightSpace;
vec4 skyColor;
mat4 spotLightSpaces[MAX_SPOT_LIGHTS];
Material materials[MAX_MATERIALS];
Light lights[MAX_LIGHTS];
2021-05-09 20:04:41 -04:00
int numLights;
} scene;
layout(push_constant) uniform readonly PushConstant{
2021-05-09 20:04:41 -04:00
mat4 model, view;
int materialOffset;
};
const mat4 biasMat = mat4(
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.5, 0.5, 0.0, 1.0);
void main() {
gl_Position = scene.projection * view * model * vec4(inPosition, 1.0);
outFragPos = vec3(model * vec4(inPosition, 1.0));
outNormal = mat3(model) * inNormal;
outUV = inUV;
outMaterialId = materialOffset;
fragPosLightSpace = (biasMat * scene.lightSpace * model) * vec4(inPosition, 1.0);
for(int i = 0; i < max_spot_lights; i++) {
fragPostSpotLightSpace[i] = (biasMat * scene.spotLightSpaces[i] * model) * vec4(inPosition, 1.0);
}
}