Exemple #1
0
        public override void UpdateGpuProgramsParams(Graphics.IRenderable rend, Graphics.Pass pass,
                                                     Graphics.AutoParamDataSource source,
                                                     Core.Collections.LightList lightList)
        {
            if (this.monitorsCountChanged)
            {
                this.vsInMonitorsCount.SetGpuParameter(this.monitorsCount + new Vector2(0.0001f, 0.0001f));
                this.psInMonitorsCount.SetGpuParameter(this.monitorsCount + new Vector2(0.0001f, 0.0001f));

                this.monitorsCountChanged = false;
            }
        }
Exemple #2
0
        public override void UpdateGpuProgramsParams(Graphics.IRenderable rend, Graphics.Pass pass,
                                                     Graphics.AutoParamDataSource source,
                                                     Core.Collections.LightList lightList)
        {
            int shadowIndex = 0;

            foreach (var it in this.shadowTextureParamsList)
            {
                it.WorldViewProjMatrix.SetGpuParameter(source.GetTextureWorldViewProjMatrix(shadowIndex));
                it.InvTextureSize.SetGpuParameter(source.GetInverseTextureSize(it.TextureSamplerIndex));

                shadowIndex++;
            }

            var splitPoints = new Vector4();

            splitPoints.x = this.shadowTextureParamsList[0].MaxRange;
            splitPoints.y = this.shadowTextureParamsList[1].MaxRange;
            splitPoints.z = 0.0;
            splitPoints.w = 0.0;

            this.psSplitPoints.SetGpuParameter(splitPoints);
        }
Exemple #3
0
        public override void UpdateGpuProgramsParams(Graphics.IRenderable rend, Graphics.Pass pass,
                                                     Graphics.AutoParamDataSource source,
                                                     Core.Collections.LightList lightList)
        {
            if (this.lightParamsList.Count == 0)
            {
                return;
            }

            Matrix4   matView             = source.ViewMatrix;
            LightType curLightType        = LightType.Directional;
            int       curSearchLightIndex = 0;

            //Update per light parameters
            for (int i = 0; i < this.lightParamsList.Count; i++)
            {
                LightParams curParams = this.lightParamsList[i];

                if (curLightType != curParams.Type)
                {
                    curLightType        = curParams.Type;
                    curSearchLightIndex = 0;
                }

                Light   srcLight = null;
                Vector4 vParameter;
                ColorEx color;

                //Search a matching light from the current sorted lights of the given renderable
                for (int j = curSearchLightIndex; j < lightList.Count; j++)
                {
                    if (lightList[j].Type == curLightType)
                    {
                        srcLight            = lightList[j];
                        curSearchLightIndex = j + 1;
                        break;
                    }
                }

                //No matching light found -> use a blank dummy light for parameter update
                if (srcLight == null)
                {
                    srcLight = this.blankLight;
                }

                switch (curParams.Type)
                {
                case LightType.Directional:
                    //Update light direction
                    vParameter = matView.TransformAffine(srcLight.GetAs4DVector(true));
                    curParams.Direction.SetGpuParameter(vParameter);
                    break;

                case LightType.Point:
                    //Update light position
                    vParameter = matView.TransformAffine(srcLight.GetAs4DVector(true));
                    curParams.Position.SetGpuParameter(vParameter);

                    //Update light attenuation paramters
                    vParameter.x = srcLight.AttenuationRange;
                    vParameter.y = srcLight.AttenuationConstant;
                    vParameter.z = srcLight.AttenuationLinear;
                    vParameter.w = srcLight.AttenuationQuadratic;
                    curParams.AttenuatParams.SetGpuParameter(vParameter);
                    break;

                case LightType.Spotlight:
                {
                    Vector3 vec3;
                    Matrix3 matViewIT;

                    source.InverseTransposeViewMatrix.Extract3x3Matrix(out matViewIT);

                    //Update light position
                    vParameter = matView.TransformAffine(srcLight.GetAs4DVector(true));
                    curParams.Position.SetGpuParameter(vParameter);

                    vec3 = matViewIT * srcLight.DerivedDirection;
                    vec3.Normalize();

                    vParameter.x = -vec3.x;
                    vParameter.y = -vec3.y;
                    vParameter.z = -vec3.z;
                    vParameter.w = 0.0f;

                    curParams.Direction.SetGpuParameter(vParameter);

                    //Update light attenuation parameters
                    vParameter.x = srcLight.AttenuationRange;
                    vParameter.y = srcLight.AttenuationConstant;
                    vParameter.z = srcLight.AttenuationLinear;
                    vParameter.w = srcLight.AttenuationQuadratic;
                    curParams.AttenuatParams.SetGpuParameter(vParameter);

                    //Update spotlight parameters
                    Real phi   = Axiom.Math.Utility.Cos(srcLight.SpotlightOuterAngle * 0.5);
                    Real theta = Axiom.Math.Utility.Cos(srcLight.SpotlightInnerAngle * 0.5);

                    vec3.x = theta;
                    vec3.y = phi;
                    vec3.z = srcLight.SpotlightFalloff;

                    curParams.SpotParams.SetGpuParameter(vec3);
                }
                break;
                }

                //Update diffuse color
                if ((this.trackVertexColorType & TrackVertexColor.Diffuse) == 0)
                {
                    color = srcLight.Diffuse * pass.Diffuse;
                    curParams.DiffuseColor.SetGpuParameter(color);
                }
                else
                {
                    color = srcLight.Diffuse;
                    curParams.DiffuseColor.SetGpuParameter(color);
                }

                //Update specular color if need to
                if (this.specularEnable)
                {
                    //Update diffuse color
                    if ((this.trackVertexColorType & TrackVertexColor.Specular) == 0)
                    {
                        color = srcLight.Specular * pass.Specular;
                        curParams.SpecularColor.SetGpuParameter(color);
                    }
                    else
                    {
                        color = srcLight.Specular;
                        curParams.SpecularColor.SetGpuParameter(color);
                    }
                }
            }
        }
Exemple #4
0
 public virtual void UpdateGpuProgramsParams(Graphics.IRenderable rend, Graphics.Pass pass,
                                             Graphics.AutoParamDataSource source,
                                             Core.Collections.LightList lightList)
 {
 }