public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey<Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color? defaultTextureValue)
        {
            if (defaultValueKey == null) throw new ArgumentNullException(nameof(defaultValueKey));
            if (computeNode == null)
            {
                return;
            }

            var streamType = MaterialStreamType.Float;
            if (defaultValueKey.PropertyType == typeof(Vector4) || defaultValueKey.PropertyType == typeof(Color4))
            {
                streamType = MaterialStreamType.Float4;
            }
            else if (defaultValueKey.PropertyType == typeof(Vector3) || defaultValueKey.PropertyType == typeof(Color3))
            {
                streamType = MaterialStreamType.Float3;
            }
            else if (defaultValueKey.PropertyType == typeof(Vector2) || defaultValueKey.PropertyType == typeof(Half2))
            {
                streamType = MaterialStreamType.Float2;
            }
            else if (defaultValueKey.PropertyType == typeof(float))
            {
                streamType = MaterialStreamType.Float;
            }
            else
            {
                throw new NotSupportedException("ParameterKey type [{0}] is not supported by SetStream".ToFormat(defaultValueKey.PropertyType));
            }

            var classSource = computeNode.GenerateShaderSource(Context, new MaterialComputeColorKeys(defaultTexturingKey, defaultValueKey, defaultTextureValue));
            SetStream(stage, stream, streamType, classSource);
        }
 public MaterialComputeColorKeys(ObjectParameterKey<Texture> textureBaseKey, ParameterKey valueBaseKey, Color? defaultTextureValue = null, bool isColor = true)
 {
     //if (textureBaseKey == null) throw new ArgumentNullException("textureBaseKey");
     //if (valueBaseKey == null) throw new ArgumentNullException("valueBaseKey");
     TextureBaseKey = textureBaseKey;
     ValueBaseKey = valueBaseKey;
     DefaultTextureValue = defaultTextureValue;
     IsColor = isColor;
 }
 public void UpdateLayout(string compositionName)
 {
     projectiveTextureKey = TextureProjectionKeys.ProjectionTexture.ComposeWith(compositionName);
     uvScale  = TextureProjectionKeys.UVScale.ComposeWith(compositionName);
     uvOffset = TextureProjectionKeys.UVOffset.ComposeWith(compositionName);
     worldToProjectiveTextureUVsKey   = TextureProjectionReceiverBaseKeys.WorldToProjectiveTextureUV.ComposeWith(compositionName);
     projectorPlaneMatricesKey        = TextureProjectionReceiverBaseKeys.ProjectorPlaneMatrices.ComposeWith(compositionName);
     projectionTextureMipMapLevelsKey = TextureProjectionReceiverBaseKeys.ProjectionTextureMipMapLevels.ComposeWith(compositionName);
     transitionAreasKey = TextureProjectionReceiverBaseKeys.TransitionAreas.ComposeWith(compositionName);
 }
Exemplo n.º 4
0
 public override void UpdateLayout(string compositionName)
 {
     shadowMapTextureKey               = ShadowMapKeys.ShadowMapTexture.ComposeWith(compositionName);
     shadowMapTextureSizeKey           = ShadowMapKeys.TextureSize.ComposeWith(compositionName);
     shadowMapTextureTexelSizeKey      = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionName);
     worldToShadowCascadeUVsKey        = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionName);
     inverseWorldToShadowCascadeUVsKey = ShadowMapReceiverBaseKeys.InverseWorldToShadowCascadeUV.ComposeWith(compositionName);
     depthRangesKey  = ShadowMapReceiverBaseKeys.DepthRanges.ComposeWith(compositionName);
     depthBiasesKey  = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionName);
     offsetScalesKey = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionName);
 }
 public override void UpdateLayout(string compositionName)
 {
     shadowMapTextureKey          = ShadowMapKeys.ShadowMapTexture.ComposeWith(compositionName);
     shadowMapTextureSizeKey      = ShadowMapKeys.TextureSize.ComposeWith(compositionName);
     shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionName);
     worldToShadowKey             = ShadowMapReceiverPointCubeMapKeys.WorldToShadow.ComposeWith(compositionName);
     inverseWorldToShadowKey      = ShadowMapReceiverPointCubeMapKeys.InverseWorldToShadow.ComposeWith(compositionName);
     depthBiasesKey     = ShadowMapReceiverPointCubeMapKeys.DepthBiases.ComposeWith(compositionName);
     depthParametersKey = ShadowMapReceiverPointCubeMapKeys.DepthParameters.ComposeWith(compositionName);
     offsetScalesKey    = ShadowMapReceiverPointCubeMapKeys.OffsetScales.ComposeWith(compositionName);
 }
