Page 1 of 1

Texture Atlas Image Inclusion

Posted: 09 Dec 2014, 21:42
by dabbler
Our current project uses a texture atlas that is 1600x1600 RGBA 8 bit color that is 9.8 Mb in size.

When we build our compiled resources using the resource.buildtool any that reference the atlas are 22 Mb in size including the texture atlas image itself.

I am extremely new to Noesis GUI but I assume the doubling is due to pre-computed and stored mip-maps.

Regardless, is it expected that each xaml file that references the texture atlas would include the image information in the compiled output?

To verify this was the case, I replaced the texture atlas with a 150 Kb image and saw all the compiled files drop in size accordingly.

Is there a setting or configuration that can used to prevent the duplication of the image data in the individual output files?

Our output Data directory has ballooned to more than 400 Mb and we are concerned as we have many more items to add.

We are currently using the Windows SDK version 1.1.7.4810

Thanks in advance for your help

Re: Texture Atlas Image Inclusion

Posted: 10 Dec 2014, 01:06
by jsantos
Effectively, in v1.1 textures are included inside each XAML that uses it. The solution is having only one XAML referencing the atlas, for example (taken from the Aladdin sample provided inside Samples):
<!-- Created using Noesis XAML exporter for TexturePacker (http://www.texturepacker.com) -->
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <ImageBrush x:Key="aladin01" ImageSource="aladin-atlas.png" Viewbox="145,58,33,54" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin02" ImageSource="aladin-atlas.png" Viewbox="180,58,30,54" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin03" ImageSource="aladin-atlas.png" Viewbox="73,61,27,57" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin04" ImageSource="aladin-atlas.png" Viewbox="39,2,33,57" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin05" ImageSource="aladin-atlas.png" Viewbox="112,2,38,54" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin06" ImageSource="aladin-atlas.png" Viewbox="74,2,36,56" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin07" ImageSource="aladin-atlas.png" Viewbox="152,2,31,54" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin08" ImageSource="aladin-atlas.png" Viewbox="185,2,27,54" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin09" ImageSource="aladin-atlas.png" Viewbox="41,61,30,57" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin10" ImageSource="aladin-atlas.png" Viewbox="2,2,35,58" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin11" ImageSource="aladin-atlas.png" Viewbox="102,60,41,55" ViewboxUnits="Absolute" Stretch="Fill"/>
    <ImageBrush x:Key="aladin12" ImageSource="aladin-atlas.png" Viewbox="2,62,37,57" ViewboxUnits="Absolute" Stretch="Fill"/>

</ResourceDictionary>
And then, each time you need the atlas, you include the XAML :
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">

    <Grid.Resources>
      <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="atlas.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </Grid.Resources>

		<Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Center" Margin="5">
		  <Rectangle Fill="{StaticResource aladin08}" Width="27" Height="54"/>
		</Border>
</Grid>
In v1.2 (whose beta is available right now) we changed this a bit and now textures are not included inside preprocessed XAMLs and they are shared properly.

Re: Texture Atlas Image Inclusion

Posted: 11 Dec 2014, 14:09
by Frodo
Is there a way to use compressed atlas textures / sprites?
Or do I have to deal with RGBA images?

Recently we ran out of memory on mobile devices, so dealing with compressed images would be a bit more accurate for older devices..

Re: Texture Atlas Image Inclusion

Posted: 12 Dec 2014, 22:02
by jsantos
Right now, texture compression is only implemented in desktop platforms (GL and DX11 in v1.2). For mobiles, if you are using Unity you can create TextureSources using a Unity Texture2D as explained in this tutorial:

http://www.noesisengine.com/docs/Gui.Co ... orial.html
Grid grid = GetComponent<NoesisGUIPanel>().GetRoot<Grid>();

Texture2D texture = Resources.Load("Noesis") as Texture2D;
TextureSource source = new TextureSource(texture);

Image img = grid.FindName<Image>("img");
img.SetSource(source)
Anyway, implementing texture compression for mobiles is in our Roadmap.