public void Test() { var device = GraphicsDevice.New(); // Compile a toolkit effect from a file var result = EffectCompiler.CompileFromFile("toto.fx"); // Check that we don't have any errors Assert.False(result.HasErrors); var bytecode = result.EffectData; var effect = new Effect(device, bytecode); var tex1 = TextureCube.New(device, 64, PixelFormat.R8.UNorm); var samplerState = device.SamplerStates.PointWrap; effect.Parameters["SkyBoxTexture"].SetResource(tex1); effect.Parameters["SkyBoxSampler"].SetResource(samplerState); effect.Techniques[0].Passes[0].Apply(); Console.WriteLine(effect.Parameters.Count); effect.Dispose(); device.Dispose(); }
/// <inheritdoc/> protected override void OnEntityAdding(Entity entity, CubemapSourceComponent data) { base.OnEntityAdding(entity, data); if (data.IsDynamic) { // TODO: move texture creation when it is actually needed (first time use)? data.Texture = TextureCube.New(graphicsDevice, data.Size, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget); } }
/// <inheritdoc/> protected override void OnEntityAdding(Entity entity, CubemapBlendComponent data) { base.OnEntityAdding(entity, data); data.Texture = TextureCube.New(graphicsDevice, data.Size, 1, PixelFormat.R8G8B8A8_UNorm, TextureFlags.ShaderResource | TextureFlags.RenderTarget); // add parameter to model var model = entity.Get <ModelComponent>(); if (model != null) { model.Parameters.Set(data.TextureKey ?? TexturingKeys.TextureCube0, data.Texture); } }