示例#1
0
            public override void UpdateLayout(string compositionName)
            {
                base.UpdateLayout(compositionName);

                traceAttribute = GetTraceAttr();

                intensityKey         = LightVoxelShaderKeys.Intensity.ComposeWith(compositionName);
                specularIntensityKey = LightVoxelShaderKeys.SpecularIntensity.ComposeWith(compositionName);

                diffuseMarcherKey    = LightVoxelShaderKeys.diffuseMarcher.ComposeWith(compositionName);
                specularMarcherKey   = LightVoxelShaderKeys.specularMarcher.ComposeWith(compositionName);
                attributeSamplersKey = MarchAttributesKeys.AttributeSamplers.ComposeWith(compositionName);

                if (traceAttribute != null)
                {
                    if (((LightVoxel)Light.Type).DiffuseMarcher != null)
                    {
                        ((LightVoxel)Light.Type).DiffuseMarcher.UpdateMarchingLayout("diffuseMarcher." + compositionName);
                    }
                    if (((LightVoxel)Light.Type).SpecularMarcher != null)
                    {
                        ((LightVoxel)Light.Type).SpecularMarcher.UpdateMarchingLayout("specularMarcher." + compositionName);
                    }
                    traceAttribute.UpdateSamplingLayout("AttributeSamplers[0]." + compositionName);
                }
            }
示例#2
0
 public CompositionInput(Variable v, int localIndex)
 {
     Name       = v.Name.Text;
     TypeName   = v.Type.Name.Text;
     Key        = new PermutationParameterKey <ShaderSource>(Name);
     LocalIndex = localIndex;
     Variable   = v;
 }
示例#3
0
 private PermutationParameterKey <T> GetComposeKey <T>(PermutationParameterKey <T> key)
 {
     if (compositionString == null)
     {
         return(key);
     }
     key = key.ComposeWith(compositionString);
     return(key);
 }
示例#4
0
        public void SetParam <T>(PermutationParameterKey <T> key, T value)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var propertyContainer = parameterCollections.Count > 0 ? parameterCollections.Peek() : compilerParameters;

            Set(propertyContainer, key, value);
        }
示例#5
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;
            }
示例#6
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)
            {
                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);
            }
示例#8
0
        private ParameterCollection FindKeyValue <T>(PermutationParameterKey <T> key, out PermutationParameterKey <T> selectedKey)
        {
            // Try to get a value from registered containers
            selectedKey = null;
            foreach (var parameterCollection in parameterCollections)
            {
                if (parameterCollection.ContainsKey(key))
                {
                    selectedKey = key;
                    return(parameterCollection);
                }
            }
            if (compilerParameters.ContainsKey(key))
            {
                selectedKey = key;
                return(compilerParameters);
            }

            return(null);
        }
            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);
            }
示例#10
0
        /// <summary>
        /// Gets a parameter value for the specified key.
        /// </summary>
        /// <typeparam name="T">Type of the parameter value</typeparam>
        /// <param name="paramKey">The parameter key.</param>
        /// <returns>The value or default value associated to this parameter key.</returns>
        /// <exception cref="System.ArgumentNullException">key</exception>
        public T GetParam <T>(PermutationParameterKey <T> paramKey)
        {
            if (paramKey == null)
            {
                throw new ArgumentNullException("paramKey");
            }

            var globalKey   = paramKey;
            var composeKey  = GetComposeKey(paramKey);
            var selectedKey = globalKey;
            ParameterCollection sourceParameters = null;

            // Try first if a composite key with a value is available for the key
            if (composeKey != globalKey)
            {
                sourceParameters = FindKeyValue(composeKey, out selectedKey);
            }

            // Else try using global key
            if (sourceParameters == null)
            {
                sourceParameters = FindKeyValue(globalKey, out selectedKey);
            }

            // If nothing found, use composeKey and global compiler parameters
            if (sourceParameters == null)
            {
                selectedKey      = composeKey;
                sourceParameters = compilerParameters;
            }

            // Gets the value from a source parameters
            var value = Get(sourceParameters, selectedKey);

            return(value);
        }
示例#11
0
 private T Get <T>(ParameterCollection parameterCollection, PermutationParameterKey <T> key)
 {
     return(parameterCollection.Get(key));
 }
示例#12
0
 // Helpers, until we get rid of ParameterCollection
 private void Set <T>(ParameterCollection parameterCollection, PermutationParameterKey <T> key, T value)
 {
     parameterCollection.Set(key, value);
 }
示例#13
0
 /// <summary>
 /// Sets a permutation 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, PermutationParameterKey <T> parameter, T value, int materialIndex = 0, int passIndex = 0)
 {
     modelComponent.GetMaterialPassParameters(materialIndex, passIndex).Set(parameter, value);
 }
 private void SetPermutationParameterForBothShaders <T>(PermutationParameterKey <T> parameter, T value) where T : struct
 {
     blurHShader.Parameters.Set(parameter, value);
     blurVShader.Parameters.Set(parameter, value);
 }
            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);
            }
示例#16
0
        public static IVLPin CreatePermutationPin <T>(ParameterCollection parameters, PermutationParameterKey <T> key)
        {
            var shaderType = typeof(T);
            var pinType    = TypeConversions.ShaderToPinTypeMap.ValueOrDefault(shaderType);

            if (pinType != null)
            {
                var convertedValueParameterPinType = typeof(ConvertedPermutationParameterPin <,>).MakeGenericType(shaderType, pinType);
                return(Activator.CreateInstance(convertedValueParameterPinType, parameters, key) as IVLPin);
            }
            return(new PermutationParameterPin <T>(parameters, key));
        }