Exemplo n.º 6
0
            public LightSkyBoxShaderGroupData(LightSkyBoxShaderGroup group) : base(null)
            {
                intensityKey          = group.IntensityKey;
                skyMatrixKey          = group.SkyMatrixKey;
                lightDiffuseColorKey  = group.LightDiffuseColorKey;
                lightSpecularColorKey = group.LightSpecularColorKey;

                sphericalColorsKey  = group.SphericalColorsKey;
                specularCubeMapkey  = group.SpecularCubeMapkey;
                specularMipCountKey = group.SpecularMipCountKey;
            }
Exemplo n.º 7
0
            public LightSkyBoxShaderGroup(ShaderSource mixin, string compositionName)
                : base(mixin, compositionName, null)
            {
                IntensityKey          = LightSkyboxShaderKeys.Intensity.ComposeWith(compositionName);
                SkyMatrixKey          = LightSkyboxShaderKeys.SkyMatrix.ComposeWith(compositionName);
                LightDiffuseColorKey  = LightSkyboxShaderKeys.LightDiffuseColor.ComposeWith(compositionName);
                LightSpecularColorKey = LightSkyboxShaderKeys.LightSpecularColor.ComposeWith(compositionName);

                SphericalColorsKey  = SphericalHarmonicsEnvironmentColorKeys.SphericalColors.ComposeWith("lightDiffuseColor." + compositionName);
                SpecularCubeMapkey  = RoughnessCubeMapEnvironmentColorKeys.CubeMap.ComposeWith("lightSpecularColor." + compositionName);
                SpecularMipCountKey = RoughnessCubeMapEnvironmentColorKeys.MipCount.ComposeWith("lightSpecularColor." + compositionName);
            }
 public override void UpdateLayout(string compositionName)
 {
     shadowMapTextureKey          = ShadowMapKeys.ShadowMapTexture.ComposeWith(compositionName);
     shadowMapTextureSizeKey      = ShadowMapKeys.TextureSize.ComposeWith(compositionName);
     shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionName);
     offsetsKey         = ShadowMapReceiverPointParaboloidKeys.FaceOffsets.ComposeWith(compositionName);
     backfaceOffsetsKey = ShadowMapReceiverPointParaboloidKeys.BackfaceOffsets.ComposeWith(compositionName);
     faceSizesKey       = ShadowMapReceiverPointParaboloidKeys.FaceSizes.ComposeWith(compositionName);
     depthParametersKey = ShadowMapReceiverPointParaboloidKeys.DepthParameters.ComposeWith(compositionName);
     viewKey            = ShadowMapReceiverPointParaboloidKeys.View.ComposeWith(compositionName);
     depthBiasesKey     = ShadowMapReceiverPointParaboloidKeys.DepthBiases.ComposeWith(compositionName);
 }
Exemplo n.º 9
0
            public override void UpdateLayout(string compositionName)
            {
                base.UpdateLayout(compositionName);

                intensityKey          = LightSkyboxShaderKeys.Intensity.ComposeWith(compositionName);
                skyMatrixKey          = LightSkyboxShaderKeys.SkyMatrix.ComposeWith(compositionName);
                lightDiffuseColorKey  = LightSkyboxShaderKeys.LightDiffuseColor.ComposeWith(compositionName);
                lightSpecularColorKey = LightSkyboxShaderKeys.LightSpecularColor.ComposeWith(compositionName);

                sphericalColorsKey  = SphericalHarmonicsEnvironmentColorKeys.SphericalColors.ComposeWith("lightDiffuseColor." + compositionName);
                specularCubeMapkey  = RoughnessCubeMapEnvironmentColorKeys.CubeMap.ComposeWith("lightSpecularColor." + compositionName);
                specularMipCountKey = RoughnessCubeMapEnvironmentColorKeys.MipCount.ComposeWith("lightSpecularColor." + compositionName);
            }
Exemplo n.º 10
0
        public ObjectParameterKey <Texture> GetTextureKey(Texture texture, ObjectParameterKey <Texture> key, Color?defaultTextureValue = null)
        {
            var textureKey = (ObjectParameterKey <Texture>)GetParameterKey(key);

            if (texture != null)
            {
                Parameters.Set(textureKey, texture);
            }
            else if (defaultTextureValue != null && Content != null)
            {
                texture = GenerateTextureFromColor(defaultTextureValue.Value);
                Parameters.Set(textureKey, texture);
            }
            return(textureKey);
        }
Exemplo n.º 11
0
        private static void CopyTexture(GraphicsContext graphicsContext, EffectInstance effectInstance, Texture input, Texture output,
                                        ObjectParameterKey <Texture> inputTextureKey, ValueParameterKey <float> mipLevelKey)
        {
            // Set the "input" texture as the texture that we will copy to "output":
            effectInstance.Parameters.Set(inputTextureKey, input); // TODO: STABILITY: Supply the parent texture instead? I mean here we're using SampleLOD in the shader because texture views are basically being ignored during sampling on OpenGL/ES.

            // Set the mipmap level of the input texture we want to sample:
            effectInstance.Parameters.Set(mipLevelKey, input.MipLevel);  // TODO: STABILITY: Manually pass the mip level?

            // Set the "output" texture as the render target (the copy destination):
            graphicsContext.CommandList.SetRenderTargetAndViewport(null, output);

            // Perform the actual draw call to filter and copy the texture:
            graphicsContext.DrawQuad(effectInstance);
        }
Exemplo n.º 12
0
        public void UpdateVoxelizationLayout(string compositionName)
        {
            fragmentsBufferKey   = VoxelStorageClipmapShaderKeys.fragmentsBuffer.ComposeWith(compositionName);
            clipMapResolutionKey = VoxelStorageClipmapShaderKeys.clipMapResolution.ComposeWith(compositionName);
            storageUintsKey      = VoxelStorageClipmapShaderKeys.storageUints.ComposeWith(compositionName);

            if (UpdatesOneClipPerFrame())
            {
                clipScaleKey  = VoxelStorageClipmapShaderKeys.clipScale.ComposeWith(compositionName);
                clipOffsetKey = VoxelStorageClipmapShaderKeys.clipOffset.ComposeWith(compositionName);
                clipPosKey    = VoxelStorageClipmapShaderKeys.clipPos.ComposeWith(compositionName);
            }
            else
            {
                clipMapCountKey          = VoxelStorageClipmapShaderKeys.clipMapCount.ComposeWith(compositionName);
                perClipMapOffsetScaleKey = VoxelStorageClipmapShaderKeys.perClipMapOffsetScale.ComposeWith(compositionName);
            }
        }
