static void SetProgramAutoConstants( GpuProgramParameters parameters )
        {
            //Matrix
            parameters.SetNamedAutoConstant( "worldViewProjMatrix",
                GpuProgramParameters.AutoConstantType.WorldViewProjMatrix );
            parameters.SetNamedAutoConstant( "worldViewMatrix",
                GpuProgramParameters.AutoConstantType.WorldViewMatrix );
            parameters.SetNamedAutoConstant( "cameraPositionObjectSpace",
                GpuProgramParameters.AutoConstantType.CameraPositionObjectSpace );

            //Fog
            parameters.SetNamedAutoConstant( "fogParams",
                GpuProgramParameters.AutoConstantType.FogParams );
            parameters.SetNamedAutoConstant( "fogColor",
                GpuProgramParameters.AutoConstantType.FogColor );

            //Time
            //parameters.SetNamedAutoConstantFloat( "timeValue",
            //   GpuProgramParameters.AutoConstantType.Time01, 20.0f );
            parameters.SetNamedAutoConstantFloat( "time0X",
                GpuProgramParameters.AutoConstantType.Time0X, 1000.0f );

            parameters.SetNamedAutoConstant( "renderTargetFlipping",
                GpuProgramParameters.AutoConstantType.RenderTargetFlipping );
        }
Beispiel #2
0
        void SetProgramAutoConstants_ShadowCaster_Vertex( GpuProgramParameters parameters )
        {
            parameters.SetNamedAutoConstant( "worldMatrix",
                GpuProgramParameters.AutoConstantType.WorldMatrix );
            parameters.SetNamedAutoConstant( "viewProjMatrix",
                GpuProgramParameters.AutoConstantType.ViewProjMatrix );
            parameters.SetNamedAutoConstant( "cameraPosition",
                GpuProgramParameters.AutoConstantType.CameraPosition );
            parameters.SetNamedAutoConstant( "texelOffsets",
                GpuProgramParameters.AutoConstantType.TexelOffsets );

            if( RenderSystem.Instance.HasShaderModel3() &&
                RenderSystem.Instance.Capabilities.HardwareInstancing )
            {
                parameters.SetNamedAutoConstant( "instancing", GpuProgramParameters.AutoConstantType.Instancing );
            }

            //1 hour interval for better precision.
            parameters.SetNamedAutoConstantFloat( "time",
                GpuProgramParameters.AutoConstantType.Time0X, 3600.0f );
        }
Beispiel #3
0
        void SetProgramAutoConstants_ShadowCaster_Fragment( GpuProgramParameters parameters )
        {
            parameters.SetNamedAutoConstant( "farClipDistance",
                GpuProgramParameters.AutoConstantType.FarClipDistance );
            parameters.SetNamedAutoConstant( "shadowDirectionalLightBias",
                GpuProgramParameters.AutoConstantType.ShadowDirectionalLightBias );
            parameters.SetNamedAutoConstant( "shadowSpotLightBias",
                GpuProgramParameters.AutoConstantType.ShadowSpotLightBias );
            parameters.SetNamedAutoConstant( "shadowPointLightBias",
                GpuProgramParameters.AutoConstantType.ShadowPointLightBias );

            parameters.SetNamedAutoConstant( "alphaRejectValue",
                GpuProgramParameters.AutoConstantType.AlphaRejectValue );

            //1 hour interval for better precision.
            parameters.SetNamedAutoConstantFloat( "time",
                GpuProgramParameters.AutoConstantType.Time0X, 3600.0f );
        }
