I hereby claim:
- I am piratkopia13 on github.
- I am pirat (https://keybase.io/pirat) on keybase.
- I have a public key ASAomGaNuPm0Rwmr3DVQ2XwLj9o1AEP-oCv3EyJAyr-Hmwo
To claim this, I am signing this object:
// Temporal filtering via an exponential moving average | |
float alpha = 0.3f; // Temporal fade, trading temporal stability for lag | |
// Reproject screenTexCoord to where it was last frame | |
float2 motionVector = gbuffer_motionVectors.SampleLevel(ss, screenTexCoord, 0); | |
motionVector.y = 1.f - motionVector.y; | |
motionVector = motionVector * 2.f - 1.0f; | |
float2 reprojectedTexCoord = screenTexCoord - motionVector; | |
// Sample the shadow texture from last frame |
PSIn VSMain(VSIn input) { | |
PSIn output; | |
output.clipPos = mul(mWVPCurrentFrame, input.position);; | |
output.clipPosLastFrame = mul(mWVPLastFrame, input.position); | |
return output; | |
} | |
GBuffers PSMain(PSIn input) { | |
GBuffers gbuffers; | |
float2 position = input.clipPos.xy / input.clipPos.w * 0.5f + 0.5f; | |
float2 positionLastFrame = input.clipPosLastFrame.xy / input.clipPosLastFrame.w * 0.5f + 0.5f; |
// Returns a random direction vector inside a cone | |
// Angle defined in radians | |
// Example: direction=(0,1,0) and angle=pi returns ([-1,1],[0,1],[-1,1]) | |
float3 getConeSample(inout uint randSeed, float3 direction, float coneAngle) { | |
float cosAngle = cos(coneAngle); | |
// Generate points on the spherical cap around the north pole [1]. | |
// [1] See https://math.stackexchange.com/a/205589/81266 | |
float z = nextRand(randSeed) * (1.0f - cosAngle) + cosAngle; | |
float phi = nextRand(randSeed) * 2.0f * PI; |
// Calculates the angle of a cone that starts at position worldPosition and perfectly | |
// encapsulates a sphere at position light.position with radius light.radius | |
float3 toLight = normalize(light.position - worldPosition); | |
// Calculate a vector perpendicular to L | |
float3 perpL = cross(toLight, float3(0.f, 1.0f, 0.f)); | |
// Handle case where L = up -> perpL should then be (1,0,0) | |
if (all(perpL == 0.0f)) { | |
perpL.x = 1.0; | |
} |
// Barycentric interpolation | |
float2 barrypolation(float3 barry, float2 in1, float2 in2, float2 in3) { | |
return barry.x * in1 + barry.y * in2 + barry.z * in3; | |
} | |
float3 barrypolation(float3 barry, float3 in1, float3 in2, float3 in3) { | |
return barry.x * in1 + barry.y * in2 + barry.z * in3; | |
} | |
// Generates a seed for a random number generator from 2 inputs plus a backoff | |
uint initRand(uint val0, uint val1, uint backoff = 16) { |
I hereby claim:
To claim this, I am signing this object: