This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float3 REC709toREC2020(float3 RGB709) | |
{ | |
static const float3x3 ConvMat = | |
{ | |
0.627402, 0.329292, 0.043306, | |
0.069095, 0.919544, 0.011360, | |
0.016394, 0.088028, 0.895578 | |
}; | |
return mul(ConvMat, RGB709); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float3 RemoveSRGBCurve(float3 x) | |
{ | |
// Approximately pow(x, 2.2) | |
return x < 0.04045 ? x / 12.92 : pow((x + 0.055) / 1.055, 2.4); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float3 ApplyREC2084Curve(float3 L, float maxLuminance) | |
{ | |
float m1 = 2610.0 / 4096.0 / 4; | |
float m2 = 2523.0 / 4096.0 * 128; | |
float c1 = 3424.0 / 4096.0; | |
float c2 = 2413.0 / 4096.0 * 32; | |
float c3 = 2392.0 / 4096.0 * 32; | |
// L = FD / 10000, so if FD == 10000, then L = 1. | |
// so to scale max luminance, we want to multiply by maxLuminance / 10000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Texture2D<float4> originalTex : register(t1); | |
RWTexture2D<float4> outHdrTex : register(u0); | |
float3 ApplyREC2084Curve(float3 L, float maxLuminance) | |
{ | |
float m1 = 2610.0 / 4096.0 / 4; | |
float m2 = 2523.0 / 4096.0 * 128; | |
float c1 = 3424.0 / 4096.0; | |
float c2 = 2413.0 / 4096.0 * 32; | |
float c3 = 2392.0 / 4096.0 * 32; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matrix4x4 mat; | |
mat = Matrix4x4.Translate(new Vector3(centerPoint.x, centerPoint.y)); | |
mat *= Matrix4x4.Rotate(Quaternion.AngleAxis(degrees, Vector3.forward)); | |
mat *= Matrix4x4.Translate(new Vector3(-centerPoint.x, -centerPoint.y)); | |
Basis basis; | |
basis.right = new Vector2(mat.m00, mat.m01 ); | |
basis.up = new Vector2(mat.m10 , mat.m11); | |
basis.offset = new Vector2(mat.m03, mat.m13); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matrix4x4 mat; | |
mat = Matrix4x4.Translate(new Vector3(centerPoint.x, centerPoint.y)); | |
mat *= Matrix4x4.Rotate(Quaternion.AngleAxis(degrees, Vector3.forward)); | |
mat *= Matrix4x4.Translate(new Vector3(-centerPoint.x, -centerPoint.y)); | |
IntegerBasis basis; | |
basis.right = new Vector2Int( Mathf.RoundToInt(mat.m00 * BIG_NUMBER), Mathf.RoundToInt(mat.m01 * BIG_NUMBER)); | |
basis.up = new Vector2Int( Mathf.RoundToInt(mat.m10 * BIG_NUMBER), Mathf.RoundToInt(mat.m11 * BIG_NUMBER)); | |
basis.offset = new Vector2Int( Mathf.RoundToInt(mat.m03 * BIG_NUMBER), Mathf.RoundToInt(mat.m13 * BIG_NUMBER)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint2 IntegerRotate(int2 right, int2 up, int2 offset, uint2 pos) | |
{ | |
static const int BIG_NUMBER_EXPONENT = 20; | |
uint2 rotatedPos; | |
rotatedPos.x = pos.x * right.x + pos.y * right.y; | |
rotatedPos.y = pos.x * up.x + pos.y * up.y; | |
rotatedPos += offset; | |
rotatedPos = rotatedPos >> BIG_NUMBER_EXPONENT; | |
return rotatedPos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[numthreads(64, 1, 1)] | |
void BallotExample(uint gtid : SV_GroupThreadID) | |
{ | |
// assuming GCN architecture with WAVE_SIZE == 64 | |
bool firstHalf = gtid < 32; | |
uint2 ballotResult = WaveActiveBallot(firstHalf); | |
// ballotResult == 0x0000 0000 FFFF FFFF in ALL threads. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if __NV__ | |
groupshared uint ldsBallot[32]; | |
uint CoolBallot(bool value, uint waveId, uint laneId) | |
{ | |
ldsBallot[waveId] = 0; | |
InterlockedOr(ldsBallot[waveId], value << laneId); | |
return ldsBallot[waveId]; | |
} | |
#else // AMD |