public RotateWidgetRenderableAsset(IGraphicsContext context) { _texture = context.LoadTexture2D("RotationWidget"); _boundingBox = new AxisAlignedBoundingBox2D(0, 0, _texture.Height, _texture.Width); RenderingOffset = - _boundingBox.Center; Origin = _boundingBox.Center; }
public FreeMovementRenderableAsset(IGraphicsContext context) { _texture = context.LoadTexture2D("freeMovementWidget"); _boundingBox = new AxisAlignedBoundingBox2D(0, 0, _texture.Height, _texture.Width); RenderingOffset = -AABoundingBox.Center; Origin = AABoundingBox.Center; }
public PerformanceSpriteNode( ITexture2D texture ) : base(texture) { rotateUnit = ( ( float ) ( random.NextDouble () - random.NextDouble () ) ) * 10.0f; World.RotationCenter = texture.Size () / 2; World.Translate = new Vector2 ( random.Next ( 800 ), random.Next ( 600 ) ); }
public Sprite( ITexture2D texture, IEffect effect ) { if ( effect == null ) { if ( baseSpriteEffect == null ) baseSpriteEffect = new SpriteEffect (); effect = baseSpriteEffect; } if ( projectionMatrix == null ) projectionMatrix = new OrthographicOffCenterProjection ( 0, 800, 600, 0, 0.001f, 1000.0f ); Effect = effect; if ( vertexDeclaration == null ) { vertexDeclaration = Core.GraphicsDevice.CreateVertexDeclaration ( Utilities.CreateVertexElementArray<SpriteVertex> () ); } indexReference++; vertexBuffer = Core.GraphicsDevice.CreateBuffer ( BufferType.VertexBuffer, typeof ( SpriteVertex ), 4 ); textureArgument = new SamplerState ( texture, Graphics.TextureFilter.Nearest, TextureAddressing.Clamp, 0 ); Reset ( texture ); innerWorld = new World2(); }
public static void AddJob(ITexture2D tex2D, string ReplacingImage, int WhichGame, string pathBIOGame) { if (JobList.Count == 0) Initialise(); ModJob job = ModMaker.CreateTextureJob(tex2D, ReplacingImage, WhichGame, pathBIOGame); JobList.Add(job); }
public Sprite( ITexture2D texture, IEffect effect ) { if ( effect == null ) { if ( baseSpriteEffect == null ) baseSpriteEffect = new SpriteEffect (); effect = baseSpriteEffect; } Texture = texture; Effect = effect; int width = 1, height = 1; if ( texture != null ) { width = texture.Width; height = texture.Height; } vertexBuffer = LiqueurSystem.GraphicsDevice.CreateVertexBuffer<SpriteVertex> ( SpriteVertexFormat, new SpriteVertex [] { new SpriteVertex ( new Vector2 ( 0.001f, 0.001f ), Color.White, new Vector2 ( 0.001f, 0.001f ) ), new SpriteVertex ( new Vector2 ( width, 0.001f ), Color.White, new Vector2 ( 1, 0.001f ) ), new SpriteVertex ( new Vector2 ( 0.001f, height ), Color.White, new Vector2 ( 0.001f, 1 ) ), new SpriteVertex ( new Vector2 ( width, height ), Color.White, new Vector2 ( 1, 1 ) ), } ); if ( indexBuffer == null ) indexBuffer = LiqueurSystem.GraphicsDevice.CreateIndexBuffer ( new int [] { 0, 1, 2, 1, 3, 2 } ); indexReference++; clippingArea = new Rectangle ( 0, 0, width, height ); TextureFilter = Liqueur.Graphics.TextureFilter.Nearest; }
public void Set(ITexture2D resource) { this.resource.Target = resource; if (vertexIndex != -1) video.currentVertexTextures[vertexIndex] = (Texture2D)resource; if (pixelIndex != -1) video.currentPixelTextures[pixelIndex] = (Texture2D)resource; Apply = setTexture2D; }
public SpriteNode( ITexture2D texture ) { sprite = new Sprite ( texture ); World = World2.Identity; tempWorld = World2.Identity; Alignment = SpriteAlignment.LeftTop; }
public override void Intro( params object [] args ) { bulletImage = ( Parent as GameScene ).Contents.Load<ITexture2D> ( "Resources/Dodge/bullet.png", Color.Magenta); for ( int i = 0; i < 128; i++ ) Add ( new Bullet ( bulletImage ) ); base.Intro ( args ); }
public void Set(ITexture2D resource) { var texture = (Texture2D)resource; video.currentTextures[index] = texture; resourceIndex = texture.Texture; this.texture = new WeakReference(texture); Apply = setTexture2D; }
public void Dispose() { if (null != myTexture) { myTexture.Dispose(); myTexture = null; } }
public void InitializeTexture(ITexture2D texture) { if (data.Length < texture.Width * texture.Height * 4) data = Enumerable.Range(0, texture.Width * texture.Height * 4).Select(x => (byte)255).ToArray(); for (int i = 0; i < texture.MipCount; i++) texture.SetData(0, data, FormatColor.Bgra, FormatType.UnsignedByte); }
public SpriteSheetTexture(ITexture2D spriteSheet, Rectangle sourceRectangle) { if (spriteSheet == null) throw new ArgumentNullException("spriteSheet"); SpriteEffects = SpriteEffects.None; this.sourceRectangle = sourceRectangle; this.spriteSheet = spriteSheet; Color = Color.White; }
public Particle2D( ITexture2D texture, Vector2 position, Vector2 velocity, float angle, float angularVelocity, Color overlayColor, float size, TimeSpan ttl ) { sprite = new Sprite ( texture ); world = new World2 ( position, new Vector2 ( size ), texture.Size () / 2, angle, texture.Size () / 2 ); sprite.OverlayColor = overlayColor; Velocity = velocity; AngularVelocity = angularVelocity; TTL = ttl; }
public FadeTransitor( Color fadeColor, float fadeUnit ) { FadeColor = fadeColor; FadeUnit = fadeUnit; fadeTexture = Core.GraphicsDevice.CreateTexture2D ( 1, 1 ); fadeTexture.Buffer = new Color [ 1 ] { Color.White }; fadeSprite = new Sprite ( fadeTexture ); fadeSpriteWorld = new World2 (); fadeSpriteWorld.Scale = Core.GraphicsDevice.BackBuffer.Size (); }
public void SwapBgraToRgba(IDeviceContext context, ITexture2D target, ITexture2D texture) { var uav = target.ViewAsUnorderedAccessResource(rgbaFormat, 0); var srv = texture.ViewAsShaderResource(bgraFormat, 0, 1); context.ShaderForDispatching = computeShader; context.ComputeStage.ShaderResources[0] = srv; context.ComputeStage.UnorderedAccessResources[0] = uav; context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1); }
public TranslateWidgetRenderableAsset(IGraphicsContext context, TranslateArrowDirection direction) { if (direction == TranslateArrowDirection.Horizontal) { _texture = context.LoadTexture2D("ArrowHorizontal"); RenderingOffset = - new Vector2(0, _texture.Height / 2); } else { _texture = context.LoadTexture2D("ArrowVertical"); RenderingOffset = - new Vector2(_texture.Width / 2, 0); } _boundingBox = new AxisAlignedBoundingBox2D(0, 0, _texture.Height, _texture.Width); }
public MoveWidgetRenderableAsset(IGraphicsContext context) { _verticalArrow = context.LoadTexture2D("ArrowVertical"); _horizontalArrow = context.LoadTexture2D("ArrowHorizontal"); _verticalArrowBox = new AxisAlignedBoundingBox2D( -_verticalArrow.Width / 2, 0, _verticalArrow.Height, _verticalArrow.Width); _horizontalArrowBox = new AxisAlignedBoundingBox2D( 0, -_horizontalArrow.Height / 2, _horizontalArrow.Height, _horizontalArrow.Width); }
public Font(IDisposableResource parent, IShader shader, ITexture2D texture, string metricsFileName, Loader.LoadedCallbackMethod loadedCallback) : base(parent) { new StreamLoader(metricsFileName, delegate(object sender, bool succeeded) { if (succeeded) { init(shader, texture, ((StreamLoader)sender).LoadedStream, metricsFileName, loadedCallback); } else { FailedToLoad = true; Dispose(); if (loadedCallback != null) loadedCallback(this, false); } }); }
/// <summary> /// Create a texture ModJob from a tex2D with some pathing stuff. /// </summary> /// <param name="tex2D">Texture2D to build job from.</param> /// <param name="imgPath">Path of texture image to create job with.</param> /// <param name="WhichGame">Game to target.</param> /// <param name="pathBIOGame">Path to BIOGame of targeted game.</param> /// <returns>New ModJob based on provided image and Texture2D.</returns> public static ModJob CreateTextureJob(ITexture2D tex2D, string imgPath, int WhichGame, string pathBIOGame) { // KFreon: Get script string script = GenerateTextureScript(exec, tex2D.allPccs, tex2D.expIDs, tex2D.texName, WhichGame, pathBIOGame); ModJob job = new ModJob(); job.Script = script; // KFreon: Get image data using (FileStream stream = new FileStream(imgPath, FileMode.Open)) { FileInfo fs = new FileInfo(imgPath); byte[] buff = new byte[fs.Length]; stream.Read(buff, 0, buff.Length); job.data = buff; } job.Name = (tex2D.Mips > 1 ? "Upscale (with MIP's): " : "Upscale: ") + tex2D.texName; return job; }
public EarthlitNightScene(IEye eye) { this.eye = eye; device = eye.Device; swapChain = device.PrimarySwapChain; stars = new Stars(device, StarCount); var meshFactory = new MeshFactory(device, Handedness.Right, Winding.Clockwise); var earthMesh = meshFactory.CreateSphere(false, 1.0f, 36); earthVertexBuffer = earthMesh.Vertices.Buffer; earthIndexBuffer = earthMesh.Indices.Buffer; var formatInfo = eye.Adapters[0].GetSupportedFormats(FormatSupport.RenderTarget | FormatSupport.Texture2D | FormatSupport.TextureCube) .First(x => x.ColorBits == 24 && x.AlphaBits == 8 && x.ColorFormatType == FormatElementType.UNORM); starsProxyTexture = device.Create.Texture2D(new Texture2DDescription { BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Usage = Usage.Default, Width = SkyboxSize, Height = SkyboxSize, ArraySize = 1, MipLevels = 1, FormatID = formatInfo.ID }); skyboxTexture = device.Create.Texture2D(new Texture2DDescription { BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource, Usage = Usage.Default, Width = SkyboxSize, Height = SkyboxSize, ArraySize = 6, MipLevels = TextureHelper.MipLevels(SkyboxSize, SkyboxSize, 1), FormatID = formatInfo.ID, MiscFlags = MiscFlags.TextureCube | MiscFlags.GenerateMips }); var textureLoader = new TextureLoader(device); earthTexture = textureLoader.Load("../Textures/BasicTest.png"); }
public Texture2D GetTexture(ITexture2D xnaTex) { var pair = _textureContainer.Where((kvp) => kvp.Key.Id == xnaTex.Id) .FirstOrDefault(); if (pair.Value == null) return null; return pair.Value; }
public void Render(ITexture2D texture, float x, float y, Vector2 origin = default(Vector2)) { Render(texture, x, y, texture.Width, texture.Height, 0, origin); }
public void SetAlbedoTexture(ITexture2D texture) { albedoTexture = texture; hasAlbedoTexture = 1; }
public void RecreateMaterials() { lock (instanceMutationLock) { if (!materialsOutOfDate) { return; } } FragmentShader fs = GetRecommendedFragmentShader(); using (RenderingModule.RenderStateBarrier.AcquirePermit(withLock: instanceMutationLock)) { currentMaterials.ForEach(kvp => kvp.Value.Dispose()); currentMaterials.Clear(); textureViews.ForEach(kvp => { AssetLocator.UnloadTexture(kvp.Key); kvp.Value.Dispose(); }); textureViews.Clear(); foreach (LevelMaterial levelMaterial in materials) { Material material = new Material(levelMaterial.Name + " [" + levelMaterial.ID + "]", fs); ShaderResourceView srv; if (textureViews.ContainsKey(levelMaterial.TextureFileName)) { srv = textureViews[levelMaterial.TextureFileName]; } else { ITexture2D loadedTexture = AssetLocator.LoadTexture(levelMaterial.TextureFileName, levelMaterial.GenerateMips); srv = loadedTexture.CreateView(); textureViews[levelMaterial.TextureFileName] = srv; } material.SetMaterialResource((ResourceViewBinding)fs.GetBindingByIdentifier("DiffuseMap"), srv); if (fs.ContainsBinding("MaterialProperties")) { material.SetMaterialConstantValue( (ConstantBufferBinding)fs.GetBindingByIdentifier("MaterialProperties"), new Vector4(0f, 0f, 0f, levelMaterial.SpecularPower) ); } if (fs.ContainsBinding("NormalMap")) { if (levelMaterial.NormalFileName != null) { var loadedNormalMap = AssetLocator.LoadTexture(levelMaterial.NormalFileName, levelMaterial.GenerateMips); srv = loadedNormalMap.CreateView(); textureViews[levelMaterial.NormalFileName] = srv; } else { srv = AssetLocator.DefaultNormalMapView; } material.SetMaterialResource((ResourceViewBinding)fs.GetBindingByIdentifier("NormalMap"), srv); } if (fs.ContainsBinding("SpecularMap")) { if (levelMaterial.SpecularFileName != null) { var loadedSpecularMap = AssetLocator.LoadTexture(levelMaterial.SpecularFileName, levelMaterial.GenerateMips); srv = loadedSpecularMap.CreateView(); textureViews[levelMaterial.SpecularFileName] = srv; } else { srv = AssetLocator.DefaultSpecularMapView; } material.SetMaterialResource((ResourceViewBinding)fs.GetBindingByIdentifier("SpecularMap"), srv); } if (fs.ContainsBinding("EmissiveMap")) { if (levelMaterial.EmissiveFileName != null) { var loadedEmissiveMap = AssetLocator.LoadTexture(levelMaterial.EmissiveFileName, levelMaterial.GenerateMips); srv = loadedEmissiveMap.CreateView(); textureViews[levelMaterial.EmissiveFileName] = srv; } else { srv = AssetLocator.DefaultEmissiveMapView; } material.SetMaterialResource((ResourceViewBinding)fs.GetBindingByIdentifier("EmissiveMap"), srv); } currentMaterials.Add(levelMaterial, material); } materialsOutOfDate = false; } }
protected override void Render(ITexture2D input) { Renderer.ConvertToYuv(Target.Texture, input, Colorimetric, OutputLimitedRange); }
public void SetNormalMap(ITexture2D texture) { normalMap = texture; hasNormalMap = 1; }
public void Copy(ITexture2D texture) { var textureTEMP = (Texture2D)texture; uint pixelOrder, byteSizes; int format = Video.surfaceFormat(Video.DefaultSurfaceFormat(), out pixelOrder, out byteSizes); GL.CopyTexImage2D(textureTEMP.Texture, 0, (uint)format, 0, 0, Size.Width, Size.Height, 0); }
public FileSpriteSheetProvider(string textureName, string fileName, ContentManager contentManager) { this.fileName = fileName; texture = new XnaTexture2D(textureName, contentManager); }
public void SetEnvironmentMap(ITexture2D texture) { environmentMap = texture; hasEnvironmentMap = 1; reflectivity = 1; }
public void SetAlphaMap(ITexture2D texture) { alphaMap = texture; hasAlphaMap = 1; }
public void Draw(ITexture2D texture, Point location) { Draw(texture, location, Color.White); }
public void Draw(ITexture2D texture, Point location, Color color) { var gameTexture = (Texture)texture; _spriteBatch.Draw(gameTexture.Texture2D, new Vector2(location.X, location.Y), color); }
public SpriteOutlineModule(ISpriteEditor sem, IEventSystem es, IUndoSystem us, IAssetDatabase ad, IGUIUtility gu, IShapeEditorFactory sef, ITexture2D outlineTexture) { this.spriteEditorWindow = sem; this.undoSystem = us; this.eventSystem = es; this.assetDatabase = ad; this.guiUtility = gu; this.shapeEditorFactory = sef; this.m_OutlineTexture = outlineTexture; this.m_ShapeSelectionUI = new ShapeEditorRectSelectionTool(gu); this.m_ShapeSelectionUI.RectSelect += new Action <Rect, ShapeEditor.SelectionType>(this.RectSelect); this.m_ShapeSelectionUI.ClearSelection += new Action(this.ClearSelection); }
public void Render(ITexture2D texture, float x, float y, float width, float height, float rotation, Vector2 origin = default(Vector2), Vector2 renderingOffset = default(Vector2)) { var tex = _xnaGD._gContentManager.GetTexture(texture); x += TranslationTransformation.X; y += TranslationTransformation.Y; rotation += RotationTransformation; var rec = new Rectangle( (int)(x + origin.X + renderingOffset.X), (int)(y + origin.Y + renderingOffset.Y), (int)width, (int)height ); _xnaGD._spriteBatch.Draw( tex, rec, null, Color.White, MathHelper.ToRadians(rotation),//rotation, origin, SpriteEffects.FlipVertically, 0 ); }
public void SetHeightMap(ITexture2D texture) { heightMap = texture; hasHeightMap = 1; }
public void Render(ITexture2D texture, Matrix transformation, AxisAlignedBoundingBox2D boundingBox) { var tex = _xnaGD._gContentManager.GetTexture(texture); var worldMatrixPreTransform = _xnaGD._basicEffect.World; _xnaGD._basicEffect.Texture = tex; _xnaGD._basicEffect.World *= transformation * RendererTransformation(); _xnaGD._basicEffect.View = _xnaGD.ViewMatrix; _xnaGD._basicEffect.Projection = _xnaGD.ProjectionMatrix; foreach (var pass in _xnaGD._basicEffect.CurrentTechnique.Passes) { pass.Apply(); _xnaGD._gd.DrawUserPrimitives(PrimitiveType.TriangleStrip, GetVerticesFor(boundingBox), 0, 2); } _xnaGD._basicEffect.World = worldMatrixPreTransform; }
public override void Initialize() { renderTarget = Context.Create.Texture2D(RenderTargetSize, RenderTargetSize, TextureHelper.CalculateMipCount(RenderTargetSize, 1, 1), Format.Rgba8); depthStencil = Context.Create.Renderbuffer(RenderTargetSize, RenderTargetSize, Format.Depth24Stencil8); framebuffer = Context.Create.Framebuffer(); framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, renderTarget, 0); framebuffer.AttachRenderbuffer(FramebufferAttachmentPoint.DepthStencil, depthStencil); var vertexBuffer = Context.Create.Buffer(BufferTarget.Array, 24 * 8 * sizeof(float), BufferUsageHint.StaticDraw, new[] { new Vertex(1f, -1f, 1f, 1f, 0f, 0f, 0f, 0f), new Vertex(1f, 1f, 1f, 1f, 0f, 0f, 1f, 0f), new Vertex(1f, 1f, -1f, 1f, 0f, 0f, 1f, 1f), new Vertex(1f, -1f, -1f, 1f, 0f, 0f, 0f, 1f), new Vertex(1f, 1f, 1f, 0f, 1f, 0f, 0f, 0f), new Vertex(-1f, 1f, 1f, 0f, 1f, 0f, 1f, 0f), new Vertex(-1f, 1f, -1f, 0f, 1f, 0f, 1f, 1f), new Vertex(1f, 1f, -1f, 0f, 1f, 0f, 0f, 1f), new Vertex(-1f, 1f, 1f, -1f, 0f, 0f, 0f, 0f), new Vertex(-1f, -1f, 1f, -1f, 0f, 0f, 1f, 0f), new Vertex(-1f, -1f, -1f, -1f, 0f, 0f, 1f, 1f), new Vertex(-1f, 1f, -1f, -1f, 0f, 0f, 0f, 1f), new Vertex(-1f, -1f, 1f, 0f, -1f, 0f, 0f, 0f), new Vertex(1f, -1f, 1f, 0f, -1f, 0f, 1f, 0f), new Vertex(1f, -1f, -1f, 0f, -1f, 0f, 1f, 1f), new Vertex(-1f, -1f, -1f, 0f, -1f, 0f, 0f, 1f), new Vertex(-1f, -1f, 1f, 0f, 0f, 1f, 0f, 0f), new Vertex(-1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f), new Vertex(1f, 1f, 1f, 0f, 0f, 1f, 1f, 1f), new Vertex(1f, -1f, 1f, 0f, 0f, 1f, 0f, 1f), new Vertex(-1f, 1f, -1f, 0f, 0f, -1f, 0f, 0f), new Vertex(-1f, -1f, -1f, 0f, 0f, -1f, 1f, 0f), new Vertex(1f, -1f, -1f, 0f, 0f, -1f, 1f, 1f), new Vertex(1f, 1f, -1f, 0f, 0f, -1f, 0f, 1f) }); var indexBuffer = Context.Create.Buffer(BufferTarget.ElementArray, 36 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[] { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23 }); vertexArray = Context.Create.VertexArray(); vertexArray.SetElementArrayBuffer(indexBuffer); vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Three, VertexAttribPointerType.Float, false, 32, 0); vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Three, VertexAttribPointerType.Float, false, 32, 12); vertexArray.SetVertexAttributeF(2, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, 32, 24); transformBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw); cameraBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw); #if INTEL_WORKAROUND cameraOutsideBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw); #endif cameraExtraBuffer = Context.Create.Buffer(BufferTarget.Uniform, 12, BufferUsageHint.DynamicDraw); lightBuffer = Context.Create.Buffer(BufferTarget.Uniform, 12, BufferUsageHint.DynamicDraw); using (var textureLoader = new TextureLoader("../Textures/DiffuseTest.png")) { diffuseMap = Context.Create.Texture2D(textureLoader.Width, textureLoader.Height, TextureHelper.CalculateMipCount(textureLoader.Width, textureLoader.Height, 1), Format.Rgba8); for (int i = 0; i < diffuseMap.MipCount; i++) diffuseMap.SetData(i, textureLoader.GetMipData(i), FormatColor.Rgba, FormatType.UnsignedByte); } sampler = Context.Create.Sampler(); sampler.SetMagFilter(TextureMagFilter.Linear); sampler.SetMinFilter(TextureMinFilter.LinearMipmapLinear); sampler.SetMaxAnisotropy(16f); IVertexShader vsh = Context.Create.VertexShader(VertexShaderText); IFragmentShader fsh = Context.Create.FragmentShader(FragmentShaderText); program = Context.Create.Program(new ShaderProgramDescription { VertexShaders = new[] {vsh}, FragmentShaders = new[] {fsh}, VertexAttributeNames = new[] {"in_position", "in_normal", "in_tex_coord"}, UniformBufferNames = new[] {"Transform", "Camera", "Light"}, SamplerNames = new[] {"DiffuseMap"} }); }
public unsafe void CalculateLossy(IDeviceContext context, ITexture2D target, ITexture2D previous, ITexture2D temporalDiff, int mostDetailedMip) { var mipInfo = new MipInfo { MipLevel = mostDetailedMip, CoordDivisor = 1 << mostDetailedMip }; var map = context.Map(mipInfoBuffer, 0, MapType.WriteDiscard, MapFlags.None); *(MipInfo*)map.Data = mipInfo; context.Unmap(mipInfoBuffer, 0); // todo: try doing everything using MostDetailedMip of SRV context.ShaderForDispatching = computeShader; context.ComputeStage.UniformBuffers[0] = mipInfoBuffer; context.ComputeStage.ShaderResources[0] = previous.ViewAsShaderResource(formatId, 0, previous.MipLevels); context.ComputeStage.ShaderResources[1] = temporalDiff.ViewAsShaderResource(formatId, 0, temporalDiff.MipLevels); context.ComputeStage.UnorderedAccessResources[0] = target.ViewAsUnorderedAccessResource(formatId, 0); context.Dispatch(RavcMath.DivideAndCeil(target.Width, 16), RavcMath.DivideAndCeil(target.Height, 16), 1); }
public void Attach() { _texture = _factory.Create <ITexture2D>(); _texture.SetData("Assets/picture.png"); _texture2 = _factory.Create <ITexture2D>(); _texture2.SetData("Assets/picture2.png"); _scene.Init(); _physicsContainer.Gravity = new Vector3(0, -800, 0); var entity = _scene.CreateEntity(); _scene.AddComponent(entity, new CameraComponent { Camera = _camera, Active = true }); _scene.AddComponent(entity, new CameraScript(_camera)); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(-100, 400, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 300, Height = 300 }); _scene.AddComponent(entity, new ColorComponent { Color = new Vector4(0.5f, 0.5f, 0.5f, 1f) }); entity = _scene.CreateEntity(); var positionComponent = new PositionComponent { Position = new Vector3(400, -100, 0) }; _scene.AddComponent(entity, positionComponent); _scene.AddComponent(entity, new SizeComponent { Width = 400, Height = 300 }); _scene.AddComponent(entity, new ColorComponent { Color = new Vector4(1, 0, 1, 1) }); _scene.AddComponent(entity, new TextureComponent { Texture = _texture }); _scene.AddComponent(entity, new DiceScript(positionComponent)); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(-400, -100, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 300, Height = 300 }); _scene.AddComponent(entity, new TextureComponent { Texture = _texture2 }); _scene.AddComponent(entity, new PhysicsComponent { Velocity = new Vector3(300, 500, 0) }); entity = _scene.CreateEntity(); _scene.AddComponent(entity, new PositionComponent { Position = new Vector3(0, -360, 0) }); _scene.AddComponent(entity, new SizeComponent { Width = 1280, Height = 10 }); _scene.AddComponent(entity, new PhysicsComponent { Fixed = true }); }
public void CopyImgList(ITexture2D tex2D, IPCCObject PCC) { CopyImgList((ME3SaltTexture2D)tex2D, (ME3PCCObject)PCC); }
public void TestCreationParameters() { // Define variables and constants var defaultBuilder = TextureFactory.NewTexture2D <TexelFormat.RGBA32UInt>().WithUsage(ResourceUsage.DiscardWrite).WithWidth(100).WithHeight(256); var withStagingUsage = defaultBuilder.WithUsage(ResourceUsage.StagingReadWrite).WithPermittedBindings(GPUBindings.None); var withReadWriteBindings = defaultBuilder.WithUsage(ResourceUsage.Write).WithPermittedBindings(GPUBindings.ReadableShaderResource | GPUBindings.WritableShaderResource); var withDifferentFormat = defaultBuilder.WithTexelFormat <TexelFormat.Int8>(); var withWidth300 = defaultBuilder.WithWidth(300); var withMipAllocation = defaultBuilder.WithUsage(ResourceUsage.Write).WithWidth(1 << 9).WithMipAllocation(true); var withDynDetail = withMipAllocation.WithDynamicDetail(true); var withMipGen = withMipAllocation .WithUsage(ResourceUsage.Write) .WithPermittedBindings(GPUBindings.RenderTarget | GPUBindings.ReadableShaderResource) .WithMipGenerationTarget(true) .WithTexelFormat <TexelFormat.RGBA8UNorm>(); var withMS = defaultBuilder.WithMultisampling(true); // Set up context // Execute // Assert outcome ITexture2D tex = withStagingUsage.Create(); Assert.AreEqual(ResourceUsage.StagingReadWrite, tex.Usage); tex.Dispose(); tex = withReadWriteBindings.Create(); tex.Dispose(); Assert.AreEqual(GPUBindings.ReadableShaderResource | GPUBindings.WritableShaderResource, tex.PermittedBindings); tex = withDifferentFormat.Create(); tex.Dispose(); Assert.AreEqual(typeof(TexelFormat.Int8), tex.TexelFormat); tex = withWidth300.Create(); tex.Dispose(); Assert.AreEqual(300U, tex.Width); tex = withMipAllocation.Create(); tex.Dispose(); Assert.AreEqual(TextureUtils.GetNumMips(1 << 9, 256), tex.NumMips); tex = withDynDetail.Create(); tex.Dispose(); Assert.AreEqual(true, tex.IsGlobalDetailTarget); tex = withMipGen.Create(); tex.Dispose(); Assert.AreEqual(true, tex.IsMipGenTarget); tex = withMS.Create(); tex.Dispose(); Assert.AreEqual(true, tex.IsMultisampled); tex.Dispose(); ITexture2DArray ta = withStagingUsage.CreateArray(10); Assert.AreEqual(ResourceUsage.StagingReadWrite, ta.Usage); ta.Dispose(); ta = withReadWriteBindings.CreateArray(10); Assert.AreEqual(GPUBindings.ReadableShaderResource | GPUBindings.WritableShaderResource, ta.PermittedBindings); ta.Dispose(); ta = withDifferentFormat.WithUsage(ResourceUsage.Write).CreateArray(10); Assert.AreEqual(typeof(TexelFormat.Int8), ta.TexelFormat); ta.Dispose(); ta = withWidth300.WithUsage(ResourceUsage.Write).CreateArray(10); Assert.AreEqual(300U, ta.Width); ta.Dispose(); ta = withMipAllocation.CreateArray(10); Assert.AreEqual(TextureUtils.GetNumMips(1 << 9, 256), ta.NumMips); ta.Dispose(); ta = withDynDetail.CreateArray(10); Assert.AreEqual(true, ta.IsGlobalDetailTarget); ta.Dispose(); ta = withMipGen.CreateArray(10); Assert.AreEqual(true, ta.IsMipGenTarget); ta.Dispose(); ta = withMS.WithUsage(ResourceUsage.Write).CreateArray(10); Assert.AreEqual(true, ta.IsMultisampled); ta.Dispose(); ta = defaultBuilder.WithUsage(ResourceUsage.Immutable).WithInitialData(new TexelFormat.RGBA32UInt[10U * 100U * 256U]).CreateArray(10); Assert.AreEqual(10U, ta.ArrayLength); ta.Dispose(); #if !DEVELOPMENT && !RELEASE try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithUsage(ResourceUsage.Immutable) .WithInitialData(null) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithUsage(ResourceUsage.DiscardWrite) .WithPermittedBindings(GPUBindings.None) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithUsage(ResourceUsage.StagingRead) .WithPermittedBindings(GPUBindings.ReadableShaderResource) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithWidth(0U) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(true) .WithWidth(140) .WithHeight(1U) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(true) .WithMipGenerationTarget(true) .WithWidth(1 << 4) .WithHeight(1 << 4) .WithUsage(ResourceUsage.Write) .WithPermittedBindings(GPUBindings.None) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(false) .WithMipGenerationTarget(true) .WithWidth(1 << 4) .WithHeight(1 << 4) .WithUsage(ResourceUsage.Write) .WithPermittedBindings(GPUBindings.RenderTarget | GPUBindings.ReadableShaderResource) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(true) .WithMipGenerationTarget(true) .WithWidth(1 << 4) .WithHeight(1 << 4) .WithUsage(ResourceUsage.Write) .WithPermittedBindings(GPUBindings.RenderTarget | GPUBindings.ReadableShaderResource) .WithInitialData(new TexelFormat.Float32[(1 << 5) - 1]) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(true) .WithWidth(1 << 4) .WithHeight(1 << 4) .WithUsage(ResourceUsage.Immutable) .WithPermittedBindings(GPUBindings.ReadableShaderResource) .WithInitialData(new TexelFormat.Float32[1 << 4]) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(false) .WithWidth(1 << 4) .WithHeight(1 << 4) .WithUsage(ResourceUsage.Immutable) .WithPermittedBindings(GPUBindings.ReadableShaderResource) .WithInitialData(new TexelFormat.Float32[(1 << 5) - 1]) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(true) .WithWidth(32U) .WithHeight(32U) .WithMultisampling(true) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } try { TextureFactory.NewTexture2D <TexelFormat.Float32>() .WithMipAllocation(false) .WithWidth(2U) .WithHeight(2U) .WithMultisampling(true) .WithInitialData(new TexelFormat.Float32[4]) .Create(); Assert.Fail(); } catch (AssuranceFailedException) { } #endif }