Exemplo n.º 13
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LightDirectionalShadowMapGroupShaderData" /> class.
            /// </summary>
            /// <param name="compositionKey">The composition key.</param>
            /// <param name="shadowType">Type of the shadow.</param>
            /// <param name="lightCountMax">The light count maximum.</param>
            public LightDirectionalShadowMapGroupShaderData(string compositionKey, LightShadowType shadowType, int lightCountMax)
            {
                this.shadowType        = shadowType;
                this.cascadeCount      = 1 << ((int)(shadowType & LightShadowType.CascadeMask) - 1);
                cascadeSplits          = new float[cascadeCount * lightCountMax];
                worldToShadowCascadeUV = new Matrix[cascadeCount * lightCountMax];
                depthBiases            = new float[lightCountMax];
                offsetScales           = new float[lightCountMax];

                var mixin            = new ShaderMixinSource();
                var isDepthRangeAuto = (this.shadowType & LightShadowType.DepthRangeAuto) != 0;

                mixin.Mixins.Add(new ShaderClassSource(ShaderName, cascadeCount, lightCountMax, (this.shadowType & LightShadowType.BlendCascade) != 0 && !isDepthRangeAuto, isDepthRangeAuto, (this.shadowType & LightShadowType.Debug) != 0));
                // TODO: Temporary passing filter here

                switch (shadowType & LightShadowType.FilterMask)
                {
                case LightShadowType.PCF3x3:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 3));
                    break;

                case LightShadowType.PCF5x5:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 5));
                    break;

                case LightShadowType.PCF7x7:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 7));
                    break;

                default:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterDefault"));
                    break;
                }

                shadowShader                 = mixin;
                shadowMapTextureKey          = ShadowMapKeys.Texture.ComposeWith(compositionKey);
                shadowMapTextureSizeKey      = ShadowMapKeys.TextureSize.ComposeWith(compositionKey);
                shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey);
                cascadeSplitsKey             = ShadowMapReceiverDirectionalKeys.CascadeDepthSplits.ComposeWith(compositionKey);
                worldToShadowCascadeUVsKey   = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey);
                depthBiasesKey               = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey);
                offsetScalesKey              = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey);
            }
            public override void UpdateLayout(string compositionName)
            {
                base.UpdateLayout(compositionName);

                intensityKey            = LightVoxelShaderKeys.Intensity.ComposeWith(compositionName);
                intensityBounceScaleKey = LightVoxelShaderKeys.IntensityBounceScale.ComposeWith(compositionName);
                voxelMatrixKey          = LightVoxelShaderKeys.VoxelMatrix.ComposeWith(compositionName);

                lightDiffuseVoxelColorKey = LightVoxelShaderKeys.LightDiffuseVoxelColor.ComposeWith(compositionName);

                voxelVolumekey             = IsotropicVoxelColorKeys.VoxelVolume.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                mipMapsVolumekey           = IsotropicVoxelColorKeys.VoxelMipMaps.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR1           = IsotropicVoxelColorKeys.VoxelVolumeR1.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR2           = IsotropicVoxelColorKeys.VoxelVolumeR2.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR3           = IsotropicVoxelColorKeys.VoxelVolumeR3.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR4           = IsotropicVoxelColorKeys.VoxelVolumeR4.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR5           = IsotropicVoxelColorKeys.VoxelVolumeR5.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumekeyR6           = IsotropicVoxelColorKeys.VoxelVolumeR6.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumeMipCountKey     = IsotropicVoxelColorKeys.MipCount.ComposeWith("lightDiffuseVoxelColor." + compositionName);
                voxelVolumeClipMapCountKey = IsotropicVoxelColorKeys.ClipMapCount.ComposeWith("lightDiffuseVoxelColor." + compositionName);
            }
Exemplo n.º 15
0
            /// <summary>
            /// Initializes a new instance of the <see cref="LightSpotShadowMapGroupShaderData" /> class.
            /// </summary>
            /// <param name="compositionKey">The composition key.</param>
            /// <param name="shadowType">Type of the shadow.</param>
            /// <param name="lightCountMax">The light count maximum.</param>
            public LightSpotShadowMapGroupShaderData(string compositionKey, LightShadowType shadowType, int lightCountMax)
            {
                this.shadowType        = shadowType;
                worldToShadowCascadeUV = new Matrix[lightCountMax];
                depthBiases            = new float[lightCountMax];
                offsetScales           = new float[lightCountMax];

                var mixin = new ShaderMixinSource();

                mixin.Mixins.Add(new ShaderClassSource(ShaderName, lightCountMax, (this.shadowType & LightShadowType.Debug) != 0));
                // TODO: Temporary passing filter here

                switch (shadowType & LightShadowType.FilterMask)
                {
                case LightShadowType.PCF3x3:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 3));
                    break;

                case LightShadowType.PCF5x5:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 5));
                    break;

                case LightShadowType.PCF7x7:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterPcf", 7));
                    break;

                default:
                    mixin.Mixins.Add(new ShaderClassSource("ShadowMapFilterDefault"));
                    break;
                }

                shadowShader                 = mixin;
                shadowMapTextureKey          = ShadowMapKeys.Texture.ComposeWith(compositionKey);
                shadowMapTextureSizeKey      = ShadowMapKeys.TextureSize.ComposeWith(compositionKey);
                shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey);
                worldToShadowCascadeUVsKey   = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey);
                depthBiasesKey               = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey);
                offsetScalesKey              = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey);
            }
