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/base/shaders/scenecapture.vert.nocompile.glsl
Joshua Goins ca2c2c9d3d Move all engine-specific models, materials etc. to a new base directory
This is a huge change, and basically breaks everything (as per usual!)

First of, this includes stuff like shaders so anything involving those
are broken and then fixed. A new BuildAssets cmake file is added to
aid in running AssetCompiler, and it seems to work fine on the engine
base assets.

The File API will eventually be revamped to handle this new way of
organizing the files and domains will eventually be gotten rid of all
together since I probably will replace it with game directory
priorities. As it stands right now, there isn't a way to easily
replace say - render_options.cfg with your own game-specific version.

Apple builds are probably broken by this commit (since I'm moving
around content and shader directories) to be fixed later.
2022-05-21 18:28:48 -04:00

58 lines
1.6 KiB
GLSL

layout (constant_id = 0) const int max_materials = 25;
layout (constant_id = 1) const int max_lights = 25;
layout (constant_id = 2) const int max_spot_lights = 4;
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];
int numLights;
} scene;
layout(push_constant) uniform readonly PushConstant{
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);
}
}