mirror of
https://github.com/antopilo/Nuake.git
synced 2026-09-21 20:08:40 +03:00
Added cast,receive shadows & unlit flags in the materials
This commit is contained in:
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -104,7 +107,7 @@ BlurConstant pushConstants;
|
||||
|
||||
float3 SampleTexture(int textureId, float2 uv)
|
||||
{
|
||||
return textures[textureId].Sample(mySampler[1], uv).rgb;
|
||||
return textures[textureId].Sample(mySampler[0], uv).rgb;
|
||||
}
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -109,8 +112,8 @@ PSOutput main(PSInput input)
|
||||
int source2TextureID = pushConstants.Source2TextureID;
|
||||
|
||||
float2 uv = input.UV;
|
||||
float4 sampleValue = textures[sourceTextureID].Sample(mySampler[1], input.UV);
|
||||
float4 sampleValue2 = textures[source2TextureID].Sample(mySampler[1], input.UV);
|
||||
float4 sampleValue = textures[sourceTextureID].Sample(mySampler[0], input.UV);
|
||||
float4 sampleValue2 = textures[source2TextureID].Sample(mySampler[0], input.UV);
|
||||
|
||||
if(pushConstants.Mode == 0)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -116,8 +119,8 @@ float PixelToUV(float2 uv, Texture2D tex)
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
int depthTexture = pushConstants.DepthTextureID;
|
||||
float upSampledDepth = textures[depthTexture].Sample(mySampler[1], input.UV).r;
|
||||
float3 upSampledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[1], input.UV).rgb;
|
||||
float upSampledDepth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
|
||||
float3 upSampledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[0], input.UV).rgb;
|
||||
float3 color = 0.0f.xxx;
|
||||
float totalWeight = 0.0f;
|
||||
|
||||
@@ -134,8 +137,8 @@ PSOutput main(PSInput input)
|
||||
{
|
||||
float2 uvOffset = float2(offsets[i].x * 4.0, offsets[i].y * 4.0) ;
|
||||
uvOffset = PixelToUV(uvOffset, textures[pushConstants.DepthTextureID]);
|
||||
float3 downscaledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[1], input.UV + uvOffset).rgb;
|
||||
float downscaledDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[1], input.UV + uvOffset).r;
|
||||
float3 downscaledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[0], input.UV + uvOffset).rgb;
|
||||
float downscaledDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], input.UV + uvOffset).r;
|
||||
|
||||
float currentWeight = 1.0f;
|
||||
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -115,7 +118,7 @@ PSOutput main(PSInput input)
|
||||
else
|
||||
{
|
||||
float2 uv = input.UV;
|
||||
float4 textureSample = textures[pushConstants.TextureID].Sample(mySampler[1], uv);
|
||||
float4 textureSample = textures[pushConstants.TextureID].Sample(mySampler[0], uv);
|
||||
|
||||
// Alpha scisorring
|
||||
if(textureSample.a < 0.1)
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -128,8 +131,8 @@ PSOutput main(PSInput input)
|
||||
int entityIDTextureID = pushConstants.EntityIDTextureID;
|
||||
float hasHit = 0.0f;
|
||||
|
||||
float sampleValue = textures[entityIDTextureID].Sample(mySampler[1], uv).r;
|
||||
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler[1], uv).r;
|
||||
float sampleValue = textures[entityIDTextureID].Sample(mySampler[0], uv).r;
|
||||
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], uv).r;
|
||||
|
||||
float4 fragColor = float4(0, 0, 0, 0);
|
||||
const float TAU = 6.28318530;
|
||||
@@ -142,8 +145,8 @@ PSOutput main(PSInput input)
|
||||
sampleUV.x = clamp(sampleUV.x, 0.0, 0.999);
|
||||
sampleUV.y = clamp(sampleUV.y, 0.0, 0.999);
|
||||
|
||||
float sample = textures[entityIDTextureID].Sample(mySampler[1], sampleUV).r;
|
||||
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[1], sampleUV).r;
|
||||
float sample = textures[entityIDTextureID].Sample(mySampler[0], sampleUV).r;
|
||||
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], sampleUV).r;
|
||||
|
||||
//sampleDepth = LinearizeDepth(sampleDepth, 0.1f, 200.0f);
|
||||
//depth = LinearizeDepth(depth, 0.1f, 200.0f);
|
||||
@@ -173,7 +176,7 @@ PSOutput main(PSInput input)
|
||||
fragColor.a = 1.0f;
|
||||
}
|
||||
|
||||
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler[1], uv).rgb;
|
||||
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler[0], uv).rgb;
|
||||
float ratio = float(sampleValue != target && hasHit > 0.0f);
|
||||
float4 finalColor = float4(
|
||||
lerp(sourceTexture.r, fragColor.r, ratio),
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
|
||||
[[vk::binding(0, 3)]]
|
||||
@@ -104,6 +107,7 @@ struct ShadingPushConstant
|
||||
float AmbientTerm;
|
||||
float cascadeDepth[4];
|
||||
int SSAOTextureId;
|
||||
int EntityTextureId;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
@@ -198,7 +202,7 @@ int GetCSMSplit(float depth)
|
||||
|
||||
float SampleShadowMap(int textureId, float2 coords, float compare)
|
||||
{
|
||||
return compare > textures[textureId].Sample(mySampler[1], coords.xy).r;
|
||||
return compare > textures[textureId].Sample(mySampler[0], coords.xy).r;
|
||||
}
|
||||
|
||||
float SampleShadowMapLinear(int textureId, float2 coords, float compare, float2 texelSize)
|
||||
@@ -260,7 +264,7 @@ float ShadowCalculation(Light light, float3 fragPos, float3 normal)
|
||||
return result /= NUM_SAMPLES_SQUARED;
|
||||
}
|
||||
|
||||
float shadowMapDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[1], projCoords.xy).r;
|
||||
float shadowMapDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[0], projCoords.xy).r;
|
||||
|
||||
return (currentDepth > shadowMapDepth);//> 0.0 ? 1.0 : 0.0;
|
||||
}
|
||||
@@ -270,24 +274,36 @@ PSOutput main(PSInput input)
|
||||
CameraView camView = cameras[pushConstants.CameraID];
|
||||
|
||||
int depthTexture = pushConstants.DepthInputTextureId;
|
||||
float depth = textures[depthTexture].Sample(mySampler[1], input.UV).r;
|
||||
float depth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
|
||||
|
||||
if(depth == 0.0f)
|
||||
{
|
||||
discard;
|
||||
}
|
||||
|
||||
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
|
||||
int albedoTextureId = pushConstants.AlbedoInputTextureId;
|
||||
float3 albedo = textures[albedoTextureId].Sample(mySampler[1], input.UV).xyz;
|
||||
float3 normal = textures[pushConstants.NormalInputTextureId].Sample(mySampler[1], input.UV).rgb;
|
||||
float3 albedo = textures[albedoTextureId].Sample(mySampler[0], input.UV).xyz;
|
||||
int materialId = (int)textures[pushConstants.EntityTextureId].Sample(mySampler[0], input.UV).g;
|
||||
Material inMaterial = material[materialId];
|
||||
|
||||
if(inMaterial.unlit)
|
||||
{
|
||||
output.oColor0 = float4(albedo, 1);
|
||||
return output;
|
||||
}
|
||||
|
||||
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
|
||||
|
||||
float3 normal = textures[pushConstants.NormalInputTextureId].Sample(mySampler[0], input.UV).rgb;
|
||||
normal = normal * 2.0f - 1.0f;
|
||||
|
||||
float4 materialSample = textures[pushConstants.MaterialInputTextureId].Sample(mySampler[1], input.UV);
|
||||
float4 materialSample = textures[pushConstants.MaterialInputTextureId].Sample(mySampler[0], input.UV);
|
||||
float metallic = materialSample.r;
|
||||
float ao = materialSample.g;
|
||||
float roughness = materialSample.b;
|
||||
float ssao = textures[pushConstants.SSAOTextureId].Sample(mySampler[1], input.UV);
|
||||
float ssao = textures[pushConstants.SSAOTextureId].Sample(mySampler[0], input.UV).r;
|
||||
|
||||
|
||||
|
||||
float3 N = normal;
|
||||
float3 V = normalize(camView.Position - worldPos);
|
||||
@@ -347,6 +363,11 @@ PSOutput main(PSInput input)
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
|
||||
if(inMaterial.receiveShadow == 0)
|
||||
{
|
||||
shadow = 1.0f;
|
||||
}
|
||||
Lo += (kD * albedo / PI + specular) * radiance * NdotL * shadow;
|
||||
}
|
||||
|
||||
@@ -393,7 +414,7 @@ PSOutput main(PSInput input)
|
||||
float3 kD = 1.0 - kS;
|
||||
kD *= 1.0 - metallic;
|
||||
|
||||
float3 ambient = (albedo) * ao * ssao * pushConstants.AmbientTerm;
|
||||
float3 ambient = (albedo) * ao * ssao * pushConstants.AmbientTerm;
|
||||
float3 color = (ambient) + Lo;
|
||||
|
||||
output.oColor0 = float4(color, 1);
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -93,6 +96,7 @@ struct ShadingPushConstant
|
||||
float AmbientTerm;
|
||||
float cascadeDepth[4];
|
||||
int SSAOTextureId;
|
||||
int EntityTextureId;
|
||||
};
|
||||
|
||||
[[vk::push_constant]]
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -132,12 +135,12 @@ float3 WorldPosFromDepth(float depth, float2 uv, CameraView camera)
|
||||
|
||||
float3 SampleTexture(int textureId, float2 uv)
|
||||
{
|
||||
return textures[textureId].Sample(mySampler[1], uv).rgb;
|
||||
return textures[textureId].Sample(mySampler[0], uv).rgb;
|
||||
}
|
||||
|
||||
float SampleDepth(float2 uv)
|
||||
{
|
||||
return textures[pushConstants.depthTextureID].Sample(mySampler[1], uv).r;
|
||||
return textures[pushConstants.depthTextureID].Sample(mySampler[0], uv).r;
|
||||
}
|
||||
|
||||
float3x3 Inverse3x3(float3x3 m)
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -123,7 +126,7 @@ float3 PBRNeutralToneMapping(float3 color)
|
||||
PSOutput main(PSInput input)
|
||||
{
|
||||
PSOutput output;
|
||||
float3 color = textures[pushConstants.SourceTextureID].Sample(mySampler[1], input.UV).rgb;
|
||||
float3 color = textures[pushConstants.SourceTextureID].Sample(mySampler[0], input.UV).rgb;
|
||||
float3 mapped = float3(1.0, 1.0, 1.0) - exp(-color * pushConstants.Exposure);
|
||||
|
||||
color = pow(mapped, float3(pushConstants.Gamma, pushConstants.Gamma, pushConstants.Gamma));
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -183,7 +186,7 @@ PSOutput main(PSInput input)
|
||||
|
||||
output.oMaterial = float4(materialOuput, 1.0f);
|
||||
|
||||
output.oEntityID = float4(pushConstants.entityID, 0.0f, 0.0f, 1.0f);
|
||||
output.oEntityID = float4(pushConstants.entityID, pushConstants.materialIndex, 0.0f, 1.0f);
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -228,7 +231,7 @@ int GetCSMSplit(float depth)
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
PSOutput main(PSInput input)
|
||||
@@ -242,7 +245,7 @@ PSOutput main(PSInput input)
|
||||
float3 startPosition = camView.Position;
|
||||
|
||||
int depthTexture = pushConstants.DepthTextureID;
|
||||
float depth = textures[depthTexture].Sample(mySampler[1], input.UV).r;
|
||||
float depth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
|
||||
|
||||
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
|
||||
|
||||
@@ -275,7 +278,7 @@ PSOutput main(PSInput input)
|
||||
|
||||
if(splitIndex == -1)
|
||||
{
|
||||
accumFog += (ComputeScattering(dot(rayDirection, light.direction)).rrr * light.color.xyz) * pushConstants.Exponant;
|
||||
//accumFog += (ComputeScattering(dot(rayDirection, light.direction)).rrr * light.color.xyz) * pushConstants.Exponant;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -285,7 +288,7 @@ PSOutput main(PSInput input)
|
||||
projCoords.xy = projCoords.xy * 0.5 + 0.5;
|
||||
|
||||
float currentDepth = projCoords.z;
|
||||
float closestDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[1], projCoords.xy).r;
|
||||
float closestDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[0], projCoords.xy).r;
|
||||
|
||||
float3 noiseOffset = float3(pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time);
|
||||
float3 noiseSamplePos = (currentPosition + noiseOffset) * pushConstants.NoiseScale;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -122,8 +125,8 @@ PSOutput main(PSInput input)
|
||||
int entityIDTextureID = pushConstants.EntityIDTextureID;
|
||||
float hasHit = 0.0f;
|
||||
|
||||
float sampleValue = textures[entityIDTextureID].Sample(mySampler[1],, uv).r;
|
||||
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler[1], uv).r;
|
||||
float sampleValue = textures[entityIDTextureID].Sample(mySampler[0],, uv).r;
|
||||
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], uv).r;
|
||||
|
||||
float4 fragColor = float4(0, 0, 0, 0);
|
||||
const float TAU = 6.28318530;
|
||||
@@ -136,8 +139,8 @@ PSOutput main(PSInput input)
|
||||
sampleUV.x = clamp(sampleUV.x, 0.0, 0.999);
|
||||
sampleUV.y = clamp(sampleUV.y, 0.0, 0.999);
|
||||
|
||||
float sample = textures[entityIDTextureID].Sample(mySampler[1], sampleUV).r;
|
||||
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[1], sampleUV).r;
|
||||
float sample = textures[entityIDTextureID].Sample(mySampler[0], sampleUV).r;
|
||||
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], sampleUV).r;
|
||||
if(sample == target && sampleDepth != 1.0f && sampleDepth > depth)
|
||||
{
|
||||
hasHit = 1.0f;
|
||||
@@ -159,7 +162,7 @@ PSOutput main(PSInput input)
|
||||
fragColor.a = 1.0f;
|
||||
}
|
||||
|
||||
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler[1], uv).rgb;
|
||||
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler[0], uv).rgb;
|
||||
float ratio = float(sampleValue != target && hasHit > 0.0f);
|
||||
float4 finalColor = float4(
|
||||
lerp(sourceTexture.r, fragColor.r, ratio),
|
||||
|
||||
@@ -42,6 +42,9 @@ struct Material
|
||||
int roughnessTextureId;
|
||||
int aoTextureId;
|
||||
int samplingType;
|
||||
int receiveShadow;
|
||||
int castShadow;
|
||||
int unlit;
|
||||
};
|
||||
[[vk::binding(0, 3)]]
|
||||
StructuredBuffer<Material> material;
|
||||
@@ -228,7 +231,7 @@ PSOutput main(PSInput input)
|
||||
float3 startPosition = camView.Position;
|
||||
|
||||
int depthTexture = pushConstants.DepthTextureID;
|
||||
float depth = textures[depthTexture].Sample(mySampler[1], input.UV).r;
|
||||
float depth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
|
||||
|
||||
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
|
||||
|
||||
@@ -262,7 +265,7 @@ PSOutput main(PSInput input)
|
||||
projCoords.xy = projCoords.xy * 0.5 + 0.5;
|
||||
|
||||
float currentDepth = projCoords.z;
|
||||
float closestDepth = textures[light.shadowMapTextureId[0]].Sample(mySampler[1], projCoords.xy).r;
|
||||
float closestDepth = textures[light.shadowMapTextureId[0]].Sample(mySampler[0], projCoords.xy).r;
|
||||
|
||||
float3 noiseOffset = float3(pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time);
|
||||
float3 noiseSamplePos = (currentPosition + noiseOffset) * pushConstants.NoiseScale;
|
||||
|
||||
Reference in New Issue
Block a user