Exemplo n.º 16
0
 public void UpdateLayout(string compositionKey)
 {
     shadowMapTextureKey = ShadowMapKeys.Texture.ComposeWith(compositionKey);
     shadowMapTextureSizeKey = ShadowMapKeys.TextureSize.ComposeWith(compositionKey);
     shadowMapTextureTexelSizeKey = ShadowMapKeys.TextureTexelSize.ComposeWith(compositionKey);
     worldToShadowCascadeUVsKey = ShadowMapReceiverBaseKeys.WorldToShadowCascadeUV.ComposeWith(compositionKey);
     depthBiasesKey = ShadowMapReceiverBaseKeys.DepthBiases.ComposeWith(compositionKey);
     offsetScalesKey = ShadowMapReceiverBaseKeys.OffsetScales.ComposeWith(compositionKey);
 }
 public override void UpdateVoxelizationLayout(string compositionName)
 {
     DirectOutput = VoxelAttributeDirectionalCoverageShaderKeys.DirectOutput.ComposeWith(compositionName);
 }
Exemplo n.º 18
0
 public void UpdateLayout(string compositionName, List <IVoxelModifierEmissionOpacity> modifier)
 {
     DirectOutput = VoxelAnisotropicWriter_Float4Keys.DirectOutput.ComposeWith(compositionName);
 }
 public ObjectParameterKey<Texture> GetTextureKey(Texture texture, ObjectParameterKey<Texture> key, Color? defaultTextureValue = null)
 {
     var textureKey = (ObjectParameterKey<Texture>)GetParameterKey(key);
     if (texture != null)
     {
         Parameters.Set(textureKey, texture);
     }
     else if (defaultTextureValue != null && Content != null)
     {
         texture = GenerateTextureFromColor(defaultTextureValue.Value);
         Parameters.Set(textureKey, texture);
     }
     return textureKey;
 }
 public void ApplyParametersWrite(ObjectParameterKey <Texture> MainKey, ParameterCollection parameters)
 {
     parameters.Set(MainKey, ClipMaps);
 }
Exemplo n.º 21
0
 public static IVLPin CreateResourcePin <T>(ParameterCollection parameters, ObjectParameterKey <T> key) where T : class
 {
     return(new ResourceParameterPin <T>(parameters, key));
 }
            public override void UpdateLayout(string compositionName)
            {
                base.UpdateLayout(compositionName);

                intensityKey = LightSkyboxShaderKeys.Intensity.ComposeWith(compositionName);
                skyMatrixKey = LightSkyboxShaderKeys.SkyMatrix.ComposeWith(compositionName);
                lightDiffuseColorKey = LightSkyboxShaderKeys.LightDiffuseColor.ComposeWith(compositionName);
                lightSpecularColorKey = LightSkyboxShaderKeys.LightSpecularColor.ComposeWith(compositionName);

                sphericalColorsKey = SphericalHarmonicsEnvironmentColorKeys.SphericalColors.ComposeWith("lightDiffuseColor." + compositionName);
                specularCubeMapkey = RoughnessCubeMapEnvironmentColorKeys.CubeMap.ComposeWith("lightSpecularColor." + compositionName);
                specularMipCountKey = RoughnessCubeMapEnvironmentColorKeys.MipCount.ComposeWith("lightSpecularColor." + compositionName);
            }
