-
Notifications
You must be signed in to change notification settings - Fork 1
Shader layout
Mathis Lamidey edited this page Jan 13, 2022
·
7 revisions
There are only 4 sets available in MRG shaders. Only 3 of these sets are currently used and 2 are user editable.
- Set 0 is defined by the engine for per-frame data and only contains Time data for now. It can be omitted if unused, and looks like this:
layout(set = 0, binding = 0) uniform TimeData {
vec4 timeScales;
} u_TimeData;
(variable and struct names can change).
- Set 1 is used for per-scene data, and contains the following information as of now:
layout(set = 1, binding = 0) uniform SceneLights {
DirectionalLight directional;
PointLight pointLights[MC_POINT_LIGHT_COUNT];
uint pointLightCount;
} u_SceneLights;
(The DirectionalLight
and PointLight
structs are defined in ../definitions.glsl
).
- Set 2 is completely up to user, and contains per-material data. Use the Material API (
Material::uploadUniform
,Material::BindTexture
, ...) to use these slots. - Set 3 is used for per-object data, and can be customized as well, but is has to have the following definition in slot 0:
layout(set = 3, location = 0) uniform ModelData {
mat4 modelMatrix;
} u_ModelData;
The rest of the slots for this set can be user defined, and should be used with the RenderObject API (RenderObject::uploadUniform
, RenderObject::BindTexture
, ...)
The push constants are reserved for camera data, like so:
layout(push_constant) uniform CameraData {
mat4 viewProjectionMatrix;
vec4 worldPos;
} pc_CameraData;