public static Ray CreatePrime(int x, int y, Scene scene, int sample, float4x2 jitterMatrix) { // Determine X and Y var sensorX = (2f * (x + jitterMatrix[sample][0]) / scene.Width) - 1f; var sensorY = 1f - (2f * (y + jitterMatrix[sample][1]) / scene.Height); // Adjust for the aspect ratio var aspectRatio = (float)scene.Width / (float)scene.Height; sensorX *= aspectRatio; // Adjust for the FOV var fovAdjustment = Hlsl.Tan((scene.Camera.FOV * (MathF.PI / 180f)) / 2f); sensorX *= fovAdjustment; sensorY *= fovAdjustment; #pragma warning disable IDE0017 // Simplify object initialization var ray = new Ray(); ray.Origin = new Vector3(); ray.Direction = Hlsl.Normalize(new float3(sensorX, sensorY, -1.0f)); #pragma warning restore IDE0017 // Simplify object initialization return(ray); }
public void Execute() { float exp = Hlsl.Exp(dword * row_major[ThreadIds.X]); float log = Hlsl.Log(1 + exp); float s1 = this.cos * exp * this.sin * log; float t1 = -this.sin * exp * this.cos * log; float s2 = s1 + this.intensity + Hlsl.Tan(s1 * this.scale); float t2 = t1 + this.intensity + Hlsl.Tan(t1 * this.scale); float u2 = this.cos * s2 - this.sin * t2; float v2 = this.sin * s2 - this.cos * t2; row_major[ThreadIds.X] = log / dword + float2 + int2x2 + u2 + v2; }