move framebuffer shader into its own file

This commit is contained in:
Greg Wells
2025-05-23 09:48:54 -04:00
parent 68eb59b6f6
commit 65d6e3013a
3 changed files with 33 additions and 52 deletions

View File

@@ -20,41 +20,6 @@
// outputDevice->outputDevice->instance = const_cast<gnInstance*>(&instance); // outputDevice->outputDevice->instance = const_cast<gnInstance*>(&instance);
// { // {
// const char* shaderSrc = R"metal(
// #include <metal_stdlib>
// using namespace metal;
// struct VertexOut {
// float4 position [[position]];
// float2 uv;
// };
// vertex VertexOut vs_main(uint vertexID [[vertex_id]]) {
// float2 positions[4] = {
// {-1.0, -1.0},
// { 1.0, -1.0},
// {-1.0, 1.0},
// { 1.0, 1.0}
// };
// float2 uvs[4] = {
// {0.0, 1.0},
// {1.0, 1.0},
// {0.0, 0.0},
// {1.0, 0.0}
// };
// VertexOut out;
// out.position = float4(positions[vertexID], 0.0, 1.0);
// out.uv = uvs[vertexID];
// return out;
// }
// fragment float4 fs_main(VertexOut in [[stage_in]],
// texture2d<float> colorTex [[texture(0)]],
// sampler samp [[sampler(0)]]) {
// return colorTex.sample(samp, in.uv);
// }
// )metal";
// NS::Error* error = nullptr; // NS::Error* error = nullptr;
// MTL::CompileOptions* options = nullptr; // MTL::CompileOptions* options = nullptr;

View File

@@ -0,0 +1,33 @@
#include <metal_stdlib>
using namespace metal;
struct VertexOut {
float4 position [[position]];
float2 uv;
};
vertex VertexOut vs_main(uint vertexID [[vertex_id]]) {
float2 positions[4] = {
{-1.0, -1.0},
{ 1.0, -1.0},
{-1.0, 1.0},
{ 1.0, 1.0}
};
float2 uvs[4] = {
{0.0, 1.0},
{1.0, 1.0},
{0.0, 0.0},
{1.0, 0.0}
};
VertexOut out;
out.position = float4(positions[vertexID], 0.0, 1.0);
out.uv = uvs[vertexID];
return out;
}
fragment float4 fs_main(VertexOut in [[stage_in]],
texture2d<float> colorTex [[texture(0)]],
sampler samp [[sampler(0)]]) {
return colorTex.sample(samp, in.uv);
}

View File

@@ -1,17 +0,0 @@
#include <metal_stdlib>
using namespace metal;
vertex float4
vertexShader(uint vertexID [[vertex_id]],
constant simd::float3* vertexPositions)
{
float4 vertexOutPositions = float4(vertexPositions[vertexID][0],
vertexPositions[vertexID][1],
vertexPositions[vertexID][2],
1.0f);
return vertexOutPositions;
}
fragment float4 fragmentShader(float4 vertexOutPositions [[stage_in]]) {
return float4(182.0f/255.0f, 240.0f/255.0f, 228.0f/255.0f, 1.0f);
}