nKast

pixel perf-ect

9. May 2024 14:25
by nKast
0 Comments

What's new in KNI v3.12

9. May 2024 14:25 by nKast | 0 Comments

  The new version of KNI 3.12.9001 brings bug fixes, performance and 3D processing improvements. A more detailed list of the changes is available on the changelog.

Download KNI v3.12 today.
See migrate to v3.12 on how to upgrade your current projects.

Architecture

  The restructuring of the framework is almost completed, with Input and Game namespaces moved to their own assemblies. The remaining namespaces are Storage and Microsoft.Devices.Sensors. What that means in practice is that the majority of libraries can target the core libraries without the need to target a PrivateAssets="All" Ref library.




ModelProcessor

 Assimp, the library we use to import 3D file formats, has been upgrade to version 5.2.4. The ModelProcessor can now correctly import the scale and orientation of .fbx files from a variety of sources. Below you can the Ship1, Pad and Pad_Halo models from the ShipGame sample as they were imported by v3.11 and v3.12. For reference the last image is the XNA build.

Additionally a couple of bugs were fixed in the ModelProcessor and the MaterialImporter. First, notice how the UV was corrupted inside the tunnel on Level1 model. Second, the textures on the walls were all noisy because of no MipMapping. For reference the last image is the XNA build.

  A key difference in XNA is that the ModelImporter will automatically generate Normals for all models. KNI gives you more control by adding a new parameter in the ModelProcessor. By setting GenerateNormals=true you can generate normals on any Model. That feature was particularly useful in porting the ShipGame sample, without the need to re-export the original models.


Sponsors

While KNI is free and open-source, maintaining and expanding the framework requires ongoing effort and resources. We rely on the support of our community to continue delivering top-notch updates, features, and support.
By becoming a Sponsor, you can directly contribute to the growth and sustainability of the KNI Game Framework.

8. March 2024 11:21
by nKast
0 Comments

What's new in KNI v3.11

8. March 2024 11:21 by nKast | 0 Comments

  The new version of KNI 3.11.9002 brings performance improvements, bug fixes, and implements missing features from the XNA. A more detailed list of the changes is available on the changelog.

Download KNI v3.11 today.
See migrate to v3.11 on how to upgrade your current projects.


Architecture

  The restructuring of the framework continues, with Content, Graphics, Audio and Media namespaces moved to their own assemblies. Input and Game classes are still in the platform assembly MonoGame.Framework.dll. 
   Those changes affect the Content Pipeline as well, where the entire dependency tree is core framework libraries. The dependency to MonoGame.Framework.dll that we had in v3.9 is eliminated.


FontDescriptionProcessor

  FontDescriptionProcessor has a couple of changes and fixes. It is now required to include the extension when you specify a local font file in FontName tag. Otherwise, the font name has to be a valid FontFamily name. The tricks that worked until now like, 'Arial Bold' will not work anymore. Instead you can now specify the style in the FontStyle tag like 'Regular', 'Italic', 'Italic, Bold', or 'Bold'.
e.g.

  <FontName>Calibri</FontName>
  <Size>16</Size>
  <Style>Bold, Italic</Style>

 
Content.Pipeline.Builder.Task

   The asset builder is now a self-contained nuget package. Instead of the Kni.Content.Builder.targets import, we now have a package reference to nkast.Xna.Framework.Content.Pipeline.Builder.3.11.9001.
See Migrating Content Builder.


net8.0, trimming and AOT

The templates, libraries and tools are upgraded to net8.0. The old targets are still supported via multitargeting (net6.0, netstandard2.0, etc).
Trimming has been enabled for the core libraries Framework, Content, Graphics, Audio, Media and Platforms when targeting net8.0. 
Trimming is also enabled on the iOS, Android, DesktopGL templates.
PublishAOT is enabled on the DesktopGL templates.
With trimming the resulting builds are smaller, which can benefit Mobile and Web games. See Enable Trimming. Bellow are screenshots of a small sample app build for Android and BlazorGL. Not only the libraries of the framework are smaller, but this has a cascading effect on the core .net libraries as well.



 


Sponsors

While KNI is free and open-source, maintaining and expanding the framework requires ongoing effort and resources. We rely on the support of our community to continue delivering top-notch updates, features, and support.
By becoming a Sponsor, you can directly contribute to the growth and sustainability of the KNI Game Framework.

29. November 2023 16:19
by nKast
0 Comments

What's new in KNI v3.10

29. November 2023 16:19 by nKast | 0 Comments

  KNI 3.10.9001 implements plenty of missing features in the BlazorGL platform, improvements in the Effect Processor, bug fixes, and performance improvements. A more detailed list of the changes is available on the changelog.

Download KNI v3.10 today.

.net6 Templates and nuget

  The SDK now includes new VS2022 templates targeting .net6. Both the .net6 templates and the former templates for net4.0 framework, Xamarin and uap10, reference the nuget packages of the framework. The MAUI platforms (Android, iOS) and their templates are upgraded to target .net8.

 

