Exemplo n.º 1
0
 public void Load()
 {
     shader = new CoreShader();
     camera = new TopDownCamera();
     sb     = new SpriteBatch(camera);
     map    = new Map(48f, 48f);
     player = new Player();
     player.Spawn(map, map.SpawnPoint);
     pc = new PlayerController(camera, map, player);
 }
Exemplo n.º 2
0
    public void Dispatch()
    {
        if (HeightTexture == null || NormalTexture == null)
        {
            return;
        }

        generationConstants.lodLevel          = (((1 << LODLevel + 2) * (Planetoid.PlanetRadius / (LODLevel + 2)) - ((Planetoid.PlanetRadius / (LODLevel + 2)) / 2)) / Planetoid.PlanetRadius);
        generationConstants.lodOctaveModifier = Planetoid.GetLODOctaveModifier(LODLevel + 1);

        // NOTE : Just setup all our generator parameters...
        if (Planetoid.tccps != null)
        {
            Planetoid.tccps.UpdateUniforms(CoreShader);
        }

        CreateBuffers();

        QuadGenerationConstantsBuffer.SetData(new[] { generationConstants });
        PreOutDataBuffer.SetData(GodManager.Instance.PreOutputDataBuffer);
        PreOutDataSubBuffer.SetData(GodManager.Instance.PreOutputSubDataBuffer);
        OutDataBuffer.SetData(GodManager.Instance.OutputDataBuffer);

        if (CoreShader == null)
        {
            return;
        }

        EventManager.PlanetoidEvents.OnDispatchStarted.Invoke(Planetoid, this);

        // NOTE : I still need this stuff...
        int kernel1 = CoreShader.FindKernel("HeightMain");
        int kernel2 = CoreShader.FindKernel("Transfer");
        int kernel3 = CoreShader.FindKernel("HeightSub");
        int kernel4 = CoreShader.FindKernel("TexturesSub");

        SetUniforms(CoreShader);

        CoreShader.Dispatch(kernel1, QuadSettings.THREADGROUP_SIZE_BORDER, QuadSettings.THREADGROUP_SIZE_BORDER, 1);
        CoreShader.Dispatch(kernel2, QuadSettings.THREADGROUP_SIZE, QuadSettings.THREADGROUP_SIZE, 1);
        CoreShader.Dispatch(kernel3, QuadSettings.THREADGROUP_SIZE_BORDER_FULL, QuadSettings.THREADGROUP_SIZE_BORDER_FULL, 1);
        CoreShader.Dispatch(kernel4, QuadSettings.THREADGROUP_SIZE_FULL, QuadSettings.THREADGROUP_SIZE_FULL, 1);

        Generated = true;

        // NOTE : NO DATA WILL BE RECIEVED UNTIL ASYNC GET DATA!

        //Release and dispose unnecessary buffers. Video memory, you are free!
        BufferHelper.ReleaseAndDisposeBuffers(PreOutDataBuffer, PreOutDataSubBuffer);

        BuffersCreated = false;

        EventManager.PlanetoidEvents.OnDispatchEnd.Invoke(Planetoid, this);
        EventManager.PlanetoidEvents.OnDispatchFinished.Invoke(Planetoid, this);
    }
Exemplo n.º 3
0
    private void SetupComputeShaderKernelUniforfms(int kernel, ComputeBuffer quadGenerationConstantsBuffer, ComputeBuffer preOutDataBuffer, ComputeBuffer preOutDataSubBuffer, ComputeBuffer outDataBuffer)
    {
        if (CoreShader == null)
        {
            return;
        }

        CoreShader.SetBuffer(kernel, "quadGenerationConstants", quadGenerationConstantsBuffer);
        CoreShader.SetBuffer(kernel, "patchPreOutput", preOutDataBuffer);
        CoreShader.SetBuffer(kernel, "patchPreOutputSub", preOutDataSubBuffer);
        CoreShader.SetBuffer(kernel, "patchOutput", outDataBuffer);

        CoreShader.SetTexture(kernel, "Height", HeightTexture);
        CoreShader.SetTexture(kernel, "Normal", NormalTexture);

        if (Planetoid.NPS != null)
        {
            Planetoid.NPS.UpdateUniforms(QuadMaterial, CoreShader, kernel);
        }
    }