Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

Optimizing and Sharing Shader Structures

layout(push_constant) uniform PushConstant {
    vec4 viewport;
    vec4 options;
    vec4 transform_ops;
    vec4 ao_options;
    vec4 ao_options2;
    vec4 proj_info;
    mat4 cameraProj;
    mat4 invProj;
};
#version 430

out vec4 finalColor;

layout(binding = 0) buffer block {
    vec3 position;
    vec3 color;
} light;

void main() {
    const vec3 dummy = vec3(1) - light.position;
    finalColor = vec4(vec3(1.0, 1.0, 1.0) * light.color, 1.0);
}
struct Light {
    glm::vec3 position;
    glm::vec3 color;
} light;

light.position = {1, 5, 0};
light.color = {3, 2, -1};
Position = (1.000000, 5.000000, 0.000000)
Color = (2.000000, -1.000000, 0.000000)
struct Light {
    glm::vec4 position;
    glm::vec4 color;
};
Position = (1.000000, 5.000000, 0.000000)
Color = (3.000000, 2.000000, -1.000000)
struct Light {
    glm::vec3 color;
    alignas(16) glm::vec3 position;
};
struct TestBuffer {
    bool a = false;
    bool b = true;
    bool c = false;
    bool d = true;
};
layout(binding = 0) buffer readonly TestBuffer {
    bool a, b, c, d;
};
a = 1, b = 0, c = 0, d = 0
layout(binding = 0) buffer readonly TestBuffer {
    int a, b, c, d;
};
primary PostPushConstant {
    viewport: vec4
    camera_proj: mat4
    inv_proj: mat4
    inv_view: mat4

    enable_aa: bool
    enable_dof: bool

    exposure: float
    display_color_space: int
    tonemapping: int

    ao_radius: float
    ao_r2: float
    ao_rneginvr2: float
    ao_rdotvbias: float
    ao_intensity: float
    ao_bias: float
}
struct PostPushConstant {
    glm::mat4 camera_proj;
    glm::mat4 inv_proj;
    glm::mat4 inv_view;
    glm::vec4 viewport;
    glm::ivec4 enable_aa_enable_dof_display_color_space_tonemapping_;
    glm::vec4 exposure_ao_radius_ao_r2_ao_rneginvr2_;
    glm::vec4 ao_rdotvbias_ao_intensity_ao_bias_;
    ...
};
#use_struct(push_constant, post, post_push_constant)
vec3 ao_result = pow(ao, ao_intensity())

About KDAB