// // CRT-Pi Vertex Shader - Metal Shading Language // Portado desde GLSL a MSL para macOS // #include using namespace metal; // Estructura de entrada del vertex shader (desde el buffer de vértices) struct VertexIn { float2 position [[attribute(0)]]; // Posición del vértice float2 texCoord [[attribute(1)]]; // Coordenadas de textura }; // Estructura de salida del vertex shader (entrada al fragment shader) struct VertexOut { float4 position [[position]]; // Posición en clip space float2 texCoord; // Coordenadas de textura float filterWidth; // Ancho del filtro calculado // float2 screenScale; // Solo si CURVATURE está activo }; // Uniforms (constantes del shader) struct Uniforms { float2 textureSize; // Tamaño de la textura (width, height) }; // Entry point del vertex shader vertex VertexOut vertex_main(VertexIn in [[stage_in]], constant Uniforms& uniforms [[buffer(1)]]) { VertexOut out; // Posición del vértice (ya está en espacio de clip [-1, 1]) out.position = float4(in.position, 0.0, 1.0); // Pasar coordenadas de textura (invertir Y para SDL, igual que en GLSL) out.texCoord = float2(in.texCoord.x, 1.0 - in.texCoord.y) * 1.0001; // Calcular filterWidth dinámicamente basándose en la altura de la textura out.filterWidth = (768.0 / uniforms.textureSize.y) / 3.0; // Si CURVATURE estuviera activo: // out.screenScale = float2(1.0, 1.0); return out; }