Esempio n. 1
0
        /// <inheritdoc/>
        public override void Initialize(EffectContext effectContext, TransformGraph transformGraph)
        {
            var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

            effectContext.LoadPixelShader(GUID_RipplePixelShader, NativeFile.ReadAllBytes(path + "\\Ripple.cso"));
            transformGraph.SetSingleTransformNode(this);
        }
Esempio n. 2
0
        //EffectContext _effectContext;
        public override void Initialize(EffectContext effectContext, TransformGraph transformGraph)
        {
            //WARNING : as soon as TransformGraph.SetSingleTransformNode is called it chain calls the
            //SetDrawInformation via a callbac. Unfortunately this is too early because the code below
            //within this method is used to populate stateful data needed by the SetDrawInformation call.
            //transformGraph.SetSingleTransformNode(this);

            var path = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;

            byte[] vertexShaderBytecode = NativeFile.ReadAllBytes(path + "\\WaveEffect.cso");
            effectContext.LoadVertexShader(GUID_WaveVertexShader, vertexShaderBytecode);

            // Only generate the vertex buffer if it has not already been initialized.
            vertexBuffer = effectContext.FindVertexBuffer(GUID_WaveVertexBuffer);

            if (vertexBuffer == null)
            {
                //InitializeVertexBuffer(effectContext);

                var mesh = GenerateMesh();

                // Updating geometry every time the effect is rendered can be costly, so it is
                // recommended that vertex buffer remain static if possible (which it is in this
                // sample effect).
                using (var stream = DataStream.Create(mesh, true, true))
                {
                    var vbProp = new VertexBufferProperties(1, VertexUsage.Static, stream);

                    var cvbProp = new CustomVertexBufferProperties(vertexShaderBytecode, new[] {
                        new InputElement("MESH_POSITION", 0, SharpDX.DXGI.Format.R32G32_Float, 0, 0),
                    }, Utilities.SizeOf <Vector2>());

                    // The GUID is optional, and is provided here to register the geometry globally.
                    // As mentioned above, this avoids duplication if multiple versions of the effect
                    // are created.
                    vertexBuffer = new VertexBuffer(effectContext, GUID_WaveVertexBuffer, vbProp, cvbProp);
                }
            }

            PrepareForRender(ChangeType.Properties | ChangeType.Context);
            transformGraph.SetSingleTransformNode(this);
        }