Ejemplo n.º 1
0
    public FieldCollection GenerateLerpField()
    {
        int lerpFieldHandler = lerpFieldGenerator.FindKernel("LerpField");

        lerpField_texture = CreateTexture();
        lerpFieldGenerator.SetTexture(lerpFieldHandler, "LerpField_Texture", lerpField_texture);

        LerpField XField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_X");
        LerpField YField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_Y");
        LerpField ZField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_Z");

        SetupShaderOffsets(lerpFieldGenerator);

        lerpFieldGenerator.Dispatch(lerpFieldHandler, volumeSize / 8, volumeSize / 8, volumeSize / 8);
        //lerpField_material.mainTexture = lerpField_texture;

        GetFieldDataFromComputeShader(XField);
        GetFieldDataFromComputeShader(YField);
        GetFieldDataFromComputeShader(ZField);

        FieldCollection collection = new FieldCollection();

        collection.X = XField;
        collection.Y = YField;
        collection.Z = ZField;
        return(collection);
    }
Ejemplo n.º 2
0
    private LerpField SetLerpFieldArrayForDirection(int lerpFieldHandler, string arrayName)
    {
        LerpField result = new LerpField();

        result.lerpValues = new float[volumeSize * volumeSize * volumeSize];
        result.lerpBuffer = new ComputeBuffer(result.lerpValues.Length, sizeof(float));
        lerpFieldGenerator.SetBuffer(lerpFieldHandler, arrayName, result.lerpBuffer);
        return(result);
    }
Ejemplo n.º 3
0
    private void GenerateLerpField()
    {
        int lerpFieldHandler = lerpFieldGenerator.FindKernel("LerpField");

        lerpField_texture = CreateTexture();
        lerpFieldGenerator.SetTexture(lerpFieldHandler, "LerpField_Texture", lerpField_texture);

        LerpField XField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_X");
        LerpField YField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_Y");
        LerpField ZField = SetLerpFieldArrayForDirection(lerpFieldHandler, "LerpFloats_Z");

        SetupShaderOffsets(lerpFieldGenerator);

        lerpFieldGenerator.Dispatch(lerpFieldHandler, volumeSize / 8, volumeSize / 8, volumeSize / 8);
        lerpField_material.mainTexture = lerpField_texture;

        GetFieldDataFromComputeShader(XField);
        GetFieldDataFromComputeShader(YField);
        GetFieldDataFromComputeShader(ZField);
    }
Ejemplo n.º 4
0
 // Returns the array, but it is also stored in the lerpField passed in.
 private static float[] GetFieldDataFromComputeShader(LerpField lerpField)
 {
     lerpField.lerpBuffer.GetData(lerpField.lerpValues);
     lerpField.lerpBuffer.Dispose();
     return(lerpField.lerpValues);
 }