Engine
Engine copied to clipboard
Enhance shaders readability
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]]) {
...
}