コード例 #1
0
ファイル: TextureAtlasSampler.cs プロジェクト: suntabu/axiom
        public override void UpdateGpuProgramsParams(IRenderable rend, Pass pass, AutoParamDataSource source,
                                                     Core.Collections.LightList lightList)
        {
            if (this.isTableDataUpdated == false)
            {
                this.isTableDataUpdated = true;
                for (int j = 0; j < TextureAtlasSampler.MaxTextures; j++)
                {
                    if (this.isAtlasTextureUnits[j] == true)
                    {
                        //Update the information of the size of the atlas textures
                        //TODO: Replace -1, -1 with actual dimensions
                        var texSizeInt = new Math.Tuple <int, int>(-1, -1);
                        // = pass.GetTextureUnitState(j).Dimensions;
                        var texSize = new Vector2(texSizeInt.First, texSizeInt.Second);
                        this.psTextureSizes[j].SetGpuParameter(texSize);

                        //Update the information of which texture exists where in the atlas
                        GpuProgramParameters vsGpuParams = pass.VertexProgramParameters;
                        var buffer = new List <float>(this.atlasTableDatas[j].Count * 4);
                        for (int i = 0; i < this.atlasTableDatas[j].Count; i++)
                        {
                            buffer[i * 4]     = this.atlasTableDatas[j][i].posU;
                            buffer[i * 4 + 1] = this.atlasTableDatas[j][i].posV;
                            buffer[i * 4 + 2] =
                                (float)Axiom.Math.Utility.Log2((int)this.atlasTableDatas[j][i].width * (int)texSize.x);
                            buffer[i * 4 + 3] =
                                (float)Axiom.Math.Utility.Log2((int)this.atlasTableDatas[j][i].height * (int)texSize.y);
                        }
                        vsGpuParams.SetNamedConstant(this.vsTextureTable[j].Name, buffer.ToArray(),
                                                     this.atlasTableDatas[j].Count);
                    }
                }
            }
        }
コード例 #2
0
ファイル: ReflectionMap.cs プロジェクト: bostich83/axiom
        UpdateGpuProgramsParams(IRenderable rend, Pass pass, AutoParamDataSource source,
                                Core.Collections.LightList lightList)
        {
            if (this.reflectionPowerChanged)
            {
                GpuProgramParameters fsParams = pass.FragmentProgramParameters;

                this.reflectionPower.SetGpuParameter(this.reflectionPowerValue);
                this.reflectionPowerChanged = false;
            }
        }
コード例 #3
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;
            }
        }
コード例 #4
0
ファイル: FFPFog.cs プロジェクト: bostich83/axiom
        public override void UpdateGpuProgramsParams(IRenderable rend, Pass pass, AutoParamDataSource source,
                                                     Core.Collections.LightList lightList)
        {
            if (this.fogMode == FogMode.None)
            {
                return;
            }

            FogMode fMode;
            ColorEx newFogColor;
            Real    newFogStart, newFogEnd, newFogDensity;

            if (this.passOverrideParams)
            {
                fMode         = pass.FogMode;
                newFogColor   = pass.FogColor;
                newFogStart   = pass.FogStart;
                newFogEnd     = pass.FogEnd;
                newFogDensity = pass.FogDensity;
            }
            else
            {
                var sceneMgr = ShaderGenerator.Instance.ActiveSceneManager;

                fMode         = sceneMgr.FogMode;
                newFogColor   = sceneMgr.FogColor;
                newFogStart   = sceneMgr.FogStart;
                newFogEnd     = sceneMgr.FogEnd;
                newFogDensity = sceneMgr.FogDensity;
            }

            SetFogProperties(fMode, newFogColor, newFogStart, newFogEnd, newFogDensity);

            //Per pixel fog
            if (this.calcMode == CalcMode.PerPixel)
            {
                this.fogParams.SetGpuParameter(this.fogParamsValue);
            }

            //per vertex fog
            else
            {
                this.fogParams.SetGpuParameter(this.fogParamsValue);
            }

            this.fogColor.SetGpuParameter(this.fogColorValue);
        }
コード例 #5
0
ファイル: IntegratedPSSM3.cs プロジェクト: bostich83/axiom
        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);
        }
コード例 #6
0
ファイル: FFPLighting.cs プロジェクト: suntabu/axiom
        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);
                    }
                }
            }
        }
コード例 #7
0
 public virtual void UpdateGpuProgramsParams(Graphics.IRenderable rend, Graphics.Pass pass,
                                             Graphics.AutoParamDataSource source,
                                             Core.Collections.LightList lightList)
 {
 }