} // Load() /// <summary> /// Load an effect from an hlsl .fx file /// </summary> protected void LoadFromFXFile(System.IO.Stream strm, EffectPool pool) { CompiledEffect compiledEffect; using (var reader = new System.IO.StreamReader(strm)) { string source = reader.ReadToEnd(); compiledEffect = Effect.CompileEffectFromSource(source, null, includeHandler, CompilerOptions.Debug, TargetPlatform.Windows); } if (compiledEffect.Success == false) { Console.WriteLine("Shader compile error in BasicShader. Error message is as follows:\n" + compiledEffect.ErrorsAndWarnings); if (effect == null) { throw new Exception("Failed to compile shader. Error message is as follows:\n" + compiledEffect.ErrorsAndWarnings); } return; } // Dispose old shader if (effect != null) { effect.Dispose(); effect = null; } effect = new Effect(game.GraphicsDevice, compiledEffect.GetEffectCode(), CompilerOptions.None, pool); LoadParameters(); //return shader; } // Load()
public GameObject GetEffect(EffectType type, int nIdx) { EffectPool pool = m_effectPools[type][nIdx]; if (pool == null) { return(null); } if (pool.pooledList.Count < 1) { if (m_canBeGrow) { GameObject newEffect = Instantiate(pool.prefab); newEffect.name = pool.prefab.name; return(newEffect); } else { return(null); } } GameObject outPut = pool.pooledList.Pop(); outPut.transform.parent = null; //outPut.SetActive(true); return(outPut); }
/// <summary>compile and load an effect from a string containing effect code</summary> private Effect LoadContentRuntimeString(string content, string name) { Effect reffect = null; try { // ForcePixelShaderSoftwareNoOptimizations gives wrong answers // SkipOptimizations makes the variable size convolution work, but at what cost?? CompilerOptions copts = CompilerOptions.SkipOptimization; // | CompilerOptions.AvoidFlowControl; CompiledEffect compiledEffect = Effect.CompileEffectFromSource(content, null, null, copts, TargetPlatform.Windows); if (compiledEffect.Success) { EffectPool effectPool = new EffectPool(); reffect = new Effect(graphicsDevice, compiledEffect.GetEffectCode(), CompilerOptions.None, effectPool); } else { System.Windows.Forms.MessageBox.Show("Error in dynamic shader " + name + ". Previous version will be used.\n\n" + compiledEffect.ErrorsAndWarnings); } } catch (Exception e) { System.Windows.Forms.MessageBox.Show("Unexpected error in dynamic shader " + name + ". Previous version will be used.\n\n" + e); } return(reffect); }
public void CreateGraphicsContext(int deviceWidth, int deviceHeight) { GraphicsDeviceManager m_Manager = new GraphicsDeviceManager(game); m_Manager.PreferredBackBufferWidth = deviceWidth; m_Manager.PreferredBackBufferHeight = deviceHeight; if (m_XNA_GraphicsDevice != null) { return(false); } //create an XNA graphics device m_XNA_GraphicsDevice = m_Manager.GraphicsDevice(); //check if graphics device was created Debug.Assert(m_XNA_GraphicsDevice != null, "XNA Graphics Device did not Initialize"); m_EffectPool = new EffectPool(); m_BasicEffect = new BasicEffect(m_XNA_GraphicsDevice, m_EffectPool); //set the model matrix to identity m_BasicEffect.World = Matrix.Identity; m_BasicEffect.View = Matrix.Identity; m_BasicEffect.Projection = Matrix.Identity; m_XNA_GraphicsDevice.RenderState.DepthBufferEnable = true; m_XNA_GraphicsDevice.RenderState.DepthBufferWriteEnable = true; return(true); }
public static void GiveArtifactTo(PlayerMobile pm) { Item item = (Item)Activator.CreateInstance(Artifacts[Utility.Random(Artifacts.Length)]); bool message = true; if (!pm.AddToBackpack(item)) { Container bank = pm.BankBox; if (!(bank != null && bank.TryDropItem(pm, item, false))) { pm.SendLocalizedMessage(1072523, "", 64); // You find an artifact, but your backpack and bank are too full to hold it. message = false; item.MoveToWorld(pm.Location, pm.Map); } } if (message) { pm.SendLocalizedMessage(1062317, "", 64); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. } EffectPool.ArtifactDrop(pm); pm.DoomCredits = 0; }
public void Hit(float value) { mCurrentHp -= value; if (mCurrentHp <= 0) { if (mEffectpool == null) { mEffectpool = GameObject.FindGameObjectWithTag("EffectPool"). GetComponent <EffectPool>(); } Timer effect = mEffectpool.GetFromPool((int)eEffecttype.Enmey); effect.transform.position = transform.position; if (mSoundController == null) { mSoundController = GameObject.FindGameObjectWithTag("SoundController"). GetComponent <SoundController>(); } mSoundController.PlayEffectSound((int)eSoundType.ExpEnem); mGameController.AddScore(10); gameObject.SetActive(false); } }
void EffectPoolCreate(Transform parent, EffectType type, Data.EffectContainier containier) { m_effectPools[type] = new Dictionary <int, EffectPool>(); for (int i = 0; i < containier.GetEffectCount(type); i++) { GameObject prefab = containier.GetEffects(type, i); if (prefab != null) { EffectPool pool = new EffectPool(); pool.prefab = prefab; pool.nBufferAmount = m_effectAmount; pool.pooledList = new Stack <GameObject>(); for (int j = 0; j < pool.nBufferAmount; j++) { GameObject poolObj = Instantiate(prefab); poolObj.name = prefab.name; poolObj.transform.parent = parent; poolObj.SetActive(false); pool.pooledList.Push(poolObj); } m_effectPools[type].Add(i, pool); } } }
public void TestBeginEnd() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { #if XNA_4 using (BasicEffect effect = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); for (int pass = 0; pass < test.Passes; ++pass) { test.Apply(pass); } } #else using (EffectPool pool = new EffectPool()) { using (BasicEffect effect = new BasicEffect(service.GraphicsDevice, pool)) { TestEffectDrawContext test = new TestEffectDrawContext(effect); test.Begin(); try { for (int pass = 0; pass < test.Passes; ++pass) { test.BeginPass(pass); test.EndPass(); } } finally { test.End(); } } } #endif } }
public void TestEqualsWithDifferentObject() { MockedGraphicsDeviceService service = new MockedGraphicsDeviceService(); using (IDisposable keeper = service.CreateDevice()) { #if XNA_4 using (BasicEffect effect1 = new BasicEffect(service.GraphicsDevice)) { using (BasicEffect effect2 = new BasicEffect(service.GraphicsDevice)) { TestEffectDrawContext test1 = new TestEffectDrawContext(effect1); TestEffectDrawContext test2 = new TestEffectDrawContext(effect2); Assert.IsFalse(test1.Equals((object)test2)); } } #else using (EffectPool pool = new EffectPool()) { using (BasicEffect effect1 = new BasicEffect(service.GraphicsDevice, pool)) { using (BasicEffect effect2 = new BasicEffect(service.GraphicsDevice, pool)) { TestEffectDrawContext test1 = new TestEffectDrawContext(effect1); TestEffectDrawContext test2 = new TestEffectDrawContext(effect2); Assert.IsFalse(test1.Equals((object)test2)); } } } #endif } }
/// <summary>Create an effect from a file</summary> public Effect CreateEffectFromFile(Device device, string filename, Macro[] defines, Include includeFile, ShaderFlags flags, EffectPool effectPool, int instanceId, out string errors) { // No errors at first! errors = string.Empty; // Search the cache first foreach (CachedEffect ce in effectCache.Keys) { if ((string.Compare(ce.Source, filename, true) == 0) && (ce.Flags == flags) && (ce.InstanceId == instanceId)) { // A match was found, return that return(effectCache[ce] as Effect); } } // Nothing found in the cache Effect e = Effect.FromFile(device, filename, defines, includeFile, null, flags, effectPool, out errors); // Add this to the cache CachedEffect entry = new CachedEffect(); entry.Flags = flags; entry.Source = filename; entry.InstanceId = instanceId; effectCache.Add(entry, e); //if (!string.IsNullOrEmpty(errors)) // System.Windows.Forms.MessageBox.Show(errors); // Return the new effect return(e); }
public DataControl(Device device, EffectPool pool) { meshInf = new List <MeshInformation>(); shaderPool = pool; dev = device; entities = new List <Entity>(); }
/// <summary> /// Load an effect from an hlsl .fx file /// </summary> public static BasicShader LoadFromFXFile(IXNAGame game, IGameFile file, EffectPool pool) { BasicShader s = new BasicShader(game); s.LoadFromFXFile(file, pool); return(s); }
public void Initialize(IXNAGame _game) { VertexDeclaration = Renderer.GetVertexDeclaration <TangentVertex>(); effectPool = new EffectPool(); Shader = new DefaultModelShader(_game, effectPool); }
void Awake() { mRB = GetComponent <Rigidbody>(); mSoundController = GameObject.FindGameObjectWithTag("SoundController"). GetComponent <SoundController>(); mEffectPool = GameObject.FindGameObjectWithTag("EffectPool"). GetComponent <EffectPool>(); }
public EffectParamsGeneric GetEffect(string key) { EffectPool pool = this.GetPool(key); EffectParamsGeneric effectParamsGeneric = pool.Rent(); effectParamsGeneric.InitializeFast(BattleEffectManager._camera); return(effectParamsGeneric); }
private void Awake() { mRB = GetComponent <Rigidbody>(); GameObject effectPool = GameObject.FindGameObjectWithTag("EffectPool"); //가져와서 넣어줌. mEffectPool = effectPool.GetComponent <EffectPool>(); mGameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); }
/// <summary> /// Initializes a new instance of the <see cref="BasicEffect" /> class from a specified <see cref="EffectPool"/>. /// </summary> /// <param name="device">The device.</param> /// <param name="pool">The pool.</param> public BasicEffect(GraphicsDevice device, EffectPool pool) : base(device, effectBytecode, pool) { DirectionalLight0.Enabled = true; SpecularColor = Vector3.One; SpecularPower = 16; }
// Start is called before the first frame update void Start() { mRB = GetComponent <Rigidbody>(); GameObject effectPool = GameObject.FindGameObjectWithTag("EffectPool"); //가져와서 넣어줌. mEffectPool = effectPool.GetComponent <EffectPool>(); //mGameController = GameObject.FindGameObjectWithTag("GameController").GetComponent<GameController>(); mSoundController = GameObject.FindGameObjectWithTag("SoundController").GetComponent <SoundController>(); }
void Start() { mRB = GetComponent <Rigidbody>(); mCurrentFireLate = mFireLate; GameObject effectPool = GameObject.FindGameObjectWithTag("EffectPool"); //가져와서 넣어줌. mEffectPool = effectPool.GetComponent <EffectPool>(); mGameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>(); }
private void RemoveEffectPool(EffectPool effectPool) { effectPool.EffectAdded -= effectPool_EffectAdded; effectPool.EffectRemoved -= effectPool_EffectRemoved; foreach (var registeredEffect in effectPool.RegisteredEffects) { RemoveEffect(registeredEffect); } }
private void AddEffectPool(EffectPool effectPool) { foreach (var registeredEffect in effectPool.RegisteredEffects) { AddEffect(registeredEffect); } effectPool.EffectAdded += effectPool_EffectAdded; effectPool.EffectRemoved += effectPool_EffectRemoved; }
public void TestCompiler() { var device = GraphicsDevice.New(); // Compile a toolkit effect from a file var result = new EffectCompiler().CompileFromFile("TestEffect.fx"); // Check that we don't have any errors Assert.False(result.HasErrors); var bytecode = result.EffectData; // Check that the name of this effect is the file name Assert.AreEqual(bytecode.Description.Name, "TestEffect"); // We have 3 shaders compiled: VS, VS2, PS Assert.AreEqual(bytecode.Shaders.Count, 3); // Check that this is the profile 10.0 Assert.AreEqual(bytecode.Shaders[0].Level, FeatureLevel.Level_10_0); // Create a EffectData pool from a single EffectData var effectGroup = EffectPool.New(device); //var effect = effectGroup.New<BasicEffect>(); var effect = new Effect(device, bytecode, effectGroup); //Texture2D tex : register(t0); //Texture2D tex1 : register(t2); //Texture2D tex2 : register(t3); //Texture2D tex3 : register(t10); //SamplerState samp; var tex = Texture2D.New(device, 256, 256, PixelFormat.R8.UNorm); var tex1 = Texture2D.New(device, 256, 256, PixelFormat.R8.UNorm); var tex2 = Texture2D.New(device, 256, 256, PixelFormat.R8.UNorm); var tex3 = Texture2D.New(device, 256, 256, PixelFormat.R8.UNorm); var samplerState = device.SamplerStates.PointWrap; effect.Parameters["tex"].SetResource(tex); effect.Parameters["tex1"].SetResource(tex1); effect.Parameters["tex2"].SetResource(tex2); effect.Parameters["tex3"].SetResource(tex3); effect.Parameters["worldViewProj"].SetValue(Matrix.Identity); effect.Parameters["samp"].SetResource(samplerState); //effect.Parameters["World"].SetValue(Vector3.Zero); //effect.Parameters["Tata"].SetResource(texture); effect.Techniques[0].Passes[0].Apply(); Console.WriteLine(effect.Parameters.Count); effect.Dispose(); device.Dispose(); }
private void Awake() { mRB = GetComponent <Rigidbody>(); GameObject controlObj = GameObject.FindGameObjectWithTag("GameController"); gameController = controlObj.GetComponent <GameController>(); soundController = gameController.GetSoundController(); GameObject effectObj = GameObject.FindGameObjectWithTag("EffectPool"); effect = effectObj.GetComponent <EffectPool>(); }
private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } }
/// <summary> /// 添加特效 /// </summary> /// <returns></returns> public bool add(EffectPool obj) { if (_effects.ContainsKey(obj.getName())) { return(false); } _effects.Add(obj.getName(), obj); return(true); }
/// <summary> /// 添加特效 /// </summary> /// <returns></returns> public bool add(EffectPool obj) { if (_effects.ContainsKey(obj.getName())) { return false; } _effects.Add(obj.getName(), obj); return true; }
// Start is called before the first frame update void Start() { currentFireTimer = 0; currentChargeValue = 0; mRB = GetComponent <Rigidbody>(); effect = GameObject.FindGameObjectWithTag("EffectPool").GetComponent <EffectPool>(); GameObject controlObj = GameObject.FindGameObjectWithTag("GameController"); gameController = controlObj.GetComponent <GameController>(); soundController = gameController.GetSoundController(); }
void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); } }
void Awake() { mRB = GetComponent <Rigidbody>(); mRB.velocity = Vector3.back * Speed; GameObject effectObj = GameObject.FindGameObjectWithTag("EffectPool"); effect = effectObj.GetComponent <EffectPool>(); GameObject controller = GameObject.FindGameObjectWithTag("GameController"); gameController = controller.GetComponent <GameController>(); soundController = gameController.GetSoundController(); }
private void Start() { pool = new EffectPool( prefab, transform, effect => { effect.gameObject.SetActive(true); effect.SetFloat(IntensityProperty, currentIntensity); }, effect => effect.gameObject.SetActive(false), 9); }
private void Awake() { mRB = GetComponent <Rigidbody>(); mRB.velocity = Vector3.back * Speed; GameObject effectObj = GameObject.FindGameObjectWithTag("EffectPool"); effect = effectObj.GetComponent <EffectPool>(); GameObject controller = GameObject.FindGameObjectWithTag("GameController"); gameController = controller.GetComponent <GameController>(); soundController = gameController.GetSoundController(); //Random.Range(3.0f, 6.0f) - 랜덤 스피는 주는 방법 (인트형이랑 플롯형 2가지가 있으며 random.randomrange는 구버전의 라이브러리로 지금은 안씀 } // unity execution order를 구글에 치면 관련 정보를 얻을 수 있다.
public CieloStellato() { model = new Model("MEDIA//satellite.x", 0); EffectPool pool = new EffectPool(); effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//NightSky.fx", null, ShaderFlags.None, pool); effectHandles = new EffectHandle[6]; effectHandles[0] = effect.GetTechnique("t0"); effectHandles[1] = effect.GetParameter(null, "matViewProjection"); effectHandles[2] = effect.GetParameter(null, "Time"); effectHandles[3] = effect.GetParameter(null, "BaseTexture"); effectHandles[4] = effect.GetParameter(null, "NoiseTexture"); effectHandles[5] = effect.GetParameter(null, "TexDimension"); baseTexture = new BaseTexture[2]; baseTexture[0] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//StarMap1.jpg"); baseTexture[1] = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//Noise.jpg"); }
/// <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"); } }
public void CreaAnelli(XTexture TextureBase, XTexture TexturePattern) { anelli = new Model("MEDIA\\ring.x", 0); textureAnelli = TextureBase; textureAnelliPattern = TexturePattern; EffectPool pool = new EffectPool(); effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA\\anelli.fx", null, ShaderFlags.None, pool); effectHandles = new EffectHandle[5]; effectHandles[0] = effect.GetTechnique("t0"); effectHandles[1] = effect.GetParameter(null, "matViewProjection"); effectHandles[2] = effect.GetParameter(null, "matWorld"); effectHandles[3] = effect.GetParameter(null, "colorTex"); effectHandles[4] = effect.GetParameter(null, "alphaTex"); }
/// <summary> /// Creates a new DualTextureEffect with default parameter settings from a specified <see cref="EffectPool"/>. /// </summary> public DualTextureEffect(GraphicsDevice device, EffectPool pool) : base(device, effectBytecode, pool) { }
/// <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; } }
/// <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"); } }
public Sole() { model = new Model("MEDIA//Sfera5.x", 0); EffectPool pool = new EffectPool(); effect = Effect.FromFile(LogiX_Engine.Device, "MEDIA//Sun.fx", null, ShaderFlags.None, pool); effectHandles = new EffectHandle[5]; effectHandles[0] = effect.GetTechnique("t0"); effectHandles[1] = effect.GetParameter(null, "matViewProjection"); effectHandles[2] = effect.GetParameter(null, "Time"); effectHandles[3] = effect.GetParameter(null, "Texture"); effectHandles[4] = effect.GetParameter(null, "TexDimension"); baseTexture = TextureLoader.FromFile(LogiX_Engine.Device, "MEDIA//N030.jpg"); Alone = new XMaterial(Color.White, Color.White, Color.Black, 1); light = new DirectionalLight(VertexData.Empty, Color.FromArgb(60, 10, 0), Color.FromArgb(255, 170, 100), Color.FromArgb(250, 250, 250)); }
// Use this for initialization void Awake () { sInstance = this; CreatePool (); }
/// <summary>Create an effect from a file</summary> public Effect CreateEffectFromFile(Device device, string filename, Macro[] defines, Include includeFile, ShaderFlags flags, EffectPool effectPool) { string temp; return CreateEffectFromFile(device, filename, defines, includeFile, flags, effectPool, out temp); }
/// <summary> /// 加载技能所需要的特效 /// </summary> private void loadSkllResource() { foreach(int key in _skillData.Effect.Keys) { if (!EffectsManager.getInstance().hasEffect(_skillData.Effect[key].getEffectName())) { GameObject effect = Resources.Load<GameObject>(_skillData.Effect[key].getEffectName()); // 设置pool name 和存放的对象 EffectPool pool = new EffectPool( effect); EffectsManager.getInstance().add(pool); } } }
/// <summary> /// Creates a new AlphaTestEffect with default parameter settings from a specified <see cref="EffectPool"/>. /// </summary> public AlphaTestEffect(GraphicsDevice device, EffectPool pool) : base(device, effectBytecode, pool) { }
/// <summary> /// Initializes a new instance of the <see cref="BasicEffect" /> class from a specified <see cref="EffectPool"/>. /// </summary> /// <param name="device">The device.</param> /// <param name="pool">The pool.</param> public BasicEffect(GraphicsDevice device, EffectPool pool) : base(device, pool, BasicEffectName) { CacheEffectParameters(null); DirectionalLight0.Enabled = true; SpecularColor = Vector3.One; SpecularPower = 16; }
/// <summary> /// Creates a new DualTextureEffect with default parameter settings from a specified <see cref="EffectPool"/>. /// </summary> public DualTextureEffect(GraphicsDevice device, EffectPool pool) : base(device, pool, DualTextureEffectName) { CacheEffectParameters(); }
/// <summary>Create an effect from a file</summary> public Effect CreateEffectFromFile(Device device, string filename, Macro[] defines, Include includeFile, ShaderFlags flags, EffectPool effectPool, out string errors) { // No errors at first! errors = string.Empty; // Search the cache first foreach(CachedEffect ce in effectCache.Keys) { if ( (string.Compare(ce.Source, filename, true) == 0) && ce.Flags == flags) { // A match was found, return that return effectCache[ce] as Effect; } } // Nothing found in the cache Effect e = Effect.FromFile(device, filename, defines, includeFile, null, flags, effectPool, out errors); // Add this to the cache CachedEffect entry = new CachedEffect(); entry.Flags = flags; entry.Source = filename; effectCache.Add(entry, e); // Return the new effect return e; }