Beispiel #1
0
        public unsafe void Execute(int index)
        {
            RayDDAContext   rayContext     = inRays[index];
            SegmentContext *segmentContext = rayContext.segment;

            // TODO change the DDA ray setup so that we can do an intersection test with the world to find the first position instead of stepping to it
            RayContinuation cont = new RayContinuation
            {
                segment       = rayContext.segment,
                ddaRay        = rayContext.ddaRay,
                planeRayIndex = rayContext.planeRayIndex,
                rayColumn     = segmentContext->activeRayBufferFull.GetRayColumn(rayContext.planeRayIndex + segmentContext->segmentRayIndexOffset),
                lod           = 0,
            };

            World *world   = drawContext.worldLODs;
            float  farClip = drawContext.camera.FarClip;
            float  lodMax  = drawContext.camera.LODDistances[0];

            if (!World.REPEAT_WORLD)
            {
                // with a non-repeating world, we want to start inside the first grid position that is inside of the world
                // this means we can simply stop the ray later on if it runs outside of the world
                // (plus we know there's possible a lot of air out there)
                int2 dimensions = world->Dimensions.xz;
                int2 startPos   = cont.ddaRay.Position;
                if (any(startPos < 0 | startPos >= dimensions))
                {
                    // so the start is outside of the limited world
                    if (cont.ddaRay.StepToWorldIntersection(dimensions))
                    {
                        while (cont.ddaRay.IntersectionDistances.x >= lodMax)
                        {
                            cont.ddaRay.NextLOD(1 << cont.lod);
                            cont.lod++;
                            world++;
                            lodMax = drawContext.camera.LODDistances[cont.lod];
                        }

                        if (cont.ddaRay.IsBeyondFarClip(farClip))
                        {
                            WriteSkyboxFull(segmentContext->originalNextFreePixelMin, segmentContext->originalNextFreePixelMax, cont.rayColumn);
                        }
                        else
                        {
                            outRays.AddNoResize(cont);
                        }
                    }
                    else
                    {
                        WriteSkyboxFull(segmentContext->originalNextFreePixelMin, segmentContext->originalNextFreePixelMax, cont.rayColumn);
                    }
                    return;
                }
            }

            outRays.AddNoResize(cont);
        }
Beispiel #2
0
        public unsafe void Execute(int i)
        {
            float  endRayLerp = raysInput[i].planeRayIndex / (float)raysInput[i].context->segment.RayCount;
            float2 camLocalPlaneRayDirection = lerp(
                raysInput[i].context->segment.CamLocalPlaneRayMin,
                raysInput[i].context->segment.CamLocalPlaneRayMax,
                endRayLerp
                );
            SegmentDDAData ray = new SegmentDDAData(
                drawContext.camera.PositionXZ,
                normalize(camLocalPlaneRayDirection)
                );

            raysOutput[i] = new RayDDAContext
            {
                segment       = raysInput[i].context,
                planeRayIndex = raysInput[i].planeRayIndex,
                ddaRay        = ray
            };
        }