Skip to content

Instantly share code, notes, and snippets.

@nickludlam
Created February 12, 2023 19:16
Show Gist options
  • Save nickludlam/477fe527e4cfb0f4bd00245da235e6d8 to your computer and use it in GitHub Desktop.
Save nickludlam/477fe527e4cfb0f4bd00245da235e6d8 to your computer and use it in GitHub Desktop.
Function to sample a blue noise texture for use with each screen pixel
// Requires NDC from GetVertexPositionInputs() in the vert shader
float2 GetNoiseUV(float2 positionNDC) {
float2 blueTexSizeMultiplier = _BlueNoise_TexelSize.xy; // i.e. 1/32
float2 screenWidthHeight = _ScreenParams.xy + float2(0.5, 0.5); // i.e. 1920,1080 + half to center
return screenWidthHeight * blueTexSizeMultiplier * positionNDC;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment