void OnGUI () { GUILayout.Label ("Image to Export", EditorStyles.boldLabel); exportImg = (UPAImage)EditorGUILayout.ObjectField (exportImg, typeof(UPAImage), false); GUILayout.Label ("Export Settings", EditorStyles.boldLabel); texExtension = (TextureExtension)EditorGUILayout.EnumPopup("Save As:", texExtension); if (texExtension == TextureExtension.JPG) { #if UNITY_4_2 GUILayout.Label ("Error: Export to JPG requires Unity 4.5+"); #elif UNITY_4_3 GUILayout.Label ("Error: Export to JPG requires Unity 4.5+"); #endif GUILayout.Label ("Warning: JPG files will lose transparency."); } texType = (TextureType)EditorGUILayout.EnumPopup("Texture Type:", texType); EditorGUILayout.Space (); if ( GUILayout.Button ("Export", GUILayout.Height(30)) ) { if (exportImg == null) { EditorUtility.DisplayDialog( "Select Image", "You Must Select an Image first!", "Ok"); return; } bool succes = UPASession.ExportImage ( exportImg, texType, texExtension ); if (succes) this.Close(); UPAEditorWindow.window.Repaint(); } }
internal static void ApplyTexture(Body b, TextureType textureType) { foreach (Fixture f in b.FixtureList) { ApplyTexture(f, textureType); } }
/// <summary> /// Determines whether this model has the specified texture type. /// </summary> /// <param name="type">The type.</param> /// <returns> /// <c>true</c> if the specified type has texture; otherwise, <c>false</c>. /// </returns> public bool HasTexture(TextureType type) { if (type == TextureType.ENVIRONMENT) { return textureInformation.getCubeTexture(TextureType.ENVIRONMENT) != null; } if (type == TextureType.DIFFUSE) { return textureInformation.getTexture(TextureType.DIFFUSE) != null; } else if (type == TextureType.BUMP) { return textureInformation.getTexture(TextureType.BUMP) != null; } else if (type == TextureType.SPECULAR) { return textureInformation.getTexture(TextureType.SPECULAR) != null; } else if (type == TextureType.GLOW) { return textureInformation.getTexture(TextureType.GLOW) != null; } else if (type == TextureType.PARALAX) { return textureInformation.getTexture(TextureType.PARALAX) != null; } return false; }
private static SFML.Graphics.Texture GetRightTexture(string name, TextureType type) { if (type == TextureType.SFML) return TextureManager.GetTexture(name); else return FramedTextureManager.GetTexture(name); }
public bool Contains( String name, TextureType type ) { if ( type == TextureType.Diffuse ) return myDiffuseTextures.ContainsKey( name ); else return myMaskTextures.ContainsKey( name ); }
public void Create(TextureType type, Geometry2D.Integer.Size size) { this.SetFormat(type, size); this.Use(); this.Create(IntPtr.Zero); this.UnUse(); }
public static bool ExportImage(UPAImage img, TextureType type, TextureExtension extension) { string path = EditorUtility.SaveFilePanel( "Export image as " + extension.ToString(), "Assets/", img.name + "." + extension.ToString().ToLower(), extension.ToString().ToLower()); if (path.Length == 0) return false; byte[] bytes; if (extension == TextureExtension.PNG) { // Encode texture into PNG bytes = img.GetFinalImage(true).EncodeToPNG(); } else { // Encode texture into JPG #if UNITY_4_2 bytes = img.GetFinalImage(true).EncodeToPNG(); #elif UNITY_4_3 bytes = img.GetFinalImage(true).EncodeToPNG(); #elif UNITY_4_5 bytes = img.GetFinalImage(true).EncodeToJPG(); #else bytes = img.GetFinalImage(true).EncodeToJPG(); #endif } path = FileUtil.GetProjectRelativePath(path); //Write to a file in the project folder File.WriteAllBytes(path, bytes); AssetDatabase.Refresh(); TextureImporter texImp = AssetImporter.GetAtPath(path) as TextureImporter; if (type == TextureType.texture) texImp.textureType = TextureImporterType.Image; else if (type == TextureType.sprite) { texImp.textureType = TextureImporterType.Sprite; #if UNITY_4_2 texImp.spritePixelsToUnits = 10; #elif UNITY_4_3 texImp.spritePixelsToUnits = 10; #elif UNITY_4_5 texImp.spritePixelsToUnits = 10; #else texImp.spritePixelsPerUnit = 10; #endif } texImp.filterMode = FilterMode.Point; texImp.textureFormat = TextureImporterFormat.AutomaticTruecolor; AssetDatabase.ImportAsset(path); return true; }
public Texture2D GetTexture( TextureType type ) { if ( this.textures.ContainsKey( type ) ) { return this.textures[ type ]; } return null; }
public override Texture Create(string name, TextureType type) { GLTexture texture = new GLTexture(name, type); texture.Enable32Bit(is32Bit); return texture; }
public ReflectionMap() { this.maskMapSamplerIndex = 0; this.reflectionMapSamplerIndex = 0; this.reflectionMapType = TextureType.TwoD; this.reflectionPowerChanged = true; this.reflectionPowerValue = 0.05f; }
public static Texture2D GetTexture(TextureType type, object id) { List<TextureEntity> entities = new List<TextureEntity>(); if (type == TextureType.Menu) { entities = textureEntities; } return entities[(int) id].Texture; }
public Texture2D this[String name, TextureType type] { get { if ( type == TextureType.Diffuse ) return myDiffuseTextures[ name ]; else return myMaskTextures[ name ]; } }
public ITexture CreateTexture(TextureType type) { switch (type) { case TextureType.BaseTexture: return new Texture(); default: throw new ArgumentOutOfRangeException("type"); } }
public idImage(string name, TextureType type, TextureFilter filter, TextureRepeat repeat, TextureDepth depth, CubeFiles cubeMap, bool allowDownSize) { _name = name; _type = type; _filter = filter; _repeat = repeat; _depth = depth; _cubeFiles = cubeMap; _allowDownSize = allowDownSize; }
// background loading information. /*private idImage _partialImage; // shrunken, space-saving version * private bool _isPartialImage; // true if this is pointed to by another image*/ #endregion #region Constructor public idImage(string name, ImageLoadCallback generator) { _name = name; _generator = generator; _type = TextureType.Disabled; _filter = TextureFilter.Default; _repeat = TextureRepeat.Repeat; _depth = TextureDepth.Default; _cubeFiles = CubeFiles.TwoD; }
}; //Icon的路径,用于动态图集 #endregion #region 场景贴图 #endregion void OnPreprocessTexture() { //获得importer实例 TextureImporter tImporter = assetImporter as TextureImporter; TextureType textureType = GetTextureType(tImporter.assetPath); bool hasAlpha = false; if (tImporter.alphaSource != TextureImporterAlphaSource.None) { hasAlpha = tImporter.DoesSourceTextureHaveAlpha() || tImporter.alphaSource == TextureImporterAlphaSource.FromGrayScale; } if (textureType == TextureType.UICommon) { tImporter.textureType = TextureImporterType.Sprite; tImporter.spriteImportMode = SpriteImportMode.Single; string atlasName = new DirectoryInfo(Path.GetDirectoryName(assetPath)).Name.ToLower(); tImporter.spritePackingTag = atlasName; //设置Read/Write Enabled开关,不勾选 tImporter.isReadable = false; tImporter.alphaIsTransparency = hasAlpha; //设置UI纹理Generate Mipmaps开关,不勾选 tImporter.mipmapEnabled = false; tImporter.streamingMipmaps = false; //设置UI纹理WrapMode开关,Clamp tImporter.wrapMode = TextureWrapMode.Clamp; } else if (textureType == TextureType.UITexture || textureType == TextureType.UITextureNoAlpha || textureType == TextureType.UIIcon) { tImporter.textureType = TextureImporterType.Default; tImporter.alphaIsTransparency = hasAlpha; if (textureType == TextureType.UIIcon) { tImporter.npotScale = TextureImporterNPOTScale.ToNearest; } tImporter.isReadable = false; //设置UI纹理Generate Mipmaps开关,不勾选 tImporter.mipmapEnabled = false; tImporter.streamingMipmaps = false; } var standardAndroidImporter = GetAndroidStandardImportSetting(tImporter, textureType, hasAlpha); tImporter.SetPlatformTextureSettings(standardAndroidImporter); var standardIOSImporter = GetIOSStandardImportSetting(tImporter, textureType, hasAlpha); tImporter.SetPlatformTextureSettings(standardIOSImporter); var standardWinImporter = GetWinStandardImportSetting(tImporter, textureType, hasAlpha); tImporter.SetPlatformTextureSettings(standardWinImporter); }
public Tile(Point grid, string assetname = "", TileType tp = TileType.Background, TextureType tt = TextureType.None, int layer = 0, string id = "") : base(assetname, layer, id, 0) { tileobject = TileObject.Tile; this.grid = grid; texturetype = tt; type = tp; drawPassengers = new List <string>(); passengers = new List <string>(); hasItem = 0; }
private static void RefreshTexture(TextureType textureType) { texture[(int)textureType] = new Texture2D(width, height, TextureFormat.ARGB32, false); for (int i = 0; i < World.Cells.Length; i++) { SetCellTexture(i, textureType); } texture[(int)textureType].filterMode = FilterMode.Point; texture[(int)textureType].Apply(); }
//public static Texture2D CreateTexture(TextureType tType) //{ // size = (int)Math.Ceiling(Math.Sqrt(World.Cells.Length)); // scale = 10; // Debug.Log("Texture size: " + size); // int width = size*scale; // int height = size*scale; // Debug.Log("Create texture for world of " + World.Cells.Length + " cells. Size of texture aray is: " + size + "*" + size); // switch (tType) // { // case TextureType.Blank: // { // return new Texture2D(width, height); // } // default: // { // return new Texture2D(width, height); // } // } // Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false); // texture.filterMode = FilterMode.Point; // for (int i = 0; i < World.Cells.Length; i++) // { // Color col = World.CellColor[i]; // texture = SetCellTexture(i, col, texture); // } // ////Test Cor Cell 01 // //for (int x = 0; x <= scale - 1; x++) // //{ // // for (int y = 0; y <= scale - 1; y++) // // { // // texture.SetPixel(x, y, Color.red); // // } // //} // texture.name = "Generated Texture"; // texture.Apply(); // buildTexture = texture; // return texture; //} public static void UpdateTexture(TextureType textureType, List <int> id) { Texture2D tempTexture = texture[(int)textureType]; foreach (int i in id) { SetCellTexture(i, textureType); } tempTexture.Apply(); texture[(int)textureType] = tempTexture; }
public static uint ByteSize(this TextureType T) { if (T == TextureType.DXT5) { return(16); } else { return(8); } }
public ITexture CreateTexture(TextureType type) { switch (type) { case TextureType.BaseTexture: return(new Texture()); default: throw new ArgumentOutOfRangeException("type"); } }
/// <summary> /// Constructs a new instance of the <see cref="MaterialProperty"/> class. Creates a Color3D property. /// </summary> /// <param name="baseName">Base name of the property</param> /// <param name="value">Property value</param> public MaterialProperty(String baseName, Color3D value) { m_name = baseName; m_type = PropertyType.Float; m_texIndex = 0; m_texType = TextureType.None; m_rawValue = null; SetColor3DValue(value); AssertIsBaseName(); }
/// <summary> /// Constructs a new instance of the <see cref="MaterialProperty"/> class. Creates a texture property. /// </summary> /// <param name="baseName">Base name of the property</param> /// <param name="value">Property value</param> /// <param name="texType">Texture type</param> /// <param name="textureIndex">Texture index</param> public MaterialProperty(String baseName, String value, TextureType texType, int textureIndex) { m_name = baseName; m_type = PropertyType.String; m_texIndex = textureIndex; m_texType = texType; m_rawValue = null; SetStringValue(value); AssertIsBaseName(); }
private static SFML.Graphics.Texture GetRightTexture(string name, TextureType type) { if (type == TextureType.SFML) { return(TextureManager.GetTexture(name)); } else { return(FramedTextureManager.GetTexture(name)); } }
/// <summary> /// Constructs a new instance of the <see cref="MaterialProperty"/> class. Creates a string property. /// </summary> /// <param name="baseName">Base name of the property</param> /// <param name="value">Property value</param> public MaterialProperty(String baseName, String value) { m_name = baseName; m_type = PropertyType.String; m_texIndex = 0; m_texType = TextureType.None; m_rawValue = null; SetStringValue(value); AssertIsBaseName(); }
public CollisionPlane(int offset, Vector3 direction, Material material, TextureType textureIn, Rectangle rectArea) : base(rectArea, textureIn) { this.Offset = offset; this.Direction = direction; this.Material = material; }
/// <summary> /// Constructs a new instance of the <see cref="MaterialProperty"/> class. Creates a int array property. /// </summary> /// <param name="baseName">Base name of the property</param> /// <param name="values">Property values</param> public MaterialProperty(String baseName, int[] values) { m_name = baseName; m_type = PropertyType.Integer; m_texIndex = 0; m_texType = TextureType.None; m_rawValue = null; SetIntegerArrayValue(values); AssertIsBaseName(); }
public void WriteTextureToRAM(DescriptorHeap shaderRenderViewHeap) { for (TextureType type = TextureType.Diffuse; type < TextureType.Bump; type++) { if (!HasTexture[type]) { continue; } WriteTextureToRAM(shaderRenderViewHeap, type); } }
/// <summary> /// Constructs a new instance of the <see cref="MaterialProperty"/> class. Constructs a boolean property. /// </summary> /// <param name="baseName">Name of the property</param> /// <param name="value">Property value</param> public MaterialProperty(String baseName, bool value) { m_name = baseName; m_type = PropertyType.Integer; m_texIndex = 0; m_texType = TextureType.None; m_rawValue = null; SetBooleanValue(value); AssertIsBaseName(); }
public bool Contains(String name, TextureType type) { if (type == TextureType.Diffuse) { return(myDiffuseTextures.ContainsKey(name)); } else { return(myMaskTextures.ContainsKey(name)); } }
public Particle(TextureType textureType, Vector2 position, Vector2 velocity, float angle, float angularVelocity, Color color, float size, int ttl) { this.TextureType = textureType; Position = position; Velocity = velocity; Angle = angle; AngularVelocity = angularVelocity; Color = color; Size = size; TTL = ttl; }
public GuardianDrawData(TextureType tt, Texture2D Texture, Vector2 Position, Rectangle?Source, Color color, float Rotation, Vector2 Origin, Vector2 Scale, SpriteEffects seffect) { this.textureType = tt; this.Texture = Texture; this.Position = Position; this.color = color; this.Source = Source; this.Rotation = Rotation; this.Origin = Origin; this.Scale = Scale; this.Seffects = seffect; }
internal Asset(int x, int y, int sizeX, int sizeY, TextureType type, bool gravityEffected) { _Position = new Vector2(x, y); _Size = new Vector2(sizeX, sizeY); _Type = type; _Velocity = new Vector2(0); _GravityEffected = gravityEffected; if (!_GravityEffected) { _Velocity = new Vector2(-10, 0); } }
public GameMouse() : base(200, "mouse") { item = false; tile = false; asset = ""; entityBoundingBox = 0; texturetype = TextureType.Grass; tiletype = TileType.Floor; tileobject = TileObject.Tile; entitytype = EntityType.None; }
public AstTextureOperation( Instruction inst, TextureType type, TextureFlags flags, int handle, int compMask, params IAstNode[] sources) : base(inst, compMask, sources) { Type = type; Flags = flags; Handle = handle; }
public static SFML.Graphics.Texture GetTexture(string name) { TextureType type = TextureType.SFML; if (ContainsTexture(name, out type)) { return(GetRightTexture(name, type)); } throw new ArgumentException("Texture '" + name + "' is not loaded. " + "source:GTM.GetTexture()"); }
public override bool IsHardwareFilteringSupported(TextureType ttype, PixelFormat format, TextureUsage usage, bool preciseFormatOnly) { if (!preciseFormatOnly) { format = GetNativeFormat(ttype, format, usage); } var rs = (D3D9RenderSystem)Root.Instance.RenderSystem; return(rs.CheckTextureFilteringSupported(ttype, format, usage)); }
public Texture(Stream headerStream, Stream dataStream) { using (BinaryReader headerReader = new BinaryReader(headerStream)) using (BinaryReader dataReader = new BinaryReader(dataStream)) { header = headerReader.Read <TextureHeader>(); if (header.dataSize != 0) { return; } format = header.Format(); if (format == TextureType.Unknown) { return; } rawHeader = dataReader.Read <RawTextureHeader>(); size = rawHeader.imageSize / header.Format().ByteSize(); color1 = new uint[size]; color2 = new uint[size]; color3 = new ushort[size]; color4 = new ushort[size]; color5 = new uint[size]; if ((byte)header.format > 72) { for (int i = 0; i < size; ++i) { color3[i] = dataReader.ReadUInt16(); } for (int i = 0; i < size; ++i) { color4[i] = dataReader.ReadUInt16(); color5[i] = dataReader.ReadUInt32(); } } if ((byte)header.format < 80) { for (int i = 0; i < size; ++i) { color1[i] = dataReader.ReadUInt32(); } for (int i = 0; i < size; ++i) { color2[i] = dataReader.ReadUInt32(); } } } loaded = true; }
List <Texture> LoadTextures(Material mat, TextureType type) { List <Texture> retval = new List <Texture>(); for (int i = 0; i < mat.GetMaterialTextureCount(type); i++) { mat.GetMaterialTexture(type, i, out var tex); Console.WriteLine(tex.FilePath); retval.Add(texFromFile(tex.FilePath)); } return(retval); }
static void SetTexture(MaterialAsset mat, Texture diffuse, TextureType type) { //MaterialAsset mat = DiffuseMaterialFactory.Create(); switch (type) { case TextureType.Diffuse: ((ComputeTextureColor)((MaterialDiffuseMapFeature)mat.Attributes.Diffuse).DiffuseMap).Texture = diffuse; break; } //((ComputeTextureColor)((MaterialDiffuseMapFeature)mat.Attributes.Diffuse).DiffuseMap).Texture = diffuse; //return mat; }
private TBitmap?GetDefaultTexture(TextureType type) { var color = type switch { TextureType.Diffuse => Color.Fuchsia, TextureType.Normal => Color.Blue, TextureType.Specular => Color.FromArgb(255, 255 / 3, 255 / 3, 255 / 3), _ => throw new ArgumentException($"Unsupported texture type: {type}", nameof(type)), }; return(_loader.FromColor(color)); }
internal OpenGLTexture(byte[] data, TextureType type, int width, int height, int depth, TextureFormat format, TextureFilter minFilter, TextureFilter magFilter, TextureWrap wrapX, TextureWrap?wrapY, TextureWrap?wrapZ) { Type = type; Width = width; Height = height; Depth = depth; Format = format; id = GL.GenTexture(); switch (Type) { case TextureType.Texture1D when Platform.GraphicsBackend == GraphicsBackend.OpenGL: // Not available in OpenGL ES TextureTarget = TextureTarget.Texture1D; break; case TextureType.Texture1DArray when Platform.GraphicsBackend == GraphicsBackend.OpenGL: // Not available in OpenGL ES TextureTarget = TextureTarget.Texture1DArray; break; case TextureType.Texture2D: TextureTarget = TextureTarget.Texture2D; WrapY = wrapY.Value; break; case TextureType.Texture2DArray: TextureTarget = TextureTarget.Texture2DArray; WrapY = wrapY.Value; break; case TextureType.Texture2DMultisample: TextureTarget = TextureTarget.Texture2DMultisample; WrapY = wrapY.Value; break; case TextureType.Texture3D: TextureTarget = TextureTarget.Texture3D; WrapY = wrapY.Value; WrapZ = wrapZ.Value; break; default: throw new IllegalValueException(typeof(TextureType), Type); } MinFilter = minFilter; MagFilter = magFilter; WrapX = wrapX; SetData(data); }
protected void DrawTexturePicker(DrawInfo drawInfo) { Rect newRect = m_previewRect; Texture currentValue = m_materialMode ? m_materialValue : m_defaultValue; //??? //m_showPreview = true; bool showButtons = m_currentParameterType != PropertyType.Global; if (currentValue == null) { GUI.Label(newRect, string.Empty, UIUtils.ObjectFieldThumb); } else { DrawPreview(drawInfo, m_previewRect); } if (ContainerGraph.LodLevel <= ParentGraph.NodeLOD.LOD2) { Rect butRect = m_previewRect; butRect.y -= 1; butRect.x += 1; Rect smallButton = newRect; smallButton.height = 14 * drawInfo.InvertedZoom; smallButton.y = newRect.yMax - smallButton.height - 2; smallButton.width = 40 * drawInfo.InvertedZoom; smallButton.x = newRect.xMax - smallButton.width - 2; if (currentValue == null) { if (m_previousType != m_currentType) { m_previousType = m_currentType; m_labelText = "None (" + m_currentType.ToString() + ")"; } GUI.Label(newRect, m_labelText, UIUtils.ObjectFieldThumbOverlay); } else if (showButtons) { DrawPreviewMaskButtonsRepaint(drawInfo, butRect); } if (showButtons) { GUI.Label(smallButton, "Select", UIUtils.GetCustomStyle(CustomStyle.SamplerButton)); } } GUI.Label(newRect, string.Empty, UIUtils.GetCustomStyle(CustomStyle.SamplerFrame)); }
/// <summary> /// Constructs a new TextureSlot. /// </summary> /// <param name="filePath">Texture filepath</param> /// <param name="typeSemantic">Texture type semantic</param> /// <param name="texIndex">Texture index in the material</param> /// <param name="mapping">Texture mapping</param> /// <param name="uvIndex">UV channel in mesh that corresponds to this texture</param> /// <param name="blendFactor">Blend factor</param> /// <param name="texOp">Texture operation</param> /// <param name="wrapMode">Texture wrap mode</param> /// <param name="flags">Misc flags</param> public TextureSlot(String filePath, TextureType typeSemantic, uint texIndex, TextureMapping mapping, uint uvIndex, float blendFactor, TextureOperation texOp, TextureWrapMode wrapMode, uint flags) { _filePath = (filePath == null) ? String.Empty : filePath; _type = typeSemantic; _index = texIndex; _mapping = mapping; _uvIndex = uvIndex; _blendFactor = blendFactor; _texOp = texOp; _wrapMode = wrapMode; _flags = flags; }
public static bool ContainsTexture(string name, out TextureType type) { type = TextureType.SFML; //if in collections, type's not dummy //if not in collection : type's dummy to respect 'out' if (CollectionHelper.DictionaryContains<SFML.Graphics.Texture>(TextureManager.Textures, name)) return true; else if (CollectionHelper.DictionaryContains<FramedTexture>(FramedTextureManager.Textures, name)) { type = TextureType.Framed; return true; } return false; }
public static void LoadTexture(String name, ref Texture texture, TextureType type) { Game.PrintChat(name.ToLower()); if ((type == TextureType.Default) && MyResources.ContainsKey(name.ToLower())) { try { texture = Texture.FromMemory(Drawing.Direct3DDevice, MyResources[name.ToLower()]); } catch (Exception ex) { Console.WriteLine("SAwarness: Couldn't load texture: " + name + "\n Ex: " + ex); } } }
private static List<TextureEntity> LoadTextureEntities(ContentManager content ,TextureType type,params string[] filename) { var entities = new List<TextureEntity>(); foreach (string entry in filename) { string formatted = string.Format("{0}/{1}", type.ToString(), entry); TextureEntity entity = new TextureEntity() { Key = entry, Texture = content.Load<Texture2D>(formatted) }; entities.Add(entity); } return entities; }
public override Axiom.Media.PixelFormat GetNativeFormat( TextureType ttype, PixelFormat format, TextureUsage usage ) { // Basic filtering var d3dPF = D3D9Helper.ConvertEnum( D3D9Helper.GetClosestSupported( format ) ); // Calculate usage var d3dusage = D3D9.Usage.None; var pool = D3D9.Pool.Managed; if ( ( usage & TextureUsage.RenderTarget ) != 0 ) { d3dusage |= D3D9.Usage.RenderTarget; pool = D3D9.Pool.Default; } if ( ( usage & TextureUsage.Dynamic ) != 0 ) { d3dusage |= D3D9.Usage.Dynamic; pool = D3D9.Pool.Default; } var curDevice = D3D9RenderSystem.ActiveD3D9Device; // Use D3DX to adjust pixel format switch ( ttype ) { case TextureType.OneD: case TextureType.TwoD: var tReqs = D3D9.Texture.CheckRequirements( curDevice, 0, 0, 0, d3dusage, D3D9Helper.ConvertEnum( format ), pool ); d3dPF = tReqs.Format; break; case TextureType.ThreeD: var volReqs = D3D9.VolumeTexture.CheckRequirements( curDevice, 0, 0, 0, 0, d3dusage, D3D9Helper.ConvertEnum( format ), pool ); d3dPF = volReqs.Format; break; case TextureType.CubeMap: var cubeReqs = D3D9.CubeTexture.CheckRequirements( curDevice, 0, 0, d3dusage, D3D9Helper.ConvertEnum( format ), pool ); d3dPF = cubeReqs.Format; break; } return D3D9Helper.ConvertEnum( d3dPF ); }
/// <summary> /// Set the texture that the mesh use /// </summary> /// <param name="texturePath">Where on disk the texture is saved</param> /// <param name="textType"></param> public FXResourceVariable GetTexture(TextureType textType) { switch (textType) { case TextureType.Diffuse: return m_TextureDiffuse; case TextureType.Bump: return m_TextureBump; case TextureType.Normal: return m_TextureNormal; case TextureType.Lightmap: return m_TextureLightmap; case TextureType.Heightmap: return m_TextureHighmap; } return null; }
protected override void SetFormat(TextureType type, Geometry2D.Integer.Size size) { switch (this.Type = type) { default: case TextureType.Rgba: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgba; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Bgra; break; case TextureType.Rgb: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Rgb; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Bgr; break; case TextureType.Monochrome: this.InternalFormat = OpenTK.Graphics.OpenGL.PixelInternalFormat.Luminance; this.Format = OpenTK.Graphics.OpenGL.PixelFormat.Luminance; break; } this.Size = this.Context.ClampTextureSize(size); }
public static Texture2D AsTexture(this byte[] textureBytes, string textureName, TextureType type) { switch (type) { case TextureType.Default: { var texture = new Texture2D(1, 1, TextureFormat.ARGB32, true); texture.name = textureName; texture.LoadImage(textureBytes); texture.anisoLevel = 8; texture.filterMode = FilterMode.Bilinear; texture.Compress(true); texture.Apply(true, true); return texture; } case TextureType.LOD: { var texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); texture.name = textureName; texture.LoadImage(textureBytes); texture.anisoLevel = 8; texture.filterMode = FilterMode.Bilinear; texture.Compress(true); texture.Apply(); return texture; } case TextureType.UI: { var texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); texture.name = textureName; texture.LoadImage(textureBytes); texture.Apply(); return texture; } default: throw new ArgumentOutOfRangeException("type"); } }
public Texture CreateTexture(TextureType type, Geometry2D.Integer.Size size) { this.Free(); Composition composition = this.compositionBin.Recycle(type, size); Texture result; if (composition.NotNull()) { composition.Renderer.Use(); composition.Renderer.UnSetClip(); composition.Renderer.Clear(); composition.Renderer.Unuse(); result = composition.Texture; } else result = this.textureBin.Recycle(type, size); if (result.IsNull()) { result = this.AllocateTexture(); result.Create(type, size); } return result; }
// This ends up just discarding the format passed in; the C# methods don't let you supply // a "recommended" format. Ah well. public override Axiom.Media.PixelFormat GetNativeFormat( TextureType ttype, PixelFormat format, TextureUsage usage ) { // Basic filtering D3D.Format d3dPF = D3DHelper.ConvertEnum( D3DHelper.GetClosestSupported( format ) ); // Calculate usage D3D.Usage d3dusage = 0; D3D.Pool pool = D3D.Pool.Managed; if ( ( usage & TextureUsage.RenderTarget ) != 0 ) { d3dusage |= D3D.Usage.RenderTarget; pool = D3D.Pool.Default; } if ( ( usage & TextureUsage.Dynamic ) != 0 ) { d3dusage |= D3D.Usage.Dynamic; pool = D3D.Pool.Default; } // Use D3DX to adjust pixel format switch ( ttype ) { case TextureType.OneD: case TextureType.TwoD: D3D.TextureRequirements tReqs = D3D.Texture.CheckRequirements( device, 0, 0, 0, d3dusage, D3DHelper.ConvertEnum( format ), pool ); d3dPF = tReqs.Format; break; case TextureType.ThreeD: D3D.VolumeTextureRequirements volReqs = D3D.VolumeTexture.CheckRequirements( device, 0, 0, 0, 0, d3dusage, D3DHelper.ConvertEnum( format ), pool ); d3dPF = volReqs.Format; break; case TextureType.CubeMap: D3D.CubeTextureRequirements cubeReqs = D3D.CubeTexture.CheckRequirements( device, 0, 0, d3dusage, D3DHelper.ConvertEnum( format ), pool ); d3dPF = cubeReqs.Format; break; } return D3DHelper.ConvertEnum( d3dPF ); }
//initialization void Start() { // Assign texture to the renderer if (renderer != null) { m_textureType = TextureType.Renderer; m_material = renderer.material; m_material.mainTexture = VideoTextureManager.GetInstance().GetTexture(); m_material.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); } else if (guiTexture != null) { // or gui texture m_textureType = TextureType.GUITexture; m_guiTexture = guiTexture; m_guiTexture.texture = VideoTextureManager.GetInstance().GetTexture(); m_guiTexture.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); } else { m_textureType = TextureType.None; //Debug.Log("Game object has no renderer or gui texture to assign the generated texture to!"); } }
private void DrawCreateTextureGUI(ref bool dirty) { if (availableSizesStr == null) availableSizesStr = availableSizes.Select(s => s.ToString()).ToArray(); textureFilename = EditorGUILayout.TextField("Filename: ", textureFilename); textureType = (TextureType)EditorGUILayout.EnumPopup("Type: ", textureType); textureWidth = EditorGUILayout.IntPopup("Width: ", textureWidth, availableSizesStr, availableSizes); textureHeight = EditorGUILayout.IntPopup("Height: ", textureHeight, availableSizesStr, availableSizes); if (GUILayout.Button("Create")) { CreateTexture(); dirty = true; } EditorGUILayout.Space(); }
private static extern void nvttSetInputOptionsTextureLayout(IntPtr inputOptions, TextureType type, int w, int h, int d);
public void SetTextureLayout(TextureType type, int w, int h, int d) { nvttSetInputOptionsTextureLayout(options, type, w, h, d); }
public TextureInPoint GetTextureInPoint( TextureType textureType ) { var textureDeclartaion = this._textureInPoint[ textureType ]; return new TextureInPoint( this._contentManager.Load( textureDeclartaion.Name ), textureDeclartaion.Quadrangle ); }
void init( ) { if(noiseTex==null || isDirty){ isDirty = false; if(lastSelectedType!=textureType){ // Set good default values if(textureType==TextureType.Marble){ scale = 0.15f; turbolenceSize = 9; turbolenceStrength = 2.8f; }else if(textureType==TextureType.Wood){ scale = 294f; turbolenceSize = 6; turbolenceScaleX = 1.07f; turbolenceScaleY = 0.19f; turbolenceStrength = 11.4f; fromColor = new Color(223f/255f,188f/255f,112f/255f); toColor = new Color(169f/255f,122f/255f,60f/255f); }else if(textureType==TextureType.Sand){ turbolenceSize = 2; turbolenceStrength = 1.0f; } lastSelectedType = textureType; } noiseTex = new Texture2D(pixWidth, pixHeight); pix = new Color[noiseTex.width * noiseTex.height]; for (int y = 0; y < noiseTex.height; y++) { for (int x = 0; x < noiseTex.width; x++) { int i = y * noiseTex.width + x; if(textureType==TextureType.Marble){ float xCoord = xOrg + x / (float)noiseTex.width * scale; float yCoord = yOrg + y / (float)noiseTex.height * scale; float xyValue = xCoord + yCoord + turbulence(x* scale, y* scale, turbolenceSize)*turbolenceStrength; float sample = Mathf.Abs( Mathf.Sin(xyValue) ); float fromRatio = sample; float toRatio = 1.0f-sample; pix[i] = new Color(fromColor.r*fromRatio, fromColor.g*fromRatio, fromColor.b*fromRatio) + new Color(toColor.r*toRatio, toColor.g*toRatio, toColor.b*toRatio); }else if(textureType==TextureType.Wood){ float xCoord = xOrg + x / (float)noiseTex.width * scale; //float yCoord = yOrg + y / (float)noiseTex.height * scale; float xyValue = xCoord + turbulence(x / (float)noiseTex.width*turbolenceScaleX * scale, y / (float)noiseTex.height*turbolenceScaleY * scale, turbolenceSize)*turbolenceStrength; float sample = Mathf.Sin(xyValue); float fromRatio = sample; float toRatio = 1.0f-sample; pix[i] = new Color(fromColor.r*fromRatio, fromColor.g*fromRatio, fromColor.b*fromRatio, fromColor.a*fromRatio) + new Color(toColor.r*toRatio, toColor.g*toRatio, toColor.b*toRatio, toColor.a*toRatio); }else if(textureType==TextureType.Sand){ float xCoord = xOrg + x / (float)noiseTex.width * scale; float yCoord = yOrg + y / (float)noiseTex.height * scale; float sample = turbolenceSize<=1 ? Mathf.PerlinNoise(xCoord, yCoord) : turbulence(xCoord, yCoord, turbolenceSize)*turbolenceStrength; //Debug.Log("xCoord:"+xCoord+" yCoord:"+yCoord+" sample:"+sample+" turbolenceSize:"+turbolenceSize); float fromRatio = sample; float toRatio = 1.0f-sample; pix[i] = new Color(fromColor.r*fromRatio, fromColor.g*fromRatio, fromColor.b*fromRatio) + new Color(toColor.r*toRatio, toColor.g*toRatio, toColor.b*toRatio); }else if(textureType==TextureType.WoodStripes){ float xCoord = xOrg + x / (float)noiseTex.width * scale; //float yCoord = yOrg + y / (float)noiseTex.height * scale; float xyValue = xCoord + turbulence(x / (float)noiseTex.width*turbolenceScaleX * scale, y / (float)noiseTex.height*turbolenceScaleY * scale, turbolenceSize)*turbolenceStrength; float sample = Mathf.Sin(xyValue); if(cutoff>0.0f) sample = (sample-cutoff) / (1.0f-cutoff); float fromRatio = sample; float toRatio = 1.0f-sample; pix[i] = new Color(fromColor.r*fromRatio, fromColor.g*fromRatio, fromColor.b*fromRatio, fromColor.a*fromRatio) + new Color(toColor.r*toRatio, toColor.g*toRatio, toColor.b*toRatio, toColor.a*toRatio); } } } noiseTex.SetPixels(pix); noiseTex.Apply(); } }
public virtual void SetTexture(String path, TextureType type) { throw new NotImplementedException (); }