Static class containing source for vertex programs for extruding shadow volumes.
This exists so we don't have to be dependent on an external media files. is used so we don't have to rely on particular plugins. assembler contents of this file were generated from the following Cg: // Point light shadow volume extrude void shadowVolumeExtrudePointLight_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos // homogenous, object space ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float4 newpos = (wcoord.xxxx * lightPos) + float4(position.xyz - lightPos.xyz, 0); oPosition = mul(worldViewProjMatrix, newpos); } // Directional light extrude void shadowVolumeExtrudeDirLight_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos // homogenous, object space ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float4 newpos = (wcoord.xxxx * (position + lightPos)) - lightPos; oPosition = mul(worldViewProjMatrix, newpos); } // Point light shadow volume extrude - FINITE void shadowVolumeExtrudePointLightFinite_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos, // homogenous, object space uniform float extrusionDistance // how far to extrude ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 float3 extrusionDir = position.xyz - lightPos.xyz; extrusionDir = normalize(extrusionDir); float4 newpos = float4(position.xyz + ((1 - wcoord.x) * extrusionDistance * extrusionDir), 1); oPosition = mul(worldViewProjMatrix, newpos); } // Directional light extrude - FINITE void shadowVolumeExtrudeDirLightFinite_vp ( float4 position : POSITION, float wcoord : TEXCOORD0, out float4 oPosition : POSITION, uniform float4x4 worldViewProjMatrix, uniform float4 lightPos, // homogenous, object space uniform float extrusionDistance // how far to extrude ) { // extrusion in object space // vertex unmodified if w==1, extruded if w==0 // -ve lightPos is direction float4 newpos = float4(position.xyz - (wcoord.x * extrusionDistance * lightPos.xyz), 1); oPosition = mul(worldViewProjMatrix, newpos); }
        /// <summary>
        ///		Initialize the creation of these core vertex programs.
        /// </summary>
        public static void Initialize()
        {
            // only need to initialize once
            if (!isInitialized)
            {
                string syntax = "";

                // flags for which of the programs use finite extrusion
                bool[] vertexProgramFinite =
                    new bool[] { false, false, false, false, true, true, true, true };

                // flags for which of the programs use debug rendering
                bool[] vertexProgramDebug =
                    new bool[] { false, true, false, true, false, true, false, true };

                // types of lights that each of the programs target
                LightType[] vertexProgramLightTypes =
                    new LightType[] {
                    LightType.Point, LightType.Point,
                    LightType.Directional, LightType.Directional,
                    LightType.Point, LightType.Point,
                    LightType.Directional, LightType.Directional
                };

                // load hardware extrusion programs for point & dir lights
                if (GpuProgramManager.Instance.IsSyntaxSupported("arbvp1"))
                {
                    syntax = "arbvp1";
                }
                else if (GpuProgramManager.Instance.IsSyntaxSupported("vs_1_1"))
                {
                    syntax = "vs_1_1";
                }
                else
                {
                    throw new AxiomException("Vertex programs are supposedly supported, but neither arbvp1 nor vs_1_1 syntaxes are supported.");
                }

                // create the programs
                for (int i = 0; i < programNames.Length; i++)
                {
                    // sanity check to make sure it doesn't already exist
                    if (GpuProgramManager.Instance.GetByName(programNames[i]) == null)
                    {
                        string source = ShadowVolumeExtrudeProgram.GetProgramSource(
                            vertexProgramLightTypes[i], syntax, vertexProgramFinite[i], vertexProgramDebug[i]);

                        // create the program from the static source
                        GpuProgram program =
                            GpuProgramManager.Instance.CreateProgramFromString(
                                programNames[i], source, GpuProgramType.Vertex, syntax);

                        // load the program
                        program.Load();
                    }
                }

                isInitialized = true;
            }
        }