Exemplo n.º 23
0
 /// <summary>
 /// Sets an object of the material pass parameter. Cloning the <see cref="Material"/> if required.
 /// </summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="modelComponent">The <see cref="ModelComponent"/> to update material parameter on.</param>
 /// <param name="parameter">The parameter to update.</param>
 /// <param name="value">The value.</param>
 /// <param name="materialIndex">The index of the material to update. Default is 0.</param>
 /// <param name="passIndex">The index of the pass of the material to update. Default is 0.</param>
 /// <exception cref="ArgumentNullException">If <paramref name="modelComponent"/> is <see langword="null"/>.</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// If <paramref name="materialIndex"/> is less than 0 or greater than <see cref="ModelComponent.GetMaterialCount"/> and not in <see cref="ModelComponent.Materials"/>.
 /// Or if <paramref name="passIndex"/> is less than 0 or greater than or equal to the mu,ber of passes the material has.
 /// </exception>
 public static void SetMaterialParameter <T>(this ModelComponent modelComponent, ObjectParameterKey <T> parameter, T value, int materialIndex = 0, int passIndex = 0)
 {
     modelComponent.GetMaterialPassParameters(materialIndex, passIndex).Set(parameter, value);
 }
Exemplo n.º 24
0
 public void UpdateLayout(string compositionName, List <IVoxelModifierEmissionOpacity> modifiers)
 {
     DirectOutput     = VoxelIsotropicWriter_Float4Keys.DirectOutput.ComposeWith(compositionName);
     BrightnessInvKey = VoxelIsotropicWriter_Float4Keys.maxBrightnessInv.ComposeWith(compositionName);
 }
Exemplo n.º 25
0
 public void UpdateSamplingLayout(string compositionName)
 {
     ClipMapskey          = VoxelStorageTextureClipmapShaderKeys.clipMaps.ComposeWith(compositionName);
     MipMapskey           = VoxelStorageTextureClipmapShaderKeys.mipMaps.ComposeWith(compositionName);
     perMapOffsetScaleKey = VoxelStorageTextureClipmapShaderKeys.perMapOffsetScale.ComposeWith(compositionName);
 }
Exemplo n.º 26
0
 public void ApplyVoxelizationParameters(ObjectParameterKey <Texture> MainKey, ParameterCollection parameters)
 {
     parameters.Set(MainKey, ClipMaps);
 }
Exemplo n.º 27
0
 public void SetStream(string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue = null)
 {
     SetStream(MaterialShaderStage.Pixel, stream, computeNode, defaultTexturingKey, defaultValueKey, defaultTextureValue);
 }
Exemplo n.º 28
0
 public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue = null)
 {
     currentLayerContext.SetStream(stage, stream, computeNode, defaultTexturingKey, defaultValueKey, defaultTextureValue);
 }
Exemplo n.º 29
0
 private void SetValueParameterForBothShaders <T>(ObjectParameterKey <T> parameter, T value) where T : class
 {
     blurHShader.Parameters.Set(parameter, value);
     blurVShader.Parameters.Set(parameter, value);
 }
Exemplo n.º 30
0
        public void SetStream(MaterialShaderStage stage, string stream, IComputeNode computeNode, ObjectParameterKey <Texture> defaultTexturingKey, ParameterKey defaultValueKey, Color?defaultTextureValue)
        {
            if (defaultValueKey == null)
            {
                throw new ArgumentNullException(nameof(defaultValueKey));
            }
            if (computeNode == null)
            {
                return;
            }

            var streamType = MaterialStreamType.Float;

            if (defaultValueKey.PropertyType == typeof(Vector4) || defaultValueKey.PropertyType == typeof(Color4))
            {
                streamType = MaterialStreamType.Float4;
            }
            else if (defaultValueKey.PropertyType == typeof(Vector3) || defaultValueKey.PropertyType == typeof(Color3))
            {
                streamType = MaterialStreamType.Float3;
            }
            else if (defaultValueKey.PropertyType == typeof(Vector2) || defaultValueKey.PropertyType == typeof(Half2))
            {
                streamType = MaterialStreamType.Float2;
            }
            else if (defaultValueKey.PropertyType == typeof(float))
            {
                streamType = MaterialStreamType.Float;
            }
            else
            {
                throw new NotSupportedException("ParameterKey type [{0}] is not supported by SetStream".ToFormat(defaultValueKey.PropertyType));
            }

            var classSource = computeNode.GenerateShaderSource(Context, new MaterialComputeColorKeys(defaultTexturingKey, defaultValueKey, defaultTextureValue));

            SetStream(stage, stream, streamType, classSource);
        }