public ReferTexture(ReferTextureData trd) { this.Color = new Color(trd.Color.R, trd.Color.G, trd.Color.B, trd.Color.A); this.AddrModeX = trd.AdrModX; this.AddrModeY = trd.AdrModY; this.SourceRect = new Rectangle(trd.SrcRect.X, trd.SrcRect.Y, trd.SrcRect.Width, trd.SrcRect.Height); this.texture = (Texture2D)GameService.Instance.QueryModule<ContentModule>().GetContent(ContentType.Texture, trd.UID); this.name = trd.Key; }
public override void BeforeRender() { _lastMode = Engine.Device.SamplerStates[0].AddressU; if (_lastMode != TextureAddressMode.Wrap) Engine.Device.SamplerStates[0].AddressU = Engine.Device.SamplerStates[0].AddressV = TextureAddressMode.Wrap; GameVars.CurrentEffect.TexCoordsOffset = _uvOffset; GameVars.CurrentEffect.CommitChanges(); }
/// <summary> /// Create an atlas texture element that contains all the information from the source texture. /// </summary> /// <param name="name">The reference name of the element</param> /// <param name="texture"></param> /// <param name="sourceRegion">The region of the element in the source texture</param> /// <param name="borderSize">The size of the border around the element in the output atlas</param> /// <param name="borderModeU">The border mode along the U axis</param> /// <param name="borderModeV">The border mode along the V axis</param> /// <param name="borderColor">The color of the border</param> public AtlasTextureElement(string name, Image texture, RotableRectangle sourceRegion, int borderSize, TextureAddressMode borderModeU, TextureAddressMode borderModeV, Color? borderColor = null) { Name = name; Texture = texture; SourceRegion = sourceRegion; BorderSize = borderSize; BorderModeU = borderModeU; BorderModeV = borderModeV; BorderColor = borderColor ?? Color.Transparent; }
protected static SamplerStateDescription BuildFilterDescription(Filter filter, TextureAddressMode textureAddressMode) { var samplerDescriptor = SamplerStateDescription.Default(); samplerDescriptor.Filter = filter; samplerDescriptor.AddressU = textureAddressMode; samplerDescriptor.AddressV = textureAddressMode; samplerDescriptor.AddressW = textureAddressMode; return samplerDescriptor; }
public struct014c(int p0, Texture2D p1, enum0103 p2, enum0104 p3, TextureAddressMode p4) { this.f000197 = PrimitiveType.TriangleList; this.f00000b = p0; if ((p1 != null) && p1.IsDisposed) { throw new ObjectDisposedException("Cannot create render break with disposed Texture2D"); } this.f00004f = p1; this.f00002b = p2; this.f00002c = p3; this.f0000d5 = p4; }
private SamplerState( string name, TextureFilter filter, TextureAddressMode addressU, TextureAddressMode addressV, TextureAddressMode addressW ) : this() { Name = name; Filter = filter; AddressU = addressU; AddressV = addressV; AddressW = addressW; }
public SamplerStateInfo() { // NOTE: These match the defaults of SamplerState. _minFilter = TextureFilterType.Linear; _magFilter = TextureFilterType.Linear; _mipFilter = TextureFilterType.Linear; _addressU = TextureAddressMode.Wrap; _addressV = TextureAddressMode.Wrap; _addressW = TextureAddressMode.Wrap; _borderColor = Color.White; _maxAnisotropy = 4; _maxMipLevel = 0; _mipMapLevelOfDetailBias = 0.0f; }
public TextureSamplerSettings(TextureMinFilter minFilter, TextureMagFilter magFilter, TextureAddressMode wrapU, TextureAddressMode wrapV) { MinFilter = minFilter; MagFilter = magFilter; WrapU = wrapU; WrapV = wrapV; SamplerState = new SamplerState() { Filter = GetFilter(), AddressU = WrapU, AddressV = WrapV, }; }
//-------------------------------------------------------------- #region Convolution //-------------------------------------------------------------- /// <summary> /// Applies the a filter kernel to the specified image. /// </summary> /// <param name="image">The image.</param> /// <param name="kernel">The filter kernel. (Needs to be square.)</param> /// <param name="wrapMode">The texture address mode.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="image"/> or <paramref name="kernel"/> is <see langword="null"/>. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="kernel"/> is non-square. /// </exception> public static void Convolve(Image image, float[,] kernel, TextureAddressMode wrapMode) { if (image == null) throw new ArgumentNullException("image"); if (kernel == null) throw new ArgumentNullException("kernel"); if (kernel.GetLength(0) != kernel.GetLength(1)) throw new ArgumentException("Filter kernel needs to be square.", "kernel"); int width = image.Width; int height = image.Height; int kernelSize = kernel.GetLength(0); int kernelOffset = kernelSize / 2; var tmpImage = new Image(width, height, image.Format); Buffer.BlockCopy(image.Data, 0, tmpImage.Data, 0, image.Data.Length); // ReSharper disable AccessToDisposedClosure using (var tempImage4F = new ImageAccessor(tmpImage)) using (var image4F = new ImageAccessor(image)) { #if SINGLE_THREADED for (int y = 0; y < height; y++) #else Parallel.For(0, height, y => #endif { for (int x = 0; x < width; x++) { // Apply 2D kernel at (x, y). Vector4F color = new Vector4F(); for (int row = 0; row < kernelSize; row++) { int srcY = y + row - kernelOffset; for (int column = 0; column < kernelSize; column++) { int srcX = x + column - kernelOffset; color += kernel[row, column] * tempImage4F.GetPixel(srcX, srcY, wrapMode); } } image4F.SetPixel(x, y, color); } } #if !SINGLE_THREADED ); #endif } // ReSharper restore AccessToDisposedClosure }
public static TextureFilter CreateNearest(TextureAddressMode uvwAdressMode) { return(new TextureFilter(new SamplerStateDescription() { Filter = Filter.MinMagMipPoint, AddressU = uvwAdressMode, AddressV = uvwAdressMode, AddressW = uvwAdressMode, ComparisonFunction = Comparison.Always, MinimumLod = 0, MaximumLod = 0, MaximumAnisotropy = 16 })); }
internal Texture( int width, int height, PixelFormat pixelFormat, Tm2.GsPSM uploadPixelFormat, byte[] data, byte[] palette, TextureAddressMode textureAddressMode, int cbp, int csa) { Size = new Size(width, height); PixelFormat = pixelFormat; _uploadPixelFormat = uploadPixelFormat; _data = data; _palette = palette; TextureAddressMode = textureAddressMode; _cbp = cbp; _csa = csa; }
private SamplerState(SamplerState cloneSource) { Name = cloneSource.Name; _filter = cloneSource._filter; _addressU = cloneSource._addressU; _addressV = cloneSource._addressV; _addressW = cloneSource._addressW; _borderColor = cloneSource._borderColor; _maxAnisotropy = cloneSource._maxAnisotropy; _maxMipLevel = cloneSource._maxMipLevel; _mipMapLevelOfDetailBias = cloneSource._mipMapLevelOfDetailBias; _comparisonFunction = cloneSource._comparisonFunction; _filterMode = cloneSource._filterMode; }
public static TextureFilter CreateLinearMipmapped(TextureAddressMode uvwAdressMode) { return(new TextureFilter(new SamplerStateDescription() { Filter = Filter.MinMagMipLinear, AddressU = uvwAdressMode, AddressV = uvwAdressMode, AddressW = uvwAdressMode, ComparisonFunction = Comparison.Always, MinimumLod = 0, MaximumLod = float.MaxValue, MaximumAnisotropy = 16 })); }
public RenderSystem(PresentationParameters parameters) { Adapters = GraphicsAdapter.EnumerateGraphicsAdapter(); Device = new GraphicsDevice(Adapters[0]); SwapChain = new GraphicsSwapChain(parameters, Device); CommandList = new CommandList(Device); Texture = new Texture(Device, SwapChain); Shaders = new Shaders(Device, "Shaders/VertexShader.hlsl", "Shaders/PixelShader.hlsl"); StateWireframe = new PipelineState(Device, FillMode.Wireframe, CullMode.None); StateSolid = new PipelineState(Device, FillMode.Solid, CullMode.None); Grid = new Grid(1, 1, 8, 8); Mesh = new Mesh("suzanne.obj"); VertexBuffer = new Buffer[2]; IndexBuffer = new Buffer[2]; VertexBuffer[0] = new Buffer(Grid.SizeInBytes, Grid.Size, Device, ResourceInfo.VertexBuffer); IndexBuffer[0] = new Buffer(Grid.IndexSizeInBytes, Grid.IndexSize, Device, ResourceInfo.IndexBuffer); VertexBuffer[1] = new Buffer(Mesh.SizeInBytes, Mesh.Size, Device, ResourceInfo.VertexBuffer); IndexBuffer[1] = new Buffer(Mesh.IndexSizeInBytes, Mesh.IndexSize, Device, ResourceInfo.IndexBuffer); ConstantBuffer = new Buffer(Utilities.SizeOf <Transform>(), Utilities.SizeOf <Transform>(), Device, ResourceInfo.ConstantBuffer); TextureAddressMode Wrap = TextureAddressMode.Wrap; SamplerState = new SamplerState(Device, Wrap, Wrap, Wrap, Filter.MinMagMipLinear); Camera = new Camera(CameraType.Static); Camera.Position = new Vector3(0.0f, 0.15f, -1.5f); Camera.SetLens((float)Math.PI / 4, 1.2f, 1.0f, 1000.0f); World = new Matrix[2]; Textures = new ShaderResourceView[2]; Textures[0] = Texture.LoadFromFile(Device, "Text/UV_Grid_Sm.jpg"); Textures[1] = Texture.LoadFromFile(Device, "Text/UV_Grid_Lrg.jpg"); }
private static TextureAddress convertTextureAddress(TextureAddressMode mode) { if (mode == TextureAddressMode.Clamp) { return(TextureAddress.Clamp); } else if (mode == TextureAddressMode.Mirror) { return(TextureAddress.Mirror); } else { return(TextureAddress.Wrap); } }
#pragma warning disable CS0246 // 未能找到类型或命名空间名“All”(是否缺少 using 指令或程序集引用?) public static All TranslateTextureAddressMode(TextureAddressMode addressMode) #pragma warning restore CS0246 // 未能找到类型或命名空间名“All”(是否缺少 using 指令或程序集引用?) { switch (addressMode) { case TextureAddressMode.Clamp: return(All.ClampToEdge); case TextureAddressMode.Wrap: return(All.Repeat); default: throw new InvalidOperationException("Unsupported texture address mode."); } }
public GL33Texture(int width, int height, Filter filter, TextureAddressMode textureAddressMode, ref float[] pixelData) { _width = width; _height = height; _nativeTexture = OpenTK.Graphics.OpenGL4.GL.GenTexture(); OpenTK.Graphics.OpenGL4.GL.BindTexture(TextureTarget.Texture2D, _nativeTexture); OpenTK.Graphics.OpenGL4.GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)filter.MinFilterToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)filter.MagFilterToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapR, (int)textureAddressMode.ToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)textureAddressMode.ToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, _width, _height, 0, PixelFormat.Rgba, PixelType.Float, pixelData); View = new GL33TextureView(this); }
private static int convertTextureAddressMode(TextureAddressMode mode) { if (mode == TextureAddressMode.Clamp) { return((int)All.ClampToEdge); } else if (mode == TextureAddressMode.Mirror) { return((int)All.MirroredRepeat); } else { return((int)All.Repeat); } }
/// <summary> /// Converts the specified TextureAddressMode value to the equivalent OpenGL value. /// </summary> /// <param name="mode">The TextureAddressMode value to convert.</param> /// <returns>The converted value.</returns> internal static Int32 GetTextureAddressModeGL(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return((int)gl.GL_CLAMP_TO_EDGE); case TextureAddressMode.Wrap: return((int)gl.GL_REPEAT); case TextureAddressMode.Mirror: return((int)gl.GL_MIRRORED_REPEAT); } throw new NotSupportedException(); }
public GL46Texture(int width, int height, Filter filter, TextureAddressMode textureAddressMode, ref float[] pixelData) { OpenTK.Graphics.OpenGL4.GL.CreateTextures(TextureTarget.Texture2D, 1, out _nativeTexture); OpenTK.Graphics.OpenGL4.GL.TextureStorage2D(_nativeTexture, 1, SizedInternalFormat.Rgba32f, width, height); OpenTK.Graphics.OpenGL4.GL.TextureParameter(_nativeTexture, TextureParameterName.TextureMinFilter, (int)filter.MinFilterToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TextureParameter(_nativeTexture, TextureParameterName.TextureMagFilter, (int)filter.MagFilterToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TextureParameter(_nativeTexture, TextureParameterName.TextureWrapR, (int)textureAddressMode.ToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TextureParameter(_nativeTexture, TextureParameterName.TextureWrapS, (int)textureAddressMode.ToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TextureParameter(_nativeTexture, TextureParameterName.TextureWrapT, (int)textureAddressMode.ToOpenTK()); OpenTK.Graphics.OpenGL4.GL.TextureSubImage2D(_nativeTexture, 0, 0, 0, width, height, PixelFormat.Rgba, PixelType.Float, pixelData); View = new GL46TextureView(this); }
/// <summary> /// Custom drawing technique - sets graphics states and /// draws the custom shape /// </summary> /// <param name="camera">The currently drawing camera</param> #endregion public void Draw(Camera camera) { ////////////////////Early Out/////////////////// if (!Visible) { return; } //////////////////End Early Out///////////////// // Set graphics states FlatRedBallServices.GraphicsDevice.RasterizerState = RasterizerState.CullNone; // texture options // Have the current camera set our current view/projection variables camera.SetDeviceViewAndProjection(mEffect, false); // Here we get the positioned object's transformation (position / rotation) mEffect.World = Matrix.CreateScale(RenderingScale) * base.TransformationMatrix; mEffect.Texture = mTexture; // We won't need to use any other kind of texture // address mode besides clamp, and clamp is required // on the "Reach" profile when the texture is not power // of two. Let's set it to clamp here so that we don't crash // on non-power-of-two textures. TextureAddressMode oldTextureAddressMode = Renderer.TextureAddressMode; Renderer.TextureAddressMode = TextureAddressMode.Clamp; // Start the effect foreach (EffectPass pass in mEffect.CurrentTechnique.Passes) { // Start each pass pass.Apply(); // Draw the shape FlatRedBallServices.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionTexture>( PrimitiveType.TriangleList, mVertices, 0, mVertices.Length, mIndices, 0, mIndices.Length / 3); } Renderer.TextureAddressMode = oldTextureAddressMode; }
/// <summary>To initialize this structure with default value, use this constructor. The argument value is ignored.</summary> /// <remarks>This is only here because C# doesn’t support parameterless constructors for structures.</remarks> public SamplerDesc(bool unused) { baseStruct = new DeviceObjectAttribs(true); MinFilter = FilterType.Linear; MagFilter = FilterType.Linear; MipFilter = FilterType.Linear; AddressU = TextureAddressMode.Clamp; AddressV = TextureAddressMode.Clamp; AddressW = TextureAddressMode.Clamp; MipLODBias = 0; MaxAnisotropy = 0; ComparisonFunc = ComparisonFunction.Never; BorderColor = Vector4.Zero; MinLOD = 0; MaxLOD = float.MaxValue; }
internal OpenGLTexture(int handle, OpenGL.TextureTarget target, int levelCount) { Handle = handle; Target = target; HasMipMaps = levelCount > 1; // TODO: ... WrapS = TextureAddressMode.Wrap; WrapT = TextureAddressMode.Wrap; WrapR = TextureAddressMode.Wrap; Filter = TextureFilter.Linear; Anistropy = 4.0f; MaxMipmapLevel = 0; LODBias = 0.0f; }
public PostProcessor(DXManager dxman) { var device = dxman.device; byte[] bReduceTo1DCS = File.ReadAllBytes("Shaders\\PPReduceTo1DCS.cso"); byte[] bReduceTo0DCS = File.ReadAllBytes("Shaders\\PPReduceTo0DCS.cso"); byte[] bLumBlendCS = File.ReadAllBytes("Shaders\\PPLumBlendCS.cso"); byte[] bBloomFilterBPHCS = File.ReadAllBytes("Shaders\\PPBloomFilterBPHCS.cso"); byte[] bBloomFilterVCS = File.ReadAllBytes("Shaders\\PPBloomFilterVCS.cso"); byte[] bCopyPixelsPS = File.ReadAllBytes("Shaders\\PPCopyPixelsPS.cso"); byte[] bFinalPassVS = File.ReadAllBytes("Shaders\\PPFinalPassVS.cso"); byte[] bFinalPassPS = File.ReadAllBytes("Shaders\\PPFinalPassPS.cso"); ReduceTo1DCS = new ComputeShader(device, bReduceTo1DCS); ReduceTo0DCS = new ComputeShader(device, bReduceTo0DCS); LumBlendCS = new ComputeShader(device, bLumBlendCS); BloomFilterBPHCS = new ComputeShader(device, bBloomFilterBPHCS); BloomFilterVCS = new ComputeShader(device, bBloomFilterVCS); CopyPixelsPS = new PixelShader(device, bCopyPixelsPS); FinalPassVS = new VertexShader(device, bFinalPassVS); FinalPassPS = new PixelShader(device, bFinalPassPS); FinalPassQuad = new UnitQuad(device, true); FinalPassLayout = new InputLayout(device, bFinalPassVS, new[] { new InputElement("POSITION", 0, Format.R32G32B32A32_Float, 0, 0), new InputElement("TEXCOORD", 0, Format.R32G32_Float, 16, 0), }); ReduceCSVars = new GpuVarsBuffer <PostProcessorReduceCSVars>(device); LumBlendCSVars = new GpuVarsBuffer <PostProcessorLumBlendCSVars>(device); FilterBPHCSVars = new GpuVarsBuffer <PostProcessorFilterBPHCSVars>(device); FilterVCSVars = new GpuVarsBuffer <PostProcessorFilterVCSVars>(device); FinalPSVars = new GpuVarsBuffer <PostProcessorFinalPSVars>(device); TextureAddressMode a = TextureAddressMode.Clamp; Color4 b = new Color4(0.0f, 0.0f, 0.0f, 0.0f); Comparison c = Comparison.Always; SampleStatePoint = DXUtility.CreateSamplerState(device, a, b, c, Filter.MinMagMipPoint, 0, 1.0f, 1.0f, 0.0f); SampleStateLinear = DXUtility.CreateSamplerState(device, a, b, c, Filter.MinMagMipLinear, 0, 1.0f, 1.0f, 0.0f); BlendState = DXUtility.CreateBlendState(device, false, BlendOperation.Add, BlendOption.One, BlendOption.Zero, BlendOperation.Add, BlendOption.One, BlendOption.Zero, ColorWriteMaskFlags.All); GetSampleWeights(ref FilterVCSVars.Vars.avSampleWeights, 3.0f, 1.25f); //init sample weights FilterBPHCSVars.Vars.avSampleWeights = FilterVCSVars.Vars.avSampleWeights; }
protected static bool GetTextureAddress(int value, int maxValue, TextureAddressMode textureAddressMode, out int result) { // If value is in the valid texture address range, return it straight away. if (value >= 0 && value < maxValue) { result = value; return(true); } // Otherwise, we need to use the specified addressing mode. switch (textureAddressMode) { case TextureAddressMode.Border: result = 0; return(false); case TextureAddressMode.Clamp: result = (value < 0) ? 0 : maxValue - 1; return(true); case TextureAddressMode.Mirror: { int temp = value % (2 * maxValue); if (temp < 0) { temp += (2 * maxValue); } result = (temp > maxValue) ? (2 * maxValue) - temp : temp; return(true); } case TextureAddressMode.Wrap: { int temp = value % maxValue; if (temp < 0) { temp += maxValue; } result = temp; return(true); } default: throw new ArgumentOutOfRangeException("textureAddressMode"); } }
public RenderBreak(int itemNumber, Text text, int textureIndex) { #if DEBUG ObjectCausingBreak = text; #endif LayerName = Renderer.CurrentLayerName; Red = 1; Green = 1; Blue = 1; #if !USE_CUSTOM_SHADER if (text.ColorOperation != Graphics.ColorOperation.Texture) { Red = text.Red; Green = text.Green; Blue = text.Blue; } #endif ItemNumber = itemNumber; PrimitiveType = PrimitiveType.TriangleList; TextureFilter = FlatRedBallServices.GraphicsOptions.TextureFilter; _originalTextureFilter = TextureFilter.Linear; if (text != null) { if (text.Font.Texture != null && text.Font.Texture.IsDisposed) { throw new ObjectDisposedException("Cannot create render break with disposed Texture2D"); } mTexture = text.Font.Textures[textureIndex]; ColorOperation = text.ColorOperation; BlendOperation = text.BlendOperation; TextureAddressMode = TextureAddressMode.Clamp; } else { mTexture = null; ColorOperation = ColorOperation.Texture; BlendOperation = BlendOperation.Regular; TextureAddressMode = TextureAddressMode.Clamp; } }
private int GetWrapMode(TextureAddressMode textureAddressMode) { switch (textureAddressMode) { case TextureAddressMode.Clamp: return(33071); case TextureAddressMode.Mirror: return(33648); case TextureAddressMode.Wrap: return(10497); default: throw new NotImplementedException("No support for " + (object)textureAddressMode); } }
private static TextureWrapMode ToAssimpAddressMode(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return(TextureWrapMode.Clamp); case TextureAddressMode.Mirror: return(TextureWrapMode.Mirror); case TextureAddressMode.Wrap: return(TextureWrapMode.Wrap); default: return(TextureWrapMode.Wrap); } }
private static SharpDX.Direct3D11.TextureAddressMode GetAddressMode(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return(SharpDX.Direct3D11.TextureAddressMode.Clamp); case TextureAddressMode.Mirror: return(SharpDX.Direct3D11.TextureAddressMode.Mirror); case TextureAddressMode.Wrap: return(SharpDX.Direct3D11.TextureAddressMode.Wrap); default: throw new NotImplementedException("Invalid texture address mode!"); } }
public TextureStruct_0001 Read(BinaryReader binaryReader) { sectionIdentifier = Section.Struct; sectionSize = binaryReader.ReadInt32(); renderWareVersion = binaryReader.ReadInt32(); filterMode = (TextureFilterMode)binaryReader.ReadByte(); byte addressMode = binaryReader.ReadByte(); addressModeU = (TextureAddressMode)((addressMode & 0xF0) >> 4); addressModeV = (TextureAddressMode)(addressMode & 0x0F); useMipLevels = binaryReader.ReadUInt16(); return(this); }
private int GetWrapMode(TextureAddressMode textureAddressMode) { switch (textureAddressMode) { case TextureAddressMode.Clamp: return((int)TextureWrapMode.ClampToEdge); case TextureAddressMode.Wrap: return((int)TextureWrapMode.Repeat); case TextureAddressMode.Mirror: return((int)All.MirroredRepeat); default: throw new ArgumentException("No support for " + textureAddressMode); } }
internal static int WrapMode(this TextureAddressMode textureAddressMode) { switch (textureAddressMode) { case TextureAddressMode.Clamp: return((int)TextureWrapMode.Clamp); case TextureAddressMode.Wrap: return((int)TextureWrapMode.Repeat); case TextureAddressMode.Mirror: return((int)TextureWrapMode.MirroredRepeat); default: throw new NotImplementedException("No support for " + textureAddressMode); } }
public StaticSamplerDescription(ShaderVisibility shaderVisibility, int shaderRegister, int registerSpace) { Filter = Filter.MinMagMipLinear; AddressU = TextureAddressMode.Clamp; AddressV = TextureAddressMode.Clamp; AddressW = TextureAddressMode.Clamp; MipLodBias = 0.0f; MaxAnisotropy = 1; ComparisonFunction = ComparisonFunction.Never; BorderColor = StaticBorderColor.TransparentBlack; MinLod = float.MinValue; MaxLod = float.MaxValue; ShaderRegister = shaderRegister; RegisterSpace = registerSpace; ShaderVisibility = shaderVisibility; }
internal static D3D.TextureAddressMode ToD3DTextureAddressMode(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return(D3D.TextureAddressMode.Clamp); case TextureAddressMode.Mirror: return(D3D.TextureAddressMode.Mirror); case TextureAddressMode.Wrap: return(D3D.TextureAddressMode.Wrap); default: throw new ArgumentException("Invalid address mode"); } }
//* -----------------------------------------------------------------------* /// <summary> /// テクスチャ向けに初期化します。 /// </summary> public void initialize() { blendMode = SpriteBlendMode.None; color = Color.White; fRotation = 0f; origin = Vector2.Zero; effects = SpriteEffects.None; fLayerDepth = 0f; texture = null; addressMode = TextureAddressMode.Clamp; destinationRectangle = Rectangle.Empty; sourceRectangle = Rectangle.Empty; spriteFont = null; text = null; position = Vector2.Zero; scale = Vector2.One; }
private static SamplerAddressMode ConvertAddressMode(TextureAddressMode addressMode) { switch (addressMode) { case TextureAddressMode.Wrap: return SamplerAddressMode.Repeat; case TextureAddressMode.Border: return SamplerAddressMode.ClampToBorder; case TextureAddressMode.Clamp: return SamplerAddressMode.ClampToEdge; case TextureAddressMode.Mirror: return SamplerAddressMode.MirroredRepeat; case TextureAddressMode.MirrorOnce: return SamplerAddressMode.MirrorClampToEdge; default: throw new ArgumentOutOfRangeException(); } }
private static SlimShader.VirtualMachine.Resources.TextureAddressMode ConvertAddress(TextureAddressMode address) { switch (address) { case TextureAddressMode.Wrap: return SlimShader.VirtualMachine.Resources.TextureAddressMode.Wrap; case TextureAddressMode.Mirror: return SlimShader.VirtualMachine.Resources.TextureAddressMode.Mirror; case TextureAddressMode.Clamp: return SlimShader.VirtualMachine.Resources.TextureAddressMode.Clamp; case TextureAddressMode.Border: return SlimShader.VirtualMachine.Resources.TextureAddressMode.Border; case TextureAddressMode.MirrorOnce: return SlimShader.VirtualMachine.Resources.TextureAddressMode.MirrorOnce; default: throw new ArgumentOutOfRangeException("address"); } }
internal static void UpdateTextureSampler(SamplerId samplerState, TextureAddressMode addressMode) { SamplerStateDescription description = new SamplerStateDescription(); description.AddressU = addressMode; description.AddressV = addressMode; description.AddressW = addressMode; description.MaximumLod = System.Single.MaxValue; if(MyRender11.RenderSettings.AnisotropicFiltering == MyTextureAnisoFiltering.NONE) { description.Filter = Filter.MinMagMipLinear; } else { description.Filter = Filter.Anisotropic; switch(MyRender11.RenderSettings.AnisotropicFiltering) { case MyTextureAnisoFiltering.ANISO_1: description.MaximumAnisotropy = 1; break; case MyTextureAnisoFiltering.ANISO_4: description.MaximumAnisotropy = 4; break; case MyTextureAnisoFiltering.ANISO_8: description.MaximumAnisotropy = 8; break; case MyTextureAnisoFiltering.ANISO_16: description.MaximumAnisotropy = 16; break; default: description.MaximumAnisotropy = 1; break; } } MyPipelineStates.ChangeSamplerState(samplerState, description); }
public struct014c(int p0, c000075 p1) { this.f00000b = p0; this.f000197 = PrimitiveType.TriangleList; if (p1 != null) { if ((p1.m000064() != null) && p1.m000064().IsDisposed) { throw new ObjectDisposedException("The Sprite with the name " + p1.m000087() + " references a disposed texture of the name " + p1.m000064().Name + ". If you're using Screens you may have forgotten to remove a Sprite that was added in the Screen."); } this.f00004f = p1.m000064(); this.f00002b = p1.m000399(); this.f00002c = p1.m0000a3(); this.f0000d5 = p1.m00039a(); } else { this.f00004f = null; this.f00002b = enum0103.f00002b; this.f00002c = enum0104.f00002c; this.f0000d5 = TextureAddressMode.Clamp; } }
internal static SamplerState New(GraphicsDevice device, string name, Filter filterMode, TextureAddressMode uvwMode) { var description = SamplerStateDescription.Default(); // For 9.1, anisotropy cannot be larger then 2 if (device.Features.Level == FeatureLevel.Level_9_1) { description.MaximumAnisotropy = 2; } description.Filter = filterMode; description.AddressU = uvwMode; description.AddressV = uvwMode; description.AddressW = uvwMode; return New(device, name, description); }
/// <summary> /// Converts the specified TextureAddressMode value to the equivalent OpenGL value. /// </summary> /// <param name="mode">The TextureAddressMode value to convert.</param> /// <returns>The converted value.</returns> internal static Int32 GetTextureAddressModeGL(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return (int)gl.GL_CLAMP_TO_EDGE; case TextureAddressMode.Wrap: return (int)gl.GL_REPEAT; case TextureAddressMode.Mirror: return (int)gl.GL_MIRRORED_REPEAT; } throw new NotSupportedException(); }
protected static bool GetTextureAddress(int value, int maxValue, TextureAddressMode textureAddressMode, out int result) { // If value is in the valid texture address range, return it straight away. if (value >= 0 && value < maxValue) { result = value; return true; } // Otherwise, we need to use the specified addressing mode. switch (textureAddressMode) { case TextureAddressMode.Border: result = 0; return false; case TextureAddressMode.Clamp: result = (value < 0) ? 0 : maxValue - 1; return true; case TextureAddressMode.Mirror: { int temp = value % (2 * maxValue); if (temp < 0) temp += (2 * maxValue); result = (temp > maxValue) ? (2 * maxValue) - temp : temp; return true; } case TextureAddressMode.Wrap: { int temp = value % maxValue; if (temp < 0) temp += maxValue; result = temp; return true; } default: throw new ArgumentOutOfRangeException("textureAddressMode"); } }
public SharpDXSampler(DXDevice nativeDevice, Filter filter, TextureAddressMode textureAddressMode) : base(nativeDevice, BuildFilterDescription(filter, textureAddressMode)) {}
public OpenGLTexture( uint handle, GLenum target, int levelCount ) { Handle = handle; Target = target; HasMipmaps = levelCount > 1; WrapS = TextureAddressMode.Wrap; WrapT = TextureAddressMode.Wrap; WrapR = TextureAddressMode.Wrap; Filter = TextureFilter.Linear; Anistropy = 4.0f; MaxMipmapLevel = 0; LODBias = 0.0f; }
public Sprite() : base() { mVisible = true; mScaleX = 1; mScaleY = 1; mVertices = new SpriteVertex[4]; mVertices[0] = new SpriteVertex(); mVertices[1] = new SpriteVertex(); mVertices[2] = new SpriteVertex(); mVertices[3] = new SpriteVertex(); mVertices[0].TextureCoordinate.X = 0; mVertices[0].TextureCoordinate.Y = 0; mVertices[0].Scale = new Vector2(-1, 1); mVertices[1].TextureCoordinate.X = 1; mVertices[1].TextureCoordinate.Y = 0; mVertices[1].Scale = new Vector2(1, 1); mVertices[2].TextureCoordinate.X = 1; mVertices[2].TextureCoordinate.Y = 1; mVertices[2].Scale = new Vector2(1, -1); mVertices[3].TextureCoordinate.X = 0; mVertices[3].TextureCoordinate.Y = 1; mVertices[3].Scale = new Vector2(-1, -1); #if WINDOWS_PHONE || MONODROID mVertices[0].Color.X = 1; mVertices[1].Color.X = 1; mVertices[2].Color.X = 1; mVertices[3].Color.X = 1; mVertices[0].Color.Y = 1; mVertices[1].Color.Y = 1; mVertices[2].Color.Y = 1; mVertices[3].Color.Y = 1; mVertices[0].Color.Z = 1; mVertices[1].Color.Z = 1; mVertices[2].Color.Z = 1; mVertices[3].Color.Z = 1; mVertices[0].Color.W = 1; mVertices[1].Color.W = 1; mVertices[2].Color.W = 1; mVertices[3].Color.W = 1; #endif Alpha = GraphicalEnumerations.MaxColorComponentValue; #if FRB_XNA ColorOperation = ColorOperation.Texture; #else ColorOperation = TextureOperation.SelectArg1; #endif mAnimationChains = new AnimationChainList(); mCurrentChainIndex = -1; mAnimationSpeed = 1; mTextureAddressMode = TextureAddressMode.Clamp; mCursorSelectable = true; }
/// <summary> /// Resizes the texture. (If original texture has mipmaps, all mipmap levels are automatically /// recreated.) /// </summary> /// <param name="width">The new width.</param> /// <param name="height">The new height.</param> /// <param name="depth">The new depth. Must be 1 for 2D textures and cube map textures.</param> /// <param name="filter">The filter to use for resizing.</param> /// <param name="alphaTransparency"> /// <see langword="true"/> if the image contains uses non-premultiplied alpha; otherwise, /// <see langword="false"/> if the image uses premultiplied alpha or has no alpha. /// </param> /// <param name="wrapMode"> /// The texture address mode that will be used for sampling the at runtime. /// </param> /// <returns>The resized texture.</returns> public Texture Resize(int width, int height, int depth, ResizeFilter filter, bool alphaTransparency, TextureAddressMode wrapMode) { var description = Description; description.Width = width; description.Height = height; description.Depth = depth; var resizedTexture = new Texture(description); // Resize mipmap level 0. for (int arrayIndex = 0; arrayIndex < description.ArraySize; arrayIndex++) TextureHelper.Resize(this, 0, arrayIndex, resizedTexture, 0, arrayIndex, filter, alphaTransparency, wrapMode); // Regenerate mipmap levels, if necessary. if (description.MipLevels > 1) resizedTexture.GenerateMipmaps(filter, alphaTransparency, wrapMode); return resizedTexture; }
public GL10() { int num; this.color = new float[4]; this.clearColor = Color.Black; this.ColorWriteChannels = ColorWriteChannels.All; this.AlphaDestinationBlend = Blend.InverseSourceAlpha; this.depthFunc = CompareFunction.Always; this.textureFilter = TextureFilter.Linear; this.textureAddressU = TextureAddressMode.Clamp; this.textureAddressV = TextureAddressMode.Clamp; this.vertex = new Vertex[8]; this.texture = new Texture[0x100]; this.matrixStack = new Stack<Matrix>(); this.effect = new BasicEffect(GLEx.device); this.effect.VertexColorEnabled = true; this.alphaTestEffect = new AlphaTestEffect(GLEx.device); this.alphaTestEffect.VertexColorEnabled = true; for (num = 0; num < this.vertex.Length; num++) { this.vertex[num] = new Vertex(); } for (num = 0; num < 4; num++) { this.color[num] = 1f; } }
public void GLTexParameterf(int target, int pname, float param) { switch (pname) { case 0x2800: switch (((int)param)) { case 0x2600: this.textureFilter = TextureFilter.Point; break; case 0x2601: this.textureFilter = TextureFilter.Linear; break; } break; case 0x2802: switch (((int)param)) { case 0x2901: this.textureAddressU = TextureAddressMode.Wrap; break; case 0x812f: this.textureAddressU = TextureAddressMode.Clamp; break; } break; case 0x2803: switch (((int)param)) { case 0x2901: this.textureAddressV = TextureAddressMode.Wrap; break; case 0x812f: this.textureAddressV = TextureAddressMode.Clamp; break; } break; } }
private AtlasTextureElement CreateElementFromFile(string name, int borderSize, TextureAddressMode borderModeU, TextureAddressMode borderModeV, RotableRectangle? imageRegion = null) { using (var texTool = new TextureTool()) { var image = LoadImage(texTool, new UFile(ImageInputPath + "/" + name + ".png")); var region = imageRegion ?? new RotableRectangle(0, 0, image.Description.Width, image.Description.Height); return new AtlasTextureElement(name, image, region, borderSize, borderModeU, borderModeV, Color.SteelBlue); } }
private AtlasTextureElement CreateElement(string name, int width, int height, int borderSize, TextureAddressMode borderMode, Color? color = null, Color? borderColor = null) { Image image = null; if (color != null) image = CreateMockTexture(width, height, color.Value); return new AtlasTextureElement(name, image, new RotableRectangle(0, 0, width, height), borderSize, borderMode, borderMode, borderColor); }
/// <summary> /// Resets the render instance's fields to defaults. /// </summary> public virtual void Reset() { VertexBuffer = null; IndexBuffer = null; VertexDeclaration = null; Material = null; MaterialInstanceData = null; Opacity = 1.0f; UTextureAddressMode = TextureAddressMode.Clamp; VTextureAddressMode = TextureAddressMode.Clamp; ObjectTransform = Matrix.Identity; SortPoint = Vector3.Zero; IsSortPointSet = false; VertexSize = 0; PrimitiveType = PrimitiveType.TriangleStrip; BaseVertex = 0; VertexCount = 0; StartIndex = 0; PrimitiveCount = 0; Type = RenderInstanceType.UndefinedType; MaterialSortKey = 0; GeometrySortKey = 0; IsReset = true; }
/// <summary> /// Copies a render instance's fields into this render instance. /// </summary> /// <param name="src">The render instance to copy.</param> public void Copy(RenderInstance src) { VertexBuffer = src.VertexBuffer; IndexBuffer = src.IndexBuffer; VertexDeclaration = src.VertexDeclaration; Material = src.Material; ObjectTransform = src.ObjectTransform; WorldBox = src.WorldBox; UTextureAddressMode = src.UTextureAddressMode; VTextureAddressMode = src.VTextureAddressMode; VertexSize = src.VertexSize; PrimitiveType = src.PrimitiveType; BaseVertex = src.BaseVertex; VertexCount = src.VertexCount; StartIndex = src.StartIndex; PrimitiveCount = src.PrimitiveCount; Type = src.Type; SortPoint = src.SortPoint; IsSortPointSet = src.IsSortPointSet; Opacity = src.Opacity; }
/// <summary> /// (Re-)Generates all mipmap levels. /// </summary> /// <param name="filter">The filter to use for resizing.</param> /// <param name="alphaTransparency"> /// <see langword="true"/> if the image contains uses non-premultiplied alpha; otherwise, /// <see langword="false"/> if the image uses premultiplied alpha or has no alpha. /// </param> /// <param name="wrapMode"> /// The texture address mode that will be used for sampling the at runtime. /// </param> public void GenerateMipmaps(ResizeFilter filter, bool alphaTransparency, TextureAddressMode wrapMode) { var oldDescription = Description; var newDescription = Description; // Determine number of mipmap levels. if (oldDescription.Dimension == TextureDimension.Texture3D) newDescription.MipLevels = TextureHelper.CalculateMipLevels(oldDescription.Width, oldDescription.Height, oldDescription.Depth); else newDescription.MipLevels = TextureHelper.CalculateMipLevels(oldDescription.Width, oldDescription.Height); if (oldDescription.MipLevels != newDescription.MipLevels) { // Update Description and Images. var oldImages = Images; Description = newDescription; #if DEBUG ValidateTexture(newDescription); #endif // Recreate image collection. (Mipmap level 0 is copied from existing image collection.) Images = CreateImageCollection(newDescription, true); for (int arrayIndex = 0; arrayIndex < newDescription.ArraySize; arrayIndex++) { for (int zIndex = 0; zIndex < newDescription.Depth; zIndex++) { int oldIndex = oldDescription.GetImageIndex(0, arrayIndex, zIndex); int newIndex = newDescription.GetImageIndex(0, arrayIndex, zIndex); Images[newIndex] = oldImages[oldIndex]; } } } // Downsample mipmap levels. for (int arrayIndex = 0; arrayIndex < newDescription.ArraySize; arrayIndex++) for (int mipIndex = 0; mipIndex < newDescription.MipLevels - 1; mipIndex++) TextureHelper.Resize(this, mipIndex, arrayIndex, this, mipIndex + 1, arrayIndex, filter, alphaTransparency, wrapMode); }
private int GetWrapMode(TextureAddressMode textureAddressMode) { switch(textureAddressMode) { case TextureAddressMode.Clamp: return (int)TextureWrapMode.ClampToEdge; case TextureAddressMode.Wrap: return (int)TextureWrapMode.Repeat; case TextureAddressMode.Mirror: return (int)All.MirroredRepeat; default: throw new ArgumentException("No support for " + textureAddressMode); } }
private static SharpDX.Direct3D11.TextureAddressMode GetAddressMode(TextureAddressMode mode) { switch (mode) { case TextureAddressMode.Clamp: return SharpDX.Direct3D11.TextureAddressMode.Clamp; case TextureAddressMode.Mirror: return SharpDX.Direct3D11.TextureAddressMode.Mirror; case TextureAddressMode.Wrap: return SharpDX.Direct3D11.TextureAddressMode.Wrap; case TextureAddressMode.Border: return SharpDX.Direct3D11.TextureAddressMode.Border; default: throw new ArgumentException("Invalid texture address mode!"); } }
public void SetTextureAddressMode(int index, TextureAddressMode mode) { GFX.Device.SamplerStates[index].AddressU = mode; GFX.Device.SamplerStates[index].AddressV = mode; GFX.Device.SamplerStates[index].AddressW = mode; }
private int GetWrapMode(TextureAddressMode textureAddressMode) { switch(textureAddressMode) { case TextureAddressMode.Clamp: return (int)TextureWrapMode.Clamp; case TextureAddressMode.Wrap: return (int)TextureWrapMode.Repeat; case TextureAddressMode.Mirror: return (int)TextureWrapMode.MirroredRepeat; default: throw new NotImplementedException("No support for " + textureAddressMode); } }
internal static SamplerState New(GraphicsDevice device, string name, Filter filterMode, TextureAddressMode uvwMode) { var description = SamplerStateDescription.Default(); description.Filter = filterMode; description.AddressU = uvwMode; description.AddressV = uvwMode; description.AddressW = uvwMode; return New(device, name, description); }