BlazorGL

  The BlazorGL platform got a couple of improvements in this version. Those are the things that got implemented:

  • Texture2D.GetData(…)
  • SongReader & MediaPlayer
  • VideoPlayer
  • Game.IsActive
  • Depth24Stencil8 usage for Rendertarget2D and the backbuffer PreferredDepthStencilFormat.
  • PreferMultiSampling and RenderTargetUsage for the backbuffer.

Productivity

  A common complaint with the content builder is it takes a couple of seconds to load a project and check for changed assets. The db files in the IntermediateDir folder are stored in a new binary format, replacing the XmlSerializer and any tedious reflection and parsing.  The project loading has a O(1) dictionary to check for duplicates. The tool  will no longer output ‘Skipping…’ lines. As a result, the content builder is now lighting fast and you will not even notice it when rebuilding a project. Additionally an issue with the /OutputDir and /IntermediateDir has been fixed, and the tool  will store its output in the same folder whether you build from the editor,  the command line, or the .csproj.

    The EffectProcessor takes 10% less time that the previous version, after some refactoring and removal of unnecessary data copies.


  Macros are no longer necessary when writing effects.  Whether you are targeting WindowsDX (DX11) or an OpenGL platform, you are writing one Shader. You can use the new HLSL4.0 syntax to define Samplers and Textures or the old HLSL2.0 syntax (compatibility mode).

OldSyntax.fx

Texture2D SpriteTexture : register(t0);
sampler2D SpriteTextureSampler : register(s0) = sampler_state
{
    Texture = <SpriteTexture>;
};
struct VertexShaderOutput
{
	float4 Position : SV_POSITION;
	float2 TextureCoordinates : TEXCOORD0;
};
float4 MainPS(VertexShaderOutput input) : COLOR
{
	return tex2D(SpriteTextureSampler, input.TextureCoordinates);
}
technique SpriteDrawing
{
	pass pass0 { PixelShader = compile ps_4_0_level_9_1 MainPS(); }
};

NewSyntax.fx

Texture2D SpriteTexture : register(t0);
sampler SpriteTextureSampler : register(s0);
struct VertexShaderOutput
{
	float4 Position : SV_POSITION;
	float2 TextureCoordinates : TEXCOORD0;
};
float4 MainPS(VertexShaderOutput input) : COLOR
{
	return SpriteTexture.Sample(SpriteTextureSampler, input.TextureCoordinates);
}
technique SpriteDrawing
{
	pass pass0 { PixelShader = compile ps_4_0_level_9_1 MainPS(); }
};

 

Performance

  Rendering performance has been improved, particularly for OpenGL.

 

 

The performance tests can be found in the KniBenchmarks project on github.
Framework versions: KNI 3.10.9001, MonoGame 3.8.1.303, FNA 23.07, XNA 4.0
All tests were performed on the following system:

CPU: AMD Ryzen 3 2200U
GPU: AMD Randeon Vega 3 Mobile Gfx
HDD: WD Blue SN550 NVMe SSD 

 

Sponsors

While KNI is free and open-source, maintaining and expanding the framework requires ongoing effort and resources. We rely on the support of our community to continue delivering top-notch updates, features, and support.
By becoming a Sponsor, you can directly contribute to the growth and sustainability of the KNI Game Framework.

8. August 2023 18:19
by nKast
0 Comments

What's new in KNI v3.9

8. August 2023 18:19 by nKast | 0 Comments

  The new version of KNI 3.9.9001 brings performance improvements, bug fixes, and implements missing features from the XNA. A more detailed list of the changes is available on the changelog.

Download KNI v3.9 today.


Architecture

  The most significant change in this version has to do with the library structure. All basic math types have been moved from MonoGame.dll to Xna.Framework.dll and the Vector converters to Xna.Framework.Design.dll. The latter is needed only for game editor and you can ignore it on a typical game project. MonoGame.dll still contain the majority of namespaces like .Graphics, Audio, Input, etc.
  The core of the Content.Pipeline types can be found in Xna.Framework.Content.Pipeline.dll, while the Importers, Processors and Content items have been moved to their own libraries. MonoGameContent.Pipeline.dll has been removed.

  The effort will continue to remove preprocessor directives and partial classes from the code and to split all major namespaces into their own modules. The benefits from this is a clean structured codebase, eliminating the need to use bait-and-switch trickery, seamless support for nuget packages, signed 3rd party libraries, and easier adoption of new platforms.  
  It is necessary to update your projects and libraries with the new targets. Add a reference to Xna.Framewrok.dll and use the Ref platform as the bait and switch target for MonoGame.Framework.dll. 


Video

  After being in the backlog for years, it’s finally here. This version of KNI brings a functional implementation of VideoPlayer to WindowsDX, UAP and Android platforms.


FontDescriptionProcessor

  The Font importer is constantly improved over the last versions. Starting with a bug in Spacing element in the FontDescription, you can see bellow how the font is rendered after the fix.


 Another old issue is the font baseline. Any font family will be rendered with correct spacing on top and bellow the font.


  FontDescriptionProcessor has a new property that let you chose the hinting algorithm.
This property is specific to SharpFont.


Pipeline Content Editor

