Skip to content

Enhance shaders readability  #229

Description

@mateuszstompor

Convert

kernel void kernelBloomMerge(texture2d<float, access::read_write> inputTexture [[texture(kAttributeBloomMergeComputeShaderTextureOriginal)]],
                             texture2d<float> brightAreasTexture [[texture(kAttributeBloomMergeComputeShaderTextureBrightAreas)]],
                             constant float & time [[buffer(kAttributeBloomMergeComputeShaderBufferTime)]],
                             uint3 inposition [[thread_position_in_grid]],
                             uint3 threads [[threads_per_grid]]) {
...
}

into

// Vertex function
#define bCameraUniformsVertex buffer(kAttributeGBufferVertexShaderBufferCameraUniforms)
#define bModelUniformsVertex buffer(kAttributeGBufferVertexShaderBufferModelUniforms)
#define bMatrixPalettesVertex buffer(kAttributeGBufferVertexShaderBufferMatrixPalettes)
#define bIndexVertex buffer(kAttributeGBufferVertexShaderBufferObjectIndex)

// Fragment function
#define tAlbedoFragment texture(kAttributeGBufferFragmentShaderTextureAlbedo)
#define tRoughnessFragment texture(kAttributeGBufferFragmentShaderTextureRoughness)
#define tNormalsFragment texture(kAttributeGBufferFragmentShaderTextureNormals)
#define tMetallicFragment texture(kAttributeGBufferFragmentShaderTextureMetallic)

vertex RasterizerData vertexGBuffer(Vertex in [[stage_in]],
                                    constant CameraUniforms & cameraUniforms [[bCameraUniformsVertex]],
                                    constant ModelUniforms * modelUniforms [[bModelUniformsVertex]],
                                    constant simd_float4x4 * matrixPalettes [[bMatrixPalettesVertex]],
                                    constant int & index [[bIndexVertex]]) {
...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions