Exemplo n.º 1
0
    public void Update(DeviceContext context, ImageBasedLightingEnvironment lightingEnvironment, ShaderResourceView controlVertexInfosView, ShapeNormals shapeNormals)
    {
        if (this.shapeNormals != shapeNormals || texturedVertexInfoPairsView == null)
        {
            this.shapeNormals = shapeNormals;

            texturedVertexInfoPairsView?.Dispose();
            var pairs = TexturedVertexInfoPair.Interleave(primaryTexturedVertexInfos, shapeNormals?.TexturedVertexInfos);
            texturedVertexInfoPairsView = BufferUtilities.ToStructuredBufferView(device, pairs);
        }

        scatterer?.Scatter(context, lightingEnvironment, controlVertexInfosView);
        vertexRefiner.RefineVertices(context, controlVertexInfosView, scatterer?.ScatteredIlluminationView);
    }
Exemplo n.º 2
0
    public static             TexturedVertexInfoPair[] Interleave(TexturedVertexInfo[] primaries, TexturedVertexInfo[] secondaries)
    {
        int count = primaries.Length;

        if (secondaries != null && count != secondaries.Length)
        {
            throw new ArgumentException("count mismatch");
        }

        TexturedVertexInfoPair[] pairs = new TexturedVertexInfoPair[count];
        for (int i = 0; i < count; ++i)
        {
            pairs[i] = new TexturedVertexInfoPair(primaries[i], secondaries != null ? secondaries[i] : default(TexturedVertexInfo));
        }
        return(pairs);
    }
Exemplo n.º 3
0
    public FigureRenderer(
        Device device, ShaderCache shaderCache, Scatterer scatterer, VertexRefiner vertexRefiner, MaterialSet materialSet, FigureSurface[] surfaces,
        bool isOneSided, int[] surfaceOrder, bool[] areUnorderedTranparent, TexturedVertexInfo[] texturedVertexInfos)
    {
        this.device        = device;
        this.scatterer     = scatterer;
        this.vertexRefiner = vertexRefiner;
        this.materialSet   = materialSet;
        this.surfaces      = surfaces;

        this.isOneSided              = isOneSided;
        this.surfaceOrder            = surfaceOrder;
        this.areUnorderedTransparent = areUnorderedTranparent;

        var vertexShaderAndBytecode = shaderCache.GetVertexShader <FigureRenderer>("figure/rendering/Figure");

        this.vertexShader      = vertexShaderAndBytecode;
        this.inputLayout       = new InputLayout(device, vertexShaderAndBytecode.Bytecode, vertexRefiner.RefinedVertexBufferInputElements);
        falseDepthVertexShader = shaderCache.GetVertexShader <FigureRenderer>("figure/rendering/Figure-FalseDepth");

        primaryTexturedVertexInfos  = texturedVertexInfos;
        texturedVertexInfoPairsView = BufferUtilities.ToStructuredBufferView(device, TexturedVertexInfoPair.Interleave(primaryTexturedVertexInfos, null));
    }