The  font size of the Content editor GUI has been increased for improved readability.


Performance

The performance of Font and Texture processor has been improved. Building content during development can be distracting, especially in a big project.



Loading times are also important, not only during development but also to your target audience.



Fast content loading is essential on mobile marketplaces that have strict requirements on apps.


Rendering performance can give you not only smother animations, but also more headroom for your update logic and physics.





The performance tests can be found in the KniBenchmarks project on github.
Framework versions: KNI 3.9.9001, MonoGame 3.8.1.303, FNA 23.07, XNA 4.0
All tests were performed on the following system:

CPU: AMD Ryzen 3 2200U
GPU: AMD Randeon Vega 3 Mobile Gfx
HDD: WD Blue SN550 NVMe SSD 

 

Sponsors

While KNI is free and open-source, maintaining and expanding the framework requires ongoing effort and resources. We rely on the support of our community to continue delivering top-notch updates, features, and support.
By becoming a Sponsor, you can directly contribute to the growth and sustainability of the KNI Game Framework.

 

19. September 2010 11:52
by nKast
0 Comments

AccelKit, an Augmented Reality Accelerometer Kit for Windows Phone 7 Emulator

19. September 2010 11:52 by nKast | 0 Comments

AccelKit is an Augmented reality tool that simulates an accelerometer sensor for those who develop applications for the upcoming Windows Phone 7.
I used ARToolKit, an open source AR library that can track the position & orientation of a marker moving in front of a webcam.  Those data are then translated into accelerometer measurements and made available to any program through port 88. You can get the source code at accelkit.codeplex.com or just the executable at tainicom.


How to use it
 

Print the Print_This_Cutout.pdf on plain paper and glue it on a sheet of cardboard. 
Then cut out the phones. 

Place your webcam in  straight position, forming a 90o angle with the floor. 

Run the accelKit.exe found inside the Executable folder. 
On the first screen you are asked to select the desired web resolution. Because tracking can be very CPU intensive, select the lowest possible resolution (That screen might vary from webcam to webcam).
You should now see feed from your webcam. If not, check for other video capture devices in your system (like TV tuners for example) and disable them. 
Move the marker smoothly in front of the webcam. If accelKit keeps loosing track of the marker add some more light to the room to improve the image sharpness. If you still have problems, try again with the next resolution until you get consistent results. It is normal to lose track once in a while for a few frames, especial when the marker moves too fast or on extreme angles. 

Open a web browser and go to http://127.0.0.1:88/. You should see something in the form of "-0.068880,-0.997565,-0.010901". In case you are eager to see it in action get the samples at tainicom.net

Now, let's add support for accelKit in your applications. The code below (C#) demonstrates how you can get the accelKit data.

..
WebClient wc;
wc = new WebClient();
wc.AllowReadStreamBuffering = false;
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
wc.DownloadStringAsync(new Uri("http://127.0.0.1:88/"));
..

void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)

if (e.Error != null) { timer.Begin(); return; }
if (e.Result == null) { timer.Begin(); return; }
string[] vc = e.Result.Split(new Char[] {',', ' '});
double x = Convert.ToDouble(vc[0]);
double y = Convert.ToDouble(vc[1]);
double z = Convert.ToDouble(vc[2]);

Inside the release you will find the AccelerometerEmu class that you can use as an in-place replacement of the Accelerometer class. Unfortunately, the Accelerometer is sealed so I couldn't inherit from it and had to use composition instead. AccelerometerEmu connects to the accelKit and retrieves data in a constant rate when run in the Windows Phone 7 emulator. When run in a real device, it uses the real Accelerometer (since I don't have access to a real device I couldn't test how good that works). Here's what you have to do:

Replace all instances of Microsoft.Devices.Sensors.Accelerometer with NKast.Sensors.AccelerometerEmu.

Add an event listener to ReadingEmuChanged.

..  
accelerometer.ReadingEmuChanged += new EventHandler<AccelerometerEmuReadingEventArgs>(accelerometer_ReadingEmuChanged);
..


void accelerometer_ReadingEmuChanged(object sender, NKast.Sensors.AccelerometerEmuReadingEventArgs e)  
{
Deployment.Current.Dispatcher.BeginInvoke(() => MyReadingChanged(e));
}


void MyReadingChanged(AccelerometerEmuReadingEventArgs e)
{
double accelx , accely , accelz;
accelx = e.X; 
accely = e.Y;
accelz = e.Z; 
..

My Plans for the next version

Bug fixes!
Code optimization.
Derive acceleration from the mark movement. Right now it only accounts for orientation, therefore you get only gravity acceleration as if you were rotating the device in a fixed position.
Add a mode where the webcam looks straight down. I understand that's necessary for certain types of games. 

Last notice

  • The simulated accelerometer fires events in fixed intervals. A real device might behave differently.
  • The Timestamp property of AccelerometerEmuReadingEventArgs is not yet emulated.
  • Currently it only returns the gravity acceleration. Not acceleration caused by movement.
  • Do not print the paper cutout on glossy or semigloss paper! The less glare, the better!

 

I hope you find it helpful while developing great games for Windows Phone 7 !