Esempio n. 1
0
 public void SetAlpha(Dx3D.Effect shader, Single alpha)
 {
     if (shader == _LightShader)
     {
         var color = shader.GetValueColor(shader.GetParameter(null, "materialDiffuseColor"));
         color.Alpha = alpha;
         shader.SetValue("materialDiffuseColor", color);
     }
 }
Esempio n. 2
0
        public void init(String filename)
        {
            mShader = ShaderManager.loadShader(filename, null);


            s_Quad = new D3DQuad(false);



            // call FxShader constructor

            mShader = ShaderManager.loadShader(filename, null);

            // init default parameters

            m_fxViewport          = mShader.GetParameter(null, "Viewport");
            m_fxDestRegionCoord   = mShader.GetParameter(null, "DestRegionCoord");
            m_fxDestRegionSize    = mShader.GetParameter(null, "DestRegionSize");
            m_fxInvDestRegionSize = mShader.GetParameter(null, "InvDestRegionSize");
            m_fxTechMain          = mShader.GetTechnique("t_main");

            mShader.Technique = m_fxTechMain;
        }
Esempio n. 3
0
        public void loadPrograms()
        {
            Macro [] defines = new Macro[16];
            int      nbdef;

            nbdef = 0;
            Synthesiser.addDefaultDefines(ref defines, ref nbdef);
            Synthesiser.endDefine(ref defines, ref nbdef);

            m_fxJacobian           = ShaderManager.loadShader(AppDomain.CurrentDomain.BaseDirectory + "shaders\\jacobian.fx", null);
            m_fxJacobianClearTech  = m_fxJacobian.GetTechnique("t_identity");
            m_fxJacobianSelectTech = m_fxJacobian.GetTechnique("t_selected");
            m_fxGeomPaintJMapTech  = m_fxJacobian.GetTechnique("t_paint_jmap");

            m_fxJacobianViewport     = m_fxJacobian.GetParameter(null, "Viewport");
            m_fxJacobianGlobalScale  = m_fxJacobian.GetParameter(null, "GlobalScale");
            m_fxJacobianSelectedJMap = m_fxJacobian.GetParameter(null, "SelectedJMap");

            m_fxGeomGlobalScale           = m_fxJacobian.GetParameter(null, "GlobalScale");
            m_fxGeomPaintedJMap           = m_fxJacobian.GetParameter(null, "PaintedJMap");
            m_fxGeomExemplarMainDirection = m_fxJacobian.GetParameter(null, "ExemplarMainDirection");
        }
Esempio n. 4
0
        /// <summary>
        /// Inizializza l'effetto avanzato Water (da utilizzare all'esterno del GameLoop)
        /// </summary>
        /// <param name="baseTex"></param>
        /// <param name="backTex"></param>
        /// <param name="normal1Tex"></param>
        /// <param name="worldTex"></param>
        /// <param name="terraIncognitaTex"></param>
        /// <param name="normal2Tex"></param>
        /// <param name="normal3Tex"></param>
        public void WaterEffect(string baseTex, string backTex, string normal1Tex, string worldTex, string terraIncognitaTex, string normal2Tex, string normal3Tex)
        {
            try
            {
                EffectPool pool = new EffectPool();
                Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "Water.fx", null, ShaderFlags.None, pool);
                EffectHandles = new EffectHandle[16];
                EffectTechniques = new EffectHandle[1];
                EffectTechniques[0] = Effect.GetTechnique("Water");
                EffectHandles[0] = Effect.GetParameter(null, "matWorldViewProjection");
                EffectHandles[1] = Effect.GetParameter(null, "LightPosition");
                EffectHandles[2] = Effect.GetParameter(null, "CameraPosition");
                EffectHandles[3] = Effect.GetParameter(null, "Time");
                EffectHandles[4] = Effect.GetParameter(null, "vAlpha");
                EffectHandles[5] = Effect.GetParameter(null, "Wave");
                EffectHandles[6] = Effect.GetParameter(null, "waveSpeed");
                EffectHandles[7] = Effect.GetParameter(null, "WaveLenght");
                EffectHandles[8] = Effect.GetParameter(null, "TexturesDimension");
                EffectHandles[9] = Effect.GetParameter(null, "BaseTex");
                EffectHandles[10] = Effect.GetParameter(null, "BackTex");
                EffectHandles[11] = Effect.GetParameter(null, "Normal1Tex");
                EffectHandles[12] = Effect.GetParameter(null, "WorldTex");
                EffectHandles[13] = Effect.GetParameter(null, "TerraIncognitaTex");
                EffectHandles[14] = Effect.GetParameter(null, "Normal2Tex");
                EffectHandles[15] = Effect.GetParameter(null, "Normal3Tex");

                BaseTextures = new BaseTexture[7];
                BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTex);
                BaseTextures[1] = TextureLoader.FromFile(LogiX_Engine.Device, backTex);
                BaseTextures[2] = TextureLoader.FromFile(LogiX_Engine.Device, normal1Tex);
                BaseTextures[3] = TextureLoader.FromFile(LogiX_Engine.Device, worldTex);
                BaseTextures[4] = TextureLoader.FromFile(LogiX_Engine.Device, terraIncognitaTex);
                BaseTextures[5] = TextureLoader.FromFile(LogiX_Engine.Device, normal2Tex);
                BaseTextures[6] = TextureLoader.FromFile(LogiX_Engine.Device, normal3Tex);

                correct = true;
            }
            catch
            {
                Error("OnCreateObject");
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Inizializza l'effetto avanzato Glass (da utilizzare all'esterno del GameLoop)
        /// </summary>
        /// <param name="cubeMap"></param>
        public void GlassEffect(CubeMap cubeMap)
        {
            try
            {
                EffectPool pool = new EffectPool();
                Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "MEDIA//Glass.fx", null, ShaderFlags.None, pool);
                EffectHandles = new EffectHandle[10];
                EffectTechniques = new EffectHandle[1];
                EffectTechniques[0] = Effect.GetTechnique("Glass");
                EffectHandles[0] = Effect.GetParameter(null, "matViewProjection");
                EffectHandles[1] = Effect.GetParameter(null, "PointOfView");
                EffectHandles[2] = Effect.GetParameter(null, "refractionScale");
                EffectHandles[3] = Effect.GetParameter(null, "baseColor");
                EffectHandles[4] = Effect.GetParameter(null, "ambient");
                EffectHandles[5] = Effect.GetParameter(null, "indexOfRefractionRatio");
                EffectHandles[6] = Effect.GetParameter(null, "reflectionScale");
                EffectHandles[7] = Effect.GetParameter(null, "texCube");
                EffectHandles[8] = Effect.GetParameter(null, "alpha");
                EffectHandles[9] = Effect.GetParameter(null, "matWorld");

                CubeTextures = new CubeTexture[1];
                CubeTextures[0] = cubeMap.DXCubeTexture;

                correct = true;
            }
            catch
            {
                Error("OnCreateObject");
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Inizializza un effetto base tra quelli possibili (definiti da LogiX_Technologies.XEffects). Da utilizzare all'esterno del GameLoop
 /// </summary>
 /// <param name="baseTexturePath"></param>
 /// <param name="normalTexturePath"></param>
 /// <param name="cubeMap"></param>
 /// <param name="DefaultEffects"></param>
 public void DefaultEffect(string baseTexturePath, string normalTexturePath, CubeMap cubeMap, XEffects DefaultEffects)
 {
     switch (DefaultEffects)
     {
         case XEffects.PerPixelDirectionalLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "PerPixelDirectionalLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[8];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("t0");
                 EffectHandles[0] = Effect.GetParameter(null, "transform");
                 EffectHandles[1] = Effect.GetParameter(null, "world");
                 EffectHandles[2] = Effect.GetParameter(null, "LightDirection");
                 EffectHandles[3] = Effect.GetParameter(null, "ViewDirection");
                 EffectHandles[4] = Effect.GetParameter(null, "base_Tex");
                 EffectHandles[5] = Effect.GetParameter(null, "Specular");
                 EffectHandles[6] = Effect.GetParameter(null, "Diffuse");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 BaseTextures = new BaseTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.PerPixelPointLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, Application.StartupPath + "/PerPixelPointLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[11];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("PerPixelLightning");
                 EffectHandles[0] = Effect.GetParameter(null, "World");
                 EffectHandles[1] = Effect.GetParameter(null, "View");
                 EffectHandles[2] = Effect.GetParameter(null, "Projection");
                 EffectHandles[3] = Effect.GetParameter(null, "LightPosition");
                 EffectHandles[4] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[5] = Effect.GetParameter(null, "SpecularRatio");
                 EffectHandles[6] = Effect.GetParameter(null, "SpecularStyleLerp");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 EffectHandles[8] = Effect.GetParameter(null, "LightColor");
                 EffectHandles[9] = Effect.GetParameter(null, "MyTex_Tex");
                 EffectHandles[10] = Effect.GetParameter(null, "myCubemap_Tex");
                 BaseTextures = new BaseTexture[1];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.BumpPerPixelPointLight:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, Application.StartupPath + "PerPixelPointLight.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[12];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("PerPixelLightning");
                 EffectHandles[0] = Effect.GetParameter(null, "World");
                 EffectHandles[1] = Effect.GetParameter(null, "View");
                 EffectHandles[2] = Effect.GetParameter(null, "Projection");
                 EffectHandles[3] = Effect.GetParameter(null, "LightPosition");
                 EffectHandles[4] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[5] = Effect.GetParameter(null, "SpecularRatio");
                 EffectHandles[6] = Effect.GetParameter(null, "SpecularStyleLerp");
                 EffectHandles[7] = Effect.GetParameter(null, "SpecularPower");
                 EffectHandles[8] = Effect.GetParameter(null, "LightColor");
                 EffectHandles[9] = Effect.GetParameter(null, "MyTex_Tex");
                 EffectHandles[10] = Effect.GetParameter(null, "MyNTex_Tex");
                 EffectHandles[11] = Effect.GetParameter(null, "myCubemap_Tex");
                 BaseTextures = new BaseTexture[2];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, baseTexturePath);
                 BaseTextures[1] = TextureLoader.FromFile(LogiX_Engine.Device, normalTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
         case XEffects.Reflect:
             try
             {
                 EffectPool pool = new EffectPool();
                 Effect = Microsoft.DirectX.Direct3D.Effect.FromFile(LogiX_Engine.Device, "Reflect.fx", null, ShaderFlags.None, pool);
                 EffectHandles = new EffectHandle[7];
                 EffectTechniques = new EffectHandle[1];
                 EffectTechniques[0] = Effect.GetTechnique("Textured_Bump");
                 EffectHandles[0] = Effect.GetParameter(null, "fvEyePosition");
                 EffectHandles[1] = Effect.GetParameter(null, "matView");
                 EffectHandles[2] = Effect.GetParameter(null, "matViewProjection");
                 EffectHandles[3] = Effect.GetParameter(null, "ReflectionRatio");
                 EffectHandles[4] = Effect.GetParameter(null, "bump_Tex");
                 EffectHandles[5] = Effect.GetParameter(null, "cube_Tex");
                 EffectHandles[6] = Effect.GetParameter(null, "Bump");
                 BaseTextures = new BaseTexture[1];
                 CubeTextures = new CubeTexture[1];
                 BaseTextures[0] = TextureLoader.FromFile(LogiX_Engine.Device, normalTexturePath);
                 CubeTextures[0] = cubeMap.DXCubeTexture;
                 correct = true;
             }
             catch
             {
                 Error("OnCreateObject");
             }
             break;
     }
 }