added mesh rendering
This commit is contained in:
23
funnyassets/gfx_shaders/mesh_frag.slang
Normal file
23
funnyassets/gfx_shaders/mesh_frag.slang
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "mesh_shared.slang"
|
||||
|
||||
uint32_t hash32(uint32_t x) {
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = (x >> 16) ^ x;
|
||||
return x;
|
||||
}
|
||||
|
||||
[[vk::binding(1)]]
|
||||
uniform Sampler2D textures[];
|
||||
|
||||
|
||||
float4 main(
|
||||
VertexOutput input,
|
||||
uint triid: SV_PrimitiveID,
|
||||
uniform PushConstants constants,
|
||||
) : SV_TARGET
|
||||
{
|
||||
return float4(textures[constants.albedoID].Sample(input.uv).xyz, 1);
|
||||
|
||||
}
|
||||
|
||||
15
funnyassets/gfx_shaders/mesh_shared.slang
Normal file
15
funnyassets/gfx_shaders/mesh_shared.slang
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 position: SV_Position;
|
||||
float2 uv: TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PushConstants
|
||||
{
|
||||
float4x4 modelMatrix;
|
||||
uint albedoID;
|
||||
uint roughnessID;
|
||||
uint metalnessID;
|
||||
};
|
||||
24
funnyassets/gfx_shaders/mesh_vert.slang
Normal file
24
funnyassets/gfx_shaders/mesh_vert.slang
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "mesh_shared.slang"
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float3 position: POSITION;
|
||||
float2 uv: TEXCOORD0;
|
||||
};
|
||||
|
||||
[[vk::binding(0)]]
|
||||
cbuffer CameraInfo
|
||||
{
|
||||
float4x4 projection;
|
||||
};
|
||||
|
||||
VertexOutput main(
|
||||
VertexInput input,
|
||||
uniform PushConstants constants,
|
||||
)
|
||||
{
|
||||
VertexOutput output;
|
||||
output.position = mul(projection, mul(constants.modelMatrix, float4(input.position,1)));
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user