Exemple #1
0
        public ComputeEffectNode(NodeContext nodeContext, EffectNodeDescription description) : base(nodeContext, description)
        {
            graphicsDevice = description.Factory.DeviceManager.GraphicsDevice;
            instance       = new DynamicEffectInstance("ComputeEffectShader");
            // TODO: Same code as in description
            instance.Parameters.Set(ComputeEffectShaderKeys.ComputeShaderName, description.Name);
            instance.Parameters.Set(ComputeEffectShaderKeys.ThreadNumbers, new Int3(1));
            instance.Initialize(description.Factory.ServiceRegistry);
            instance.UpdateEffect(graphicsDevice);
            parameters     = instance.Parameters;
            Inputs         = description.CreateNodeInputs(this, parameters);
            Outputs        = description.CreateNodeOutputs(this, parameters);
            perFrameParams = parameters.GetWellKnownParameters(WellKnownParameters.PerFrameMap).ToArray();
            perViewParams  = parameters.GetWellKnownParameters(WellKnownParameters.PerViewMap).ToArray();
            perDrawParams  = parameters.GetWellKnownParameters(WellKnownParameters.PerDrawMap).ToArray();
            if (perDrawParams.Length > 0)
            {
                worldPin = Inputs.OfType <ConvertedValueParameterPin <Matrix, SharpDX.Matrix> >().FirstOrDefault(p => p.Key == TransformationKeys.World);
            }

            Inputs.SelectPin(EffectNodeDescription.ComputeDispatchCountInput, ref dispatchCountPin);
            Inputs.SelectPin(EffectNodeDescription.ComputeThreadNumbersInput, ref threadNumbersPin);
            Inputs.SelectPin(EffectNodeDescription.ComputeIterationCountInput, ref iterationCountPin);
            Inputs.SelectPin(EffectNodeDescription.ParameterSetterInput, ref parameterSetterPin);
            Inputs.SelectPin(EffectNodeDescription.ComputeIterationParameterSetterInput, ref iterationParameterSetterPin);
            Inputs.SelectPin(EffectNodeDescription.ComputeEnabledInput, ref enabledPin);
        }
Exemple #2
0
 public EffectNode(NodeContext nodeContext, EffectNodeDescription description) : base(nodeContext, description)
 {
     graphicsDevice = description.Factory.DeviceManager.GraphicsDevice;
     instance       = new DynamicEffectInstance(description.Name);
     instance.Initialize(description.Factory.ServiceRegistry);
     instance.UpdateEffect(graphicsDevice);
     parameters     = instance.Parameters;
     Inputs         = description.CreateNodeInputs(this, parameters);
     Outputs        = description.CreateNodeOutputs(this, parameters);
     perFrameParams = parameters.GetWellKnownParameters(WellKnownParameters.PerFrameMap).ToArray();
     perViewParams  = parameters.GetWellKnownParameters(WellKnownParameters.PerViewMap).ToArray();
     perDrawParams  = parameters.GetWellKnownParameters(WellKnownParameters.PerDrawMap).ToArray();
     if (perDrawParams.Length > 0)
     {
         worldPin = Inputs.OfType <ConvertedValueParameterPin <Matrix, SharpDX.Matrix> >().FirstOrDefault(p => p.Key == TransformationKeys.World);
     }
     if (Inputs.Length > 0)
     {
         customParameterSetterPin = Inputs[Inputs.Length - 1] as Pin <Action <ParameterCollection, RenderView, RenderDrawContext> >;
     }
 }