Beispiel #4
0
        void SetProgramAutoConstants_Main_Vertex( GpuProgramParameters parameters, int lightCount )
        {
            bool shadowMap = SceneManager.Instance.IsShadowTechniqueShadowmapBased() && ReceiveShadows &&
                lightCount != 0;

            parameters.SetNamedAutoConstant( "worldMatrix",
                GpuProgramParameters.AutoConstantType.WorldMatrix );
            parameters.SetNamedAutoConstant( "viewProjMatrix",
                GpuProgramParameters.AutoConstantType.ViewProjMatrix );
            parameters.SetNamedAutoConstant( "cameraPositionObjectSpace",
                GpuProgramParameters.AutoConstantType.CameraPositionObjectSpace );
            parameters.SetNamedAutoConstant( "cameraPosition",
                GpuProgramParameters.AutoConstantType.CameraPosition );

            if( lightCount != 0 )
            {
                if( shadowMap )
                {
                    parameters.SetNamedAutoConstant( "textureViewProjMatrix0",
                    GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 0 );
                    parameters.SetNamedAutoConstant( "textureViewProjMatrix1",
                        GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 1 );
                    parameters.SetNamedAutoConstant( "textureViewProjMatrix2",
                        GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 2 );
                    parameters.SetNamedAutoConstant( "shadowFarDistance",
                        GpuProgramParameters.AutoConstantType.ShadowFarDistance );
                    parameters.SetNamedAutoConstant( "shadowTextureSizes",
                        GpuProgramParameters.AutoConstantType.ShadowTextureSizes );
                    if( SceneManager.Instance.IsShadowTechniquePSSM() )
                    {
                        parameters.SetNamedAutoConstant( "shadowDirectionalLightSplitDistances",
                            GpuProgramParameters.AutoConstantType.ShadowDirectionalLightSplitDistances );
                    }
                }

                parameters.SetNamedAutoConstant( "lightPositionArray",
                    GpuProgramParameters.AutoConstantType.LightPositionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightPositionObjectSpaceArray",
                    GpuProgramParameters.AutoConstantType.LightPositionObjectSpaceArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDirectionArray",
                    GpuProgramParameters.AutoConstantType.LightDirectionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightAttenuationArray",
                    GpuProgramParameters.AutoConstantType.LightAttenuationArray, lightCount );
                parameters.SetNamedAutoConstant( "spotLightParamsArray",
                    GpuProgramParameters.AutoConstantType.SpotLightParamsArray, lightCount );
                parameters.SetNamedAutoConstant( "lightCustomShaderParameterArray",
                    GpuProgramParameters.AutoConstantType.LightCustomShaderParameterArray, lightCount );
            }

            //instancing
            if( RenderSystem.Instance.HasShaderModel3() &&
                RenderSystem.Instance.Capabilities.HardwareInstancing )
            {
                parameters.SetNamedAutoConstant( "instancing", GpuProgramParameters.AutoConstantType.Instancing );
            }

            //1 hour interval for better precision.
            parameters.SetNamedAutoConstantFloat( "time",
                GpuProgramParameters.AutoConstantType.Time0X, 3600.0f );
        }
