mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Push previous work
This commit is contained in:
@@ -54,16 +54,10 @@ StructuredBuffer<Light> lights;
|
||||
|
||||
struct PSInput {
|
||||
float4 Position : SV_Position;
|
||||
float3 Color : TEXCOORD0;
|
||||
float2 UV : TEXCOORD1;
|
||||
float3 Normal : TEXCOORD2;
|
||||
float3x3 TBN : TEXCOORD3;
|
||||
};
|
||||
|
||||
struct PSOutput {
|
||||
float4 oColor0 : SV_TARGET;
|
||||
float4 oNormal : SV_TARGET1;
|
||||
float4 oMaterial : SV_TARGET2;
|
||||
};
|
||||
|
||||
struct ModelPushConstant
|
||||
@@ -78,59 +72,5 @@ ModelPushConstant pushConstants;
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
PSOutput output;
|
||||
|
||||
Material inMaterial = material[pushConstants.materialIndex];
|
||||
// NORMAL
|
||||
// TODO use TBN matrix
|
||||
float3 normal = float3(0.5, 0.5, 1.0);
|
||||
if(inMaterial.hasNormal == 1)
|
||||
{
|
||||
// Sample from texture.
|
||||
}
|
||||
|
||||
normal = mul(input.TBN, normal);
|
||||
normal = input.Normal / 2.0f + 0.5f;
|
||||
output.oNormal = float4(normal, 1.0f);
|
||||
|
||||
// MATERIAL
|
||||
|
||||
// ALBEDO COLOR
|
||||
float4 albedoColor = float4(inMaterial.albedo.xyz, 1.0f);
|
||||
if(inMaterial.hasAlbedo == 1)
|
||||
{
|
||||
float4 albedoSample = textures[inMaterial.albedoTextureId].Sample(mySampler, input.UV);
|
||||
|
||||
// Alpha cutout?
|
||||
if(albedoSample.a < 0.001f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
albedoColor.xyz = albedoSample.xyz;
|
||||
}
|
||||
output.oColor0 = albedoColor;
|
||||
|
||||
// MATERIAL PROPERTIES
|
||||
float metalnessValue = inMaterial.metalnessValue;
|
||||
if(inMaterial.hasMetalness == 1)
|
||||
{
|
||||
// TODO: Sample from metal texture
|
||||
}
|
||||
|
||||
float aoValue = inMaterial.aoValue;
|
||||
if(inMaterial.hasAO == 1)
|
||||
{
|
||||
// TODO: Sample from AO texture
|
||||
}
|
||||
|
||||
float roughnessValue = inMaterial.roughnessValue;
|
||||
if(inMaterial.hasRoughness == 1)
|
||||
{
|
||||
// TODO: Sample from roughness texture
|
||||
}
|
||||
|
||||
float3 materialOuput = float3(inMaterial.metalnessValue, inMaterial.aoValue, inMaterial.roughnessValue);
|
||||
|
||||
output.oMaterial = float4(materialOuput, 1.0f);
|
||||
return output;
|
||||
}
|
||||
@@ -57,10 +57,6 @@ ModelPushConstant pushConstants;
|
||||
// Outputs
|
||||
struct VSOutput {
|
||||
float4 Position : SV_Position;
|
||||
float3 Color : TEXCOORD0;
|
||||
float2 UV : TEXCOORD1;
|
||||
float3 Normal : TEXCOORD2;
|
||||
float3x3 TBN : TEXCOORD3;
|
||||
};
|
||||
|
||||
// Main vertex shader
|
||||
@@ -69,7 +65,6 @@ VSOutput main(uint vertexIndex : SV_VertexID)
|
||||
VSOutput output;
|
||||
|
||||
Camera camData = camera[0];
|
||||
|
||||
ModelData modelData = model[pushConstants.modelIndex];
|
||||
|
||||
// Load vertex data from the buffer
|
||||
@@ -77,13 +72,6 @@ VSOutput main(uint vertexIndex : SV_VertexID)
|
||||
|
||||
// Output the position of each vertex
|
||||
output.Position = mul(camData.proj, mul(camData.view, mul(modelData.model, float4(v.position, 1.0f))));
|
||||
output.Color = normalize(float3(v.position.xyz));
|
||||
output.UV = float2(v.uv_x, v.uv_y);
|
||||
output.Normal = normalize(v.normal);
|
||||
|
||||
float3 T = normalize(mul((float3x3)modelData.model, normalize(v.tangent.xyz)));
|
||||
float3 B = normalize(mul((float3x3)modelData.model, normalize(v.bitangent.xyz)));
|
||||
float3 N = normalize(mul((float3x3)modelData.model, normalize(v.normal)).xyz);
|
||||
output.TBN = transpose(float3x3(T, B, N));
|
||||
return output;
|
||||
}
|
||||
Reference in New Issue
Block a user