move framebuffer shader into its own file
This commit is contained in:
@@ -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;
|
||||||
|
33
rendering_api/metal/src/core/framebuffer.metal
Normal file
33
rendering_api/metal/src/core/framebuffer.metal
Normal 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);
|
||||||
|
}
|
@@ -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);
|
|
||||||
}
|
|
Reference in New Issue
Block a user