Beispiel #5
0
        void SetProgramAutoConstants_Main_Fragment( GpuProgramParameters parameters, int lightCount )
        {
            bool shadowMap = SceneManager.Instance.IsShadowTechniqueShadowmapBased() && ReceiveShadows &&
                lightCount != 0;

            parameters.SetNamedAutoConstant( "worldMatrix", GpuProgramParameters.AutoConstantType.WorldMatrix );
            parameters.SetNamedAutoConstant( "cameraPosition", GpuProgramParameters.AutoConstantType.CameraPosition );

            parameters.SetNamedAutoConstant( "farClipDistance",
                GpuProgramParameters.AutoConstantType.FarClipDistance );

            if( shadowMap )
            {
                parameters.SetNamedAutoConstant( "drawShadowDebugging",
                    GpuProgramParameters.AutoConstantType.DrawShadowDebugging );
            }

            //viewportSize
            if( SoftParticles )
            {
                parameters.SetNamedAutoConstant( "viewportSize",
                    GpuProgramParameters.AutoConstantType.ViewportSize );
            }

            //Light
            parameters.SetNamedAutoConstant( "ambientLightColor",
                GpuProgramParameters.AutoConstantType.AmbientLightColor );

            if( lightCount != 0 )
            {
                if( shadowMap )
                {
                    parameters.SetNamedAutoConstant( "lightShadowFarClipDistance",
                        GpuProgramParameters.AutoConstantType.LightShadowFarClipDistance, 0 );
                    parameters.SetNamedAutoConstant( "shadowFarDistance",
                        GpuProgramParameters.AutoConstantType.ShadowFarDistance );
                    parameters.SetNamedAutoConstant( "shadowColorIntensity",
                        GpuProgramParameters.AutoConstantType.ShadowColorIntensity );
                    parameters.SetNamedAutoConstant( "shadowTextureSizes",
                        GpuProgramParameters.AutoConstantType.ShadowTextureSizes );
                    if( SceneManager.Instance.IsShadowTechniquePSSM() )
                    {
                        parameters.SetNamedAutoConstant( "shadowDirectionalLightSplitDistances",
                            GpuProgramParameters.AutoConstantType.ShadowDirectionalLightSplitDistances );
                    }
                }

                parameters.SetNamedAutoConstant( "lightPositionArray",
                    GpuProgramParameters.AutoConstantType.LightPositionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDirectionArray",
                    GpuProgramParameters.AutoConstantType.LightDirectionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightAttenuationArray",
                    GpuProgramParameters.AutoConstantType.LightAttenuationArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDiffuseColorPowerScaledArray",
                    GpuProgramParameters.AutoConstantType.LightDiffuseColorPowerScaledArray, lightCount );
                parameters.SetNamedAutoConstant( "lightSpecularColorPowerScaledArray",
                    GpuProgramParameters.AutoConstantType.LightSpecularColorPowerScaledArray, lightCount );
                parameters.SetNamedAutoConstant( "spotLightParamsArray",
                    GpuProgramParameters.AutoConstantType.SpotLightParamsArray, lightCount );
                parameters.SetNamedAutoConstant( "lightCastShadowsArray",
                    GpuProgramParameters.AutoConstantType.LightCastShadowsArray, lightCount );
                parameters.SetNamedAutoConstant( "lightCustomShaderParameterArray",
                    GpuProgramParameters.AutoConstantType.LightCustomShaderParameterArray, lightCount );
            }

            //Fog
            if( allowFog && SceneManager.Instance.GetFogMode() != FogMode.None )
            {
                parameters.SetNamedAutoConstant( "fogParams",
                    GpuProgramParameters.AutoConstantType.FogParams );
                parameters.SetNamedAutoConstant( "fogColor",
                    GpuProgramParameters.AutoConstantType.FogColor );
            }

            //lightmap
            if( LightmapTexCoordIndex != -1 )
            {
                parameters.SetNamedAutoConstant( "lightmapUVTransform",
                    GpuProgramParameters.AutoConstantType.LightmapUVTransform );
            }

            //clip planes
            if( RenderSystem.Instance.IsOpenGL() )
            {
                for( int n = 0; n < 6; n++ )
                {
                    parameters.SetNamedAutoConstant( "clipPlane" + n.ToString(),
                        GpuProgramParameters.AutoConstantType.ClipPlane, n );
                }
            }

            if( RenderSystem.Instance.IsOpenGLES() )
            {
                parameters.SetNamedAutoConstant( "alphaRejectValue",
                    GpuProgramParameters.AutoConstantType.AlphaRejectValue );
            }

            //1 hour interval for better precision.
            parameters.SetNamedAutoConstantFloat( "time",
                GpuProgramParameters.AutoConstantType.Time0X, 3600.0f );
        }
        protected virtual void OnSetProgramAutoConstants(
            GpuProgramParameters parameters, int lightCount)
        {
            parameters.SetNamedAutoConstant( "worldMatrix",
                GpuProgramParameters.AutoConstantType.WorldMatrix );
            parameters.SetNamedAutoConstant( "worldViewMatrix",
                GpuProgramParameters.AutoConstantType.WorldViewMatrix );
            parameters.SetNamedAutoConstant( "worldViewProjMatrix",
                GpuProgramParameters.AutoConstantType.WorldViewProjMatrix );
            parameters.SetNamedAutoConstant( "viewProjMatrix",
                GpuProgramParameters.AutoConstantType.ViewProjMatrix );
            parameters.SetNamedAutoConstant( "cameraPositionObjectSpace",
                GpuProgramParameters.AutoConstantType.CameraPositionObjectSpace );
            parameters.SetNamedAutoConstant( "cameraPosition",
                GpuProgramParameters.AutoConstantType.CameraPosition );
            parameters.SetNamedAutoConstant( "farClipDistance",
                GpuProgramParameters.AutoConstantType.FarClipDistance );

            parameters.SetNamedAutoConstant( "texelOffsets",
                GpuProgramParameters.AutoConstantType.TexelOffsets );
            parameters.SetNamedAutoConstant( "alphaRejectValue",
                GpuProgramParameters.AutoConstantType.AlphaRejectValue );

            parameters.SetNamedAutoConstant( "disableFetch4ForBrokenDrivers",
                GpuProgramParameters.AutoConstantType.DisableFetch4ForBrokenDrivers );

            //Light
            parameters.SetNamedAutoConstant( "ambientLightColor",
                GpuProgramParameters.AutoConstantType.AmbientLightColor );

            if( lightCount != 0 )
            {
                parameters.SetNamedAutoConstant( "textureViewProjMatrix0",
                    GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 0 );
                parameters.SetNamedAutoConstant( "textureViewProjMatrix1",
                    GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 1 );
                parameters.SetNamedAutoConstant( "textureViewProjMatrix2",
                    GpuProgramParameters.AutoConstantType.TextureViewProjMatrix, 2 );
                parameters.SetNamedAutoConstant( "lightShadowFarClipDistance",
                    GpuProgramParameters.AutoConstantType.LightShadowFarClipDistance, 0 );
                parameters.SetNamedAutoConstant( "shadowFarDistance",
                    GpuProgramParameters.AutoConstantType.ShadowFarDistance );
                parameters.SetNamedAutoConstant( "shadowColorIntensity",
                    GpuProgramParameters.AutoConstantType.ShadowColorIntensity );
                parameters.SetNamedAutoConstant( "shadowTextureSizes",
                    GpuProgramParameters.AutoConstantType.ShadowTextureSizes );
                parameters.SetNamedAutoConstant( "shadowDirectionalLightSplitDistances",
                    GpuProgramParameters.AutoConstantType.ShadowDirectionalLightSplitDistances );
                parameters.SetNamedAutoConstant( "lightPositionArray",
                    GpuProgramParameters.AutoConstantType.LightPositionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightPositionObjectSpaceArray",
                    GpuProgramParameters.AutoConstantType.LightPositionObjectSpaceArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDirectionArray",
                    GpuProgramParameters.AutoConstantType.LightDirectionArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDirectionObjectSpaceArray",
                    GpuProgramParameters.AutoConstantType.LightDirectionObjectSpaceArray, lightCount );
                parameters.SetNamedAutoConstant( "lightAttenuationArray",
                    GpuProgramParameters.AutoConstantType.LightAttenuationArray, lightCount );
                parameters.SetNamedAutoConstant( "lightDiffuseColorPowerScaledArray",
                    GpuProgramParameters.AutoConstantType.LightDiffuseColorPowerScaledArray, lightCount );
                parameters.SetNamedAutoConstant( "lightSpecularColorPowerScaledArray",
                    GpuProgramParameters.AutoConstantType.LightSpecularColorPowerScaledArray, lightCount );
                parameters.SetNamedAutoConstant( "spotLightParamsArray",
                    GpuProgramParameters.AutoConstantType.SpotLightParamsArray, lightCount );
                parameters.SetNamedAutoConstant( "lightCastShadowsArray",
                    GpuProgramParameters.AutoConstantType.LightCastShadowsArray, lightCount );
            }

            //Fog
            parameters.SetNamedAutoConstant( "fogParams",
                GpuProgramParameters.AutoConstantType.FogParams );
            parameters.SetNamedAutoConstant( "fogColor",
                GpuProgramParameters.AutoConstantType.FogColor );

            //Time
            //1 hour interval. for better precision
            parameters.SetNamedAutoConstantFloat( "time",
                GpuProgramParameters.AutoConstantType.Time0X, 3600.0f );

            //lightmap
            parameters.SetNamedAutoConstant( "lightmapUVTransform",
                GpuProgramParameters.AutoConstantType.LightmapUVTransform );

            //clip planes
            for( int n = 0; n < 6; n++ )
            {
                parameters.SetNamedAutoConstant( "clipPlane" + n.ToString(),
                    GpuProgramParameters.AutoConstantType.ClipPlane, n );
            }

            parameters.SetNamedAutoConstant( "instancing",
                GpuProgramParameters.AutoConstantType.Instancing );
        }