コード例 #1
0
 public abstract void Render(MatCapSnapshot matCapSnapshot, LightingRig lightingRig, CameraRuntimeRef cameraRef);
コード例 #2
0
 private Vector3 GetRayDirection(float width, float col, float height, float row, CameraRuntimeRef cameraRef)
 {
     return(new Vector3(col / width - 0.5f, row / height - 0.5f, _distanceToSphere).normalized);
 }
コード例 #3
0
 public override void Render(MatCapSnapshot matCapSnapshot, LightingRig lightingRig, CameraRuntimeRef cameraRef)
 {
     // #TODO Implement compute shader version
 }
コード例 #4
0
        // TODO: implement split texture rendering for Diffuse, Alpha & Specular (now supported only Combined)
        // TODO: implement viriable view position (now supported only along Z axis)
        public override void Render(MatCapSnapshot matCapSnapshot, LightingRig lightingRig, CameraRuntimeRef cameraRef)
        {
            Texture2D combined = matCapSnapshot.Combined;

            Color[] pixels = combined.GetPixels();

            // Min distance to  sphere caluclated according to texel size
            float epsilon = GetEpsilon(combined.width, combined.height);

            // Pixels layed out left to right, bottom to top
            for (int row = combined.height - 1; row >= 0; row--)
            {
                for (int col = 0; col < combined.width; col++)
                {
                    var rayData = new RayData();
                    rayData.RayDirection = GetRayDirection(combined.width, col, combined.height, row, cameraRef);
                    rayData.LightingRig  = lightingRig;
                    rayData.EyePosition  = new Vector3(0, 0, -_distanceToSphere);
                    rayData.Epsilon      = epsilon;

                    // TODO: use new Unity data oriented desing with ECS and Burst
                    // This task could be parallelized
                    int index = row * combined.width + col;
                    pixels[index] = RenderRay(rayData);
                }
            }

            combined.SetPixels(pixels);
            combined.Apply();
        }