December 2016 Test Build

Hello everyone! This will be my last post for 2016. It’s been a great year for Daggerfall Unity with solid updates across the board. I was hoping to have basic quest support in by now, but sadly not everything goes to plan. This will return as a priority early in 2017 so watch this space!

One thing that always amazes me is the quality of work this community is willing to put back into Daggerfall Unity. It’s always a pleasure to find a new pull request on git from someone willing to contribute their personal time to make this project even better. So this post is going to focus almost exclusively on contributions from community members. It’s time for kudos and credits all around, and you’ll see very little of me this post.

 

Texture & Mesh Replacement

This feature began with Uncanny_Valley and has lately been updated and maintained by TheLacus. It allows for runtime injection of new textures and meshes into Daggerfall Unity’s scene builders, setting the stage for updated models, higher resolution materials, and improvements to Daggerfall’s vanilla UI. It’s still early days but the potential is incredible. Here’s a few screenshots of new assets by community members.

 

At time of writing, mesh and texture replacements aren’t quite ready for download. But now support for this is baked into the core, you should start seeing community-created packs in the near future. You can read more about mesh and texture replacement in this thread on the forums.

 

Early Bow Combat

New contributor electrorobobody added basic bow combat to the lineup of supported weapon animation. No counting arrows yet, and you’ll need to roll a new character for your free silver bow, but it’s awesome to finally burn down enemies with ranged kiting. Looking forward to bows becoming a strong part of the game in future.

 

Save & Load Weather

Daggerfall Unity added basic weather events a while back, but they would not be saved and loaded with your games. Thanks to midopa, the current state of weather will be saved and loaded. This will only get better once correct weather events are wired up based on climate and season.

 

Enemy Steering

Another epic update by midopa. He added a little steering to enemy AI to prevent enemies from stacking on top of small creatures like rats. As hilarious as this problem could be, it’s good to see a workable solution for this bug. It’s still possible for enemies to slightly stack in edge cases, but the problem is much improved and they will no longer ride around on each other (imagine skeletons surfing rats and rat-rat-rat stacks).

 

Potion Recipes

The perennial InconsolableCellist returned with some amazing updates for us. Credit goes completely to him for working out potion recipe format and integrating with Daggerfall Unity. This also means potion recipes will display properly in inventory, and they’re even usable to see the individual ingredients. This is really important ground-work for a bunch of other things down the line.

 

Books

I wrote the initial book reader UI ages ago, but InconsolableCellist wrapped it up along with random book drops in loot, correct tooltips, and all-round awesomeness. Books currently exhibit the same formatting problems as classic (because it’s the same book data). That’s something yet to be fixed.

 

Exterior Automap

Nystul has done it again with the perfect companion UI to his dungeon and interior automap. Yep, exterior automaps are now a thing! It even supports proper tagging of buildings, zoom, and rotation. As always, I’m completely blown away by how complete this is right from the start. It’s still waiting on full building name integration and building identification in scene, but that will come. For now, all the buildings are tagged by type. Go explore!

 

Spotlight: Allofich

I can’t give Allofich high enough praise. He has worked incredibly hard tuning up different areas of Daggerfall Unity to make it more true to the original. He fixed a wide range of UI problems, identified sound effects, linked sounds to their correct actions, fixed clothing and item problems, and so on. Check out his full list of commits here. It’s hard to show these off properly in screenshot form because the changes are either subtle improvements or related to audio, but below is one of the UIs he has cleaned up. Note the poor texture joins in the “before” image (circled). Huge props to Allofich for his work!

 

Thanks To: AnKor

OK this is embarrassing. I was looking everywhere for the animations used when player was riding horse or cart. These turned out to be in the overlooked CFA image file format. Somehow, I had completely disregarded these files which are a format holdover from Arena. Yep, I’m only human. Fortunately, AnKor pointed this out on the forums and I was able to implement CFA support in no time. Now we have this:


It’s only a short jump from here to having these transport options in the game.

 

Thanks To: Testers

I also want to send out a huge thanks to all the amazing people who tested Daggerfall Unity in 2016 and reported the bugs and problems you found. There are simply too many people to list, but you know who you are. You’re on the forums, and Twitter, and Reddit, and sending me emails. You guys rock!

 

Bugs and Problems

Yep, we got ’em! Any large update like this will bring its fair share of new bugs. If you come across a bug during tests and would like to report it, please lodge this in the Bug Reports forum. Don’t forget to read the Guidelines to help you provide the best information to developers.

Contributors, please keep an eye on the Bug Reports forum for anything that might fall into your wheelhouse.

 

Where To Download?

You can always download the latest version of Daggerfall Unity from the Live Builds page. If this is your first time downloading Daggerfall Unity, welcome! Other information on Live Builds page should also help you get started. If you have any troubles, or just want to discuss updates, please go to the December 2016 Test Builds Updated thread on forums.

 

That’s it for 2016! Thank you everyone for visiting and all your kind words of support. Here’s wishing you all a very Merry Christmas and Happy New Year, and all the best for 2017!

 

For more frequent updates on Daggerfall Unity, follow me on Twitter @gav_clayton.

Remastering Daggerfall

Less than 12 months have passed since I began work on Daggerfall Tools for Unity. In that time, my little project has grown substantially and attracted a lot of attention from around the world, including articles on Kotaku AU and Rock Paper Shotgun.

As word about Daggerfall Tools for Unity has spread, a lot of hopeful Daggerfall players have visited looking for word on a remake – only to find a set of development tools not aimed towards players. While everyone seems excited about the potential Daggerfall Tools for Unity offers, there’s a lot of latency between new developers coming on board and getting up to speed before they can offer their contributions. So as a developer community, we may be climbing a steady ladder towards remaking Daggerfall, but there’s very little for non-developers to experience and no clear direction from which a remake will come. I’m contacted by passionate Daggerfall fans almost every week and it breaks my heart that I don’t have more for them.

I want that situation to change. I want the average Daggerfall player to be able to experience progress and have a clear sense of direction that Daggerfall Tools for Unity can be used for remaking Daggerfall, and then some.

What this means is that I can’t just create a toolset. Raw building blocks aren’t enough. I also need to create a scaffold for remastering Daggerfall that includes everyone, developers and players alike.

So let’s get this out of the way. I will shortly release a burgeoning Daggerfall remake, proudly using the Unity engine and Daggerfall Tools for Unity.

For players, this means you will be able to download regular builds to experience the project as it grows. You will become part of the process, able to offer your feedback and constructive criticism to the betterment of the project. Developers win out as well, because you get a functioning Daggerfall remake – completely open source – to build on and change as you desire. For the first time we can all, developers and players alike, come together and contribute.

So where does this leave Daggerfall Tools for Unity? Nothing changes at all. My remake project will be built on the same Daggerfall Tools for Unity that everyone has access to. If anything, this will only improve Daggerfall Tools for Unity by creating a proving-ground for new features and increasing the number of testers.

I will soon release a new web site, solely for distributing the latest playable build of my Daggerfall remake. Daggerfall Workshop will remain as the hub of social activity and development news.

And the best news for players is there’s a swag of new features coming in Daggerfall Tools for Unity 1.4 and 1.5, all aimed at creating playable systems and filling in those blanks between a toolset and a game.

Feel free to leave your comments on this post, or head over the forum post where I’ve kicked off the conversation.

Roadmap July 2015

Roadmap July 2015

With 1.3 freshly released, it’s time for me to update my roadmap again. While my overall heading remains constant, the beats and rhythm of my short-term goals are always in flux, constantly evolving as I converge on solutions and new priorities emerge. I find that right after a release is the perfect time to step back and consider my next move. So let’s take a look at where I’m up to and what’s on the horizon.

Maintaining 1.3

To start with, I’m wrapping up tutorials and fixing any bugs discovered in 1.3 release version. I plan to support the stable 1.3 branch right up to the next major release. Any minor bugs will be fixed quickly, followed by an incremental release. It’s possible some of the key features in 1.3 will be refined, but no major changes will be made at this point. Anyone waiting for 1.3 to settle down can confidently get started with it.

For those of you waiting on tutorials, Prefab Basics should be up in the next day, and Streaming World sometime next week. I’m hoping all the tutorials earmarked for 1.3 will be completed in next 2-3 weeks.

Work In Progress Branch

In case you missed it, there is now a work-in-progress branch on GitHub. New features will be added first to the work-in-progress branch and only promoted to the master branch once they become complete and stable. At which point, I go into maintenance mode for the new release and start work on the next major release. This is a much better workflow and should result in faster turnaround of fixes in maintenance releases. It’s very likely you will see a few more version points added to 1.3 before it’s done.

Developer Focus

Every major release (two betas, 1.0, 1.1, 1.2, 1.3) involved heavy changes to the underlying code. This often broke your work and was very frustrating for you. I’m sorry about that. Hopefully 1.3 marks the last major paradigm shift for some time (jumping to Unity 5 was a big one), and the new event and prefab systems help you create your projects without needing to modify the core tools.

I plan to continue this developer focus moving forward by adding more events, prefabs, interfaces, editor scripts, etc. to help you work, and make fewer breaking changes to the underlying code base. It’s obviously inevitable this will happen sooner or later, but hopefully not to the extent seen between 1.0-1.3.

Feature Focus

To date, I’ve worked very broadly across the entire spectrum of Daggerfall. This has been essential as much work was involved in setting up content readers, building a bridge into Unity, and seeing the entire game world up and running. Those system are huge, difficult, and take a mountain of work to pull off. And they are so interdependent that it’s necessary to build all of them before any of them really work. This is where most Daggerfall projects stall and fail. And guess what! We’ve pushed past that like a boss and still have plenty of steam out the other side. This is where the really interesting stuff kicks in and all that hard work pays off.

Starting with 1.4, I’m going to focus on a very specific set of features each release, plus some iteration on previous features. In this way, we climb the mountain one challenge at a time. The work becomes easier because the next goal is always in sight, then the next, and so on until the top.

Roadmap 1.4

Work on 1.4 has already begun. The only thing I haven’t shared with you are my plans for this release. Here’s a list of everything I have either already started work on, or plan to include. And the good news? From here on, everything is geared to helping you add real gameplay features.

  • Daggerfall save game import. Yep, the ability to read vanilla Daggerfall save games and import this data.
  • Unity save games. The foundations of a Unity save-game system will be implemented for new demo titles. You can use this, ignore it, or extend as needed.
  • Real player scripts. With stats, special advantages, special disadvantages, reputations, etc.
  • Real monster scripts. With all their properties read straight from the game files.
  • Real combat formulas. For real melee combat. Spellcraft will be added later.
  • Item and loot table support. Play with real Daggerfall items and their properties. Custom loot tables for monsters and dungeons.
  • Starting work on effects system.  At first this will only be complete enough to support player and monster scripts, and melee combat. Spellcraft will be added later.
  • Demo character sheet UI. With inventory and paper doll support.

Some of you may be wondering about the text & translation features I had originally planned for 1.3. Unfortunately the Unity 5 release dropped a huge spanner in the works and a great deal of effort was involved bringing everything up to par with the new paradigm. In that time, I have rethought my approach toward text and translation based on feedback from other developers.

Obviously this remains an important consideration, but I no longer believe it prudent to add a locked-in translation system to core tools. The problem with this approach is it limits options for other developers who may wish to use some other translation system, or a different approach entirely.

The original system as planned would also have added some complexity for developers who just wanted to get stuck in for their own amusement, and are not concerned about targeting multiple languages. Obviously larger projects that want to localize have a plethora of options available in the Unity landscape alone. There is simply no need for me to re-invent the wheel here.

So I’m going to keep doing what I do best, which is provide hooks back to the game files and the means for other developers to easily suck out the data they need. This data obviously includes text, and will have everything a developer needs to pair with their preferred translation system. This set of features are now part of the 1.5 update, which includes quest file support.

Conclusion

That’s everything for now. As usual, Daggerfall Tools for Unity is a constantly evolving beast and this is all subject to refinement. However the journey remains the same. I may not be remaking the game personally, but by Julianos I’m going to create all the moving parts needed to help that become a reality, and with your help it’s practically inevitable.

So if you’re a developer who loves Daggerfall, get started today and help show the world what can be accomplished!

Mod Showcase 1 Demo

I’ve said it many times: Daggerfall Tools for Unity is a platform. Besides helping to recreate the game, DFTFU can be used to remaster and re-imagine Daggerfall, or create whole new games in a similar style. Merging Daggerfall’s content with a powerful engine like Unity provides limitless potential.

Nothing shows off this potential more than mods created over the last several weeks by Nystul, LypyL, and Uncanny_Valley. These range from graphical enhancements and world improvements to silly fun like turning Daggerfall into a flight simulator. I’m so very proud to show off their hard work in the below video and to provide a playable demo for you to experience their work first-hand.

DFTFU Mod Showcase 1 – Playable Demo

What’s Included

  • Daggerfall Tools for Unity 1.3.11 [Interkarma/Gavin Clayton]
  • Increased Terrain Distance 1.4 [Nystul/Michael Rauter]
  • Floating Origin Updates [LypyL]
  • Enhanced Sky 1.6 [LypyL]
  • DaggerJet 1.1a [LypyL]
  • TravelMap2.1 [LypyL]
  • Real Grass 1.01 [Uncanny_Valley]
  • Birds In Daggerfall 1.0 [Uncanny_Valley]

Controls

See below for complete list. There is also a handy key reference created by Daschluba on the forums (click for full size).

Mod Showcase Keys

General

  • Mouse Move Look
  • W, S, A, D Move
  • Shift (hold) Run
  • Space Jump
  • Left Mouse Activate: open doors, enter dungeons, operate switches, etc.
  • Esc Exit game (standalone)

Weapons

  • Z Toggle weapons
  • Right Mouse Drag Right-click and drag mouse to swing weapon

Transport

  • R (outside) Random location, season, time of day, and weather
  • R (dungeon) Recall back to dungeon start
  • 1-7 Preset location (keeps current season, weather, etc.)

Music

  • P Toggle songs on/off
  • [ Play previous song in context playlist
  • ] Play next song in context playlist

Timescale

  • PageUp Increase timescale.
  • PageDown Decrease timescale.

Other

  • I Toggle mouse invert on/off
  • H Toggle high speed running on/off
  • L Toggle debug text on/off
  • O Toggle brighter torch in dungeons and at night
  • V Fast travel menu (see below for instructions)

Sky Control

  • T Toggle Enhanced/Native Sky

Jet Control

  • F6 Toggle laser (can be used without jet)
  • F7 Teleport to where laser is pointed, and exit jet if flying
  • F9 Summon and enter jet
  • F10 Change jet camera position
  • F11 Toggle free mouse look
  • F12 Spawn flying enemy while in jet
  • W, S, A, D Steer jet
  • Mouse0 Fire weapon at laser target
  • Space Air brakes – slow down jet while flying

Using Fast Travel Menu (LypyL)

  1. Hit V key to open/close travel menu.
  2. You can either set your coordinates directly using the sliders, or select a Region & Location using the Location menu and hit the Set Coordinates button.
  3. Use the toggles below the location menu button to choose what type of location to show in the menu (Cities, Dungeons, Taverns, Graveyard etc.)
  4. Once You’re ready to travel, just hit the GO button.

Fast Travel Notes (LypyL)

  • Red marker indicates your current location, the white shows where you will travel to.
  • Click and drag on the location & region menus to scroll through them
  • It’s very rare, but it’s possible to fall through the ground after traveling. If it happens (and you don’t have another solution, like the editor), just fast travel again somewhere to fix it.

New Workshop Members

Daggerfall Workshop is expanding today. I’d like everyone to welcome Nystul, InconsolableCellist, and LypyL to the site!

Over the last several months, I have been amazed by the contributions these three have made to Daggerfall Tools for Unity. They have all selflessly offered code, reported bugs, raised ideas, and generally helped to refine the vision of these tools. But most importantly, they demonstrated the power of open source at work inside a passionate community. They have each shown what is now possible with Daggerfall and Unity.

Anyone following me on Twitter or watching the DFTFU Subreddit may be familiar with their work already. Here’s a sampling, just to be sure.

Nystul

Nystul created a Terrain Extender script for the default Streaming World terrain. This enlarges the default draw distance of a few miles out to insane distances. Nothing shows this better than a couple of screenshots.

Below screenshot was taken just above Direnni Tower using the default Streaming World setup in Daggerfall Tools for Unity.

direnni_near

Not bad! Definitely a huge improvement over the painfully short draw distances in vanilla Daggerfall. But check below for how this same spot looks with Nystul’s Terrain Extender.

direnni_far

That popping sound you heard was my brain exploding. You can see clear across the Isle of Balfiera archipelago to the mainland. Simply amazing! And here’s another lovely far terrain screenshot.

mountains_far

 

LypyL

LypyL is the creator of the jaw-dropping Multiplayer Demo. This was literally a Daggerfall world-first, allowing you to explore the Illiac Bay and its thousands of locations with other players. If you missed out dungeon crawling with mates, I strongly recommend you give it a shot by clicking on that link!

Besides multiplayer and other enhancements (e.g. climbing and flying), LypyL has also proved to be a fearless experimenter, showing us the mad fun you can have with an open source Daggerfall. The below videos put me in mind of the vast mod potential enjoyed by later Elder Scrolls titles.

This kind of spirited tongue-in-cheek modding is exactly what I was hoping to empower everyone with from the outset. Not only can we remake Daggerfall, you can use Daggerfall Tools for Unity however you like!

Oh, and LypyL has also been working on a dynamic sky system for Daggerfall Tools for Unity.

 

InconsolableCellist

Speaking of remaking Daggerfall, this last contributor is by no means least. With the stated goal of creating a fully playable version of Daggerfall, InconsolableCellist is working towards the outcome I think everyone wants to see the most. He has also proven to be a great contributor, expanding the default tools and building all the scaffolding of a real game.

Obviously there’s a fantastic amount of work to do, and much of it is hard to show off visually. But InconsolableCellist has been working very hard indeed, building GUI systems, a text console interface, monster spawners, timers, quest logic, and much more. Best of all, he is continuing the spirit of open source by keeping everything available to the community on his Daggerfall Unity GutHub repository.

Below is an early look at InconsolableCellist’s quest system back-end in action.

And here is a screenshot of the text interface a bit further along, looking more like Daggerfall.

ic_dialog

InconsolableCellist has also experimented with running Daggerfall on the Oculus Rift. This was simply a proof-of-concept (and based on a much earlier version of Daggerfall Tools for Unity), but it demonstrates that we can one day play Daggerfall on VR headsets.

What Happens Now?

Daggerfall Tools for Unity is an interesting project all by itself, but the real story is what other people do with those tools. We have finally reached a point where the story becomes less about me and more about those who build on what I started.

InconsolableCellist, LypyL, and Nystul are now full posting members of Daggerfall Workshop. This means they can show off their progress right here and entertain us with the occasional blog post.

These three will also have collaborator rights to the Daggerfall Tools for Unity GitHub repository, allowing them to post changes to support their own work, help support others, and expand our tools into the future.

For my part, I will continue working just as I have been in the past. I will keep on reverse-engineering bits of Daggerfall, adding new features, fixing bugs, and help oversee the continued vision and quality of code changes. My job as tool creator is to help keep the tools useful and free for everyone.

The real story of Daggerfall Tools for Unity is just beginning! The more people who contribute, and the more this community grows, then the more amazing stories we’ll have to tell. I look forward to seeing what this all means for Daggerfall in the future.

Stay tuned! There is more exciting news still to come this week.

Streaming World Test 1

This is my first week back from holidays and work is kicking my butt right now. I’m not finding the time I need to really sit down and polish the streaming world demo as much as I’d like. Rather than delay it longer, I’ve decided to release a web demo for everyone to play with. That buys me time for things to settle down at work while I chip away at the final demo. Please consider this a pre-release test and forgive the rough edges.

StreamingWorldPreReleaseTest1

Streaming World Pre-Release Test 1

http://www.dfworkshop.net/web_demos/StreamingWorld-PreReleaseTest1/StreamingWorld-PreReleaseTest1.html

Note: Requires the Unity Web Player.

Features

  • Explore the entire Illiac Bay. Any region, any climate, anywhere.
  • Run smoothly between cities over actual Daggerfall terrain read from game data.
  • Full day/night cycle with animated skies and city lights.
  • Enter any building in any town or city.
  • Control an athletic player who can jump onto small buildings and sprint at high speeds through the wilderness.
  • Location beacon helps you find cities in the wilderness.
  • Entire world is built procedurally right inside your web browser.

Known Issues/Limitations

  • Not optimized. Uses a lot of memory over time.
  • May encounter a brief hitch when updating sky animation or streaming in a large location.
  • No bounds checking. Possible to run off extreme edge of world or crash.
  • Running very distant from starting point will cause precision issues. A fix is in progress to resolve this.
  • No compass or map to help you navigate.
  • Cannot enter dungeons at this time.

If you encounter problems with precision or fall through ground, please use R to travel to random location or 1-4 for preset locations. See controls below.

Controls

  • Click to capture mouse (webplayer).
  • ESC to uncapture mouse (webplayer).
  • Mouse move to look.
  • W, S, A, D to move.
  • SHIFT (hold) to run very fast.
  • SPACE to jump.
  • LEFT-CLICK mouse to open doors, operate switches, etc.
  • R to travel to a random location.
  • 1-4 to travel to a preset location.

I hope you have fun with this pre-release demo. Thank you for your patience while I take care of real-life stuff.

Featured Posts From 2014

For anyone new to Daggerfall Tools for Unity, here are some featured posts from 2014. If you are introducing the project to a new community, feel free to link these articles (or just link back to this one).

Time & Space and More

Looks at world time and day/night cycles, along with player GPS and beginnings of world streaming.
http://www.dfworkshop.net/?p=1388

Direnni Tower – Full Demo

Fully playable demo inside your web browser, or standalone for Windows. Introduces sound system, ambient sound effects player, sky effects, combat, dual wielding, enemy AI, building interiors, and a lot more.
http://www.dfworkshop.net/?p=1325

Streaming World – Part 3

Shows off the early streaming world system, along with some details about setting terrain tiles with marching squares.
http://www.dfworkshop.net/?p=1515

First Android Build

Community member Eric creates a native build of Daggerfall city on Android (i.e. not using emulation).
http://www.dfworkshop.net/?p=1425

Release 1.1 and City Basics Part Two

The current release at end of 2014. Also provides updated tutorials showing just how easy it is to create basic gameplay.
http://www.dfworkshop.net/?p=1419

Improved Terrain Tiling

To date, I have used a brute-force approach when tiling textures in cities and terrains. Each texture tile is mapped to a quad of vertices where each corner describes a UV coordinate allowing its texture to be drawn normally, rotated, flipped, or both rotated and flipped. This saves a great deal of texture space as only one version of texture is required to achieve four variations.

While it saves on texture memory (great for a 1996 game), this system has some inherent problems, not least of which is the number of vertices being used. For example, a full 8×8 block terrain has a total of 128×128 quad tiles with 4 vertices each. That’s a total of 65536 vertices just to handle the ground plane of a big city like Daggerfall or Wayrest. This is larger than Unity’s maximum mesh size, so everything needs to be split up into chunks. As cities are completely flat, wouldn’t it be great if we could just render all these tiles onto a single quad, using only 4 vertices for an entire city?

Happily, this is not only possible, we can solve a few other problems with tiled textures in the process. All through the magic of custom shaders.

The first step is to change how the ground atlas is stored. Rather than just reference a single texture and modify using UVs, we’re going to pre-transform each texture in all 4 possible configurations (normal, rotated, flipped, rotated+flipped). This removes the need for UV changes and saves time in the fragment shader, and allows for some extra packing to happen as you’ll see shortly. The new tile set atlas looks like below (note that Unity texture [0,0] is bottom-left).

Atlas1

In order to reference these tiles in the fragment shader, we also create a tile map texture. This texture packs an index into the red channel that is basically a number 0-255 corresponding to a tile in the atlas above. This texture must be point-sampled to ensure no corruption of indices occurs. The tile map for Daggerfall city is below.

Tilemap

Now the shader has an atlas of tiles and indices referencing which tile to use. The following bit of code will read index from tile map then render out correct texture tile from the atlas.

int index = tex2D(_TilemapTex, i.texcoord0).x * _MaxIndex;
int xpos = index % _TilesetDim;
int ypos = index / _TilesetDim;
float2 uv = float2(xpos, ypos) / _TilesetDim;
float xoffset = frac(i.texcoord0.x * _TilemapDim) / _TilesetDim;
float yoffset = frac(i.texcoord0.y * _TilemapDim) / _TilesetDim;
uv += float2(xoffset, yoffset);
return tex2D(_MainTex, uv);

The result is a fully tiled city quad using just 4 vertices.

TilemapInAction

This works great, and it’s fast. If we were just using point filtering with no mipmaps, our job would be done already. Unfortunately linear filtering adds one set of problems and mipmaps add another. The first problem is texture colours bleeding in from adjacent tiles due to how linear filtering works. Image below demonstrates problem, note the dirt texture being sample at edge of water.

Bleeding

There are a few of ways to fix this, but one of the most robust is to manually wrap textures around to their opposite side in the atlas. This means that when the linear filter samples outside the tile area, texture wrapping will be simulated. The new atlas shows this concept with each tile wrapped 50% on all sides. Note: This solution works for tiling textures, but not for non-tiling textures where texture clamping needs to be simulated instead. The atlas generator is yet to support both wrapped and clamped tiles.

Atlas2

With a new atlas format, our fragment shader needs updating to sample interior part of each texture.

// Get offset to tile in atlas
int index = tex2D(_TilemapTex, i.texcoord0).x * _MaxIndex;
int xpos = index % _TilesetDim;
int ypos = index / _TilesetDim;
float2 uv = float2(xpos, ypos) / _TilesetDim;

// Offset to fragment position inside tile
float xoffset = frac(i.texcoord0.x * _TilemapDim) / _GutterSize;
float yoffset = frac(i.texcoord0.y * _TilemapDim) / _GutterSize;
uv += float2(xoffset, yoffset) + _GutterSize / _AtlasSize;

// Return fragment
return tex2D(_MainTex, uv);

These additions fix linear sampling to all but remove bleeding for tiling textures. Compare this image to the earlier version.

BleedingFixed

With texture bleeding taken care of, the next challenge is dealing with mipmaps. The graphics card has no understanding of our atlas, so tile wrapping makes it sample from the wrong mip level, which creates a whole new problem with cracks as shown below (you might need to open image to full size to see the cracking discussed).

MipMapCracks

Fixing this problem requires manually calculating the mip level in fragment shader. Fortunately there’s a lot of references online for dealing with this. Rather than just naively return the texture sample using tex2d, we need to use tex2dlod instead. Below is change to final line of code.

// Manually set mip level and return fragment
float mipLevel = GetMipLevel(i.texcoord0, _AtlasSize);
return tex2Dlod(_MainTex, float4(uv.xy, 0, mipLevel));

And the GetMipLevel() function.

float GetMipLevel(float2 iUV, float2 iTextureSize)
{
	float2 dx = ddx(iUV * iTextureSize.x);
	float2 dy = ddy(iUV * iTextureSize.y);
	float d = max(dot(dx, dx), dot(dy,dy));
	return 0.5 * log2(d);
}

With this new code, our mip cracking problem has vanished.

MipMapCracksFixed

And there we have it. A super-fast method of tile mapping from an atlas which defeats both texture bleeding and mip sampling problems, and only needs a single quad mesh.

There’s still more work to do, mainly around atlas generation. I need to handle wrapped tiles and clamped tiles differently, and manually pack mip levels to improve overall quality. I will get back to this in the new year with my performance review. On the subject of performance, these concepts can be expanded to reduce draw calls for the terrain system and city environments. This is just the first spoke in a big wheel of optimizations.

This last screenshot is of the material inside Unity editor, which shows how everything hangs together.

ShaderInEditor

References

I could not have pulled this off without the help of several people much smarter than myself. All the links below were used in formulating this solution.

Connor Hollis – Fast Tilemap Shader
http://connorhollis.com/fast-tilemap-shader/

IceFall Games – Terrain Engine
http://mtnphil.wordpress.com/2011/09/22/terrain-engine/

nVidia – Improve Batching Using Texture Atlasing
https://developer.nvidia.com/sites/default/files/akamai/tools/files/Texture_Atlas_Whitepaper.pdf

0 FPS – Texture atlases wrapping and mip-mapping
http://0fps.net/2013/07/09/texture-atlases-wrapping-and-mip-mapping/

Streaming World – Part 3

With all the major parts in place, next steps are all about improving overall appearance and boosting performance. I will tackle performance in the next and final part of this series. For now, let’s take a quick look at adding some visual appeal.

My first job is to improve texturing. All the screenshots you’ve seen so far have just been a flat grass texture. I implemented a basic simplex noise setup to create tiled patterns like below.

BeforeMarchingSquares

I then used marching squares to handle tile transitions from water > dirt > grass > stone. Daggerfall actually has a wider range of possible transitions (e.g. water > grass) but for simplicity I’ve only implemented the basic transitions so far. With marching squares the transitions look like this.

AfterMarchingSquares

I also added a little fog so distant terrain gradually blends into horizon. This gives the atmosphere a greater feeling of depth at long ranges like you would see in the real world.

The final step was to add nature flats (vegetation, rocks, etc.) to scene. This is just a basic random function with a density set per tile type. This could be expanded later to change vegetation density based on any number of variables. Finally, we have a world that almost looks ready to explore.

In the hills near Daggerfall

Hills of Daggerfall

Isle of Balfiera

Isle of Balfiera

Off the coast near Sentinel

Coastal Sentinel

Swamplands of Tigonus

Swamplands of Tigonus

There’s still a great deal of work to go before this is ready. Due to the rapid nature of development, nothing has been optimised yet and performance is very poor. My first priority is a full performance review of the entire tools to get this where it needs to be. Everything from loading textures and models all the way up to drawing terrain and foliage needs to be improved. This will unfortunately delay the streaming world features until early next year, but the end result will be a much improved code base.

Another, smaller item will be the overall scale of terrain and distribution of vegetation. If you look at the coastal Sentinel screenshot above, the terrain ramps up much too rapidly. I need to set terrain scale based on biome (e.g. desert is flatter than mountains), and terrain noise based on biome (e.g. desert is more rolling than mountains). This is just a matter of tuning the numbers going into terrain generation for an overall more pleasing game space.

On the whole, I’m very happy with how the streaming world is shaping up. It’s basically where I want it in terms of recreating Daggerfall’s simplistic overworld, and just needs performance and aesthetic tuning. I can’t wait to get all of this completed so you have a whole world to build on using Daggerfall Tools for Unity.

This will be my final post for the year. I’m shutting down work at the end of this week and will be spending valuable time with family. I wish you all a very happy and safe Christmas and look forward to catching up again in the New Year.

Progress Recap and Future Direction

I can’t believe it’s December already. The Holiday Season will be upon us before we know it. I also can’t believe Daggerfall Tools for Unity has only been in development a few months. If you’ve just started following this project, here’s how it looked on August 16th this year after wrangling import of a single model.

Scourg Barrow exterior model

Now it looks like the below and can do all this stuff. Check out the Direnni Tower Demo page if you would like to play the demo this video was created from.

In less than 4 months, this Unity Asset has gone from loading a single untextured model to full locations with dungeons, enemies, weapons, combat, sound, building interiors, and a fully streaming overworld system is on the way. I am very proud of what I’ve accomplished so far. But more importantly, I’m having fun.

And to my great pleasure and surprise, others have taken an interest in what this project signifies. You guys understand these tools represent freedom to do creative things with Daggerfall, beyond just remaking the game. The simple demo above is only a taste of what’s possible.

For the first time all content and gameplay of Daggerfall can be recreated using a modern, powerful game engine. An engine which supports more than a dozen platforms and provides an entire development ecosystem backed by an enthusiastic community. It’s now possible to create entirely new Daggerfall experiences and share your creations with other Daggerfall fans. For example, community member Eric managed to get a city build running on Android.

If you’re interested, you will even find great tutorials and documentation to help you get started. And of course, everything is 100% open source.

If you don’t have development skills, you can still help by letting others know about these tools. The sky’s the limit for Daggerfall now, we just need more interested people to help reach those heights.

So that’s the last four months. What happens next? Obviously my first priority is to release version 1.2 with streaming overworld features. But that’s only a short-term goal, I also have plans for 2015 to share with you.

I want to keep growing and refining these tools, and encourage other developers to get on board. I believe the time is finally right to build a small game with Daggerfall Tools for Unity. This not only shows what is possible, it provides a starting point for others and helps critically evaluate suitability of these tools for larger projects. Part of the process will be tightening up loose screws and adding features to solve problems encountered on a real project. The result will be a new Daggerfall-styled game for you to enjoy, and a more refined version of the tools. I will talk more about this project in early 2015.

I also need to provide a support hub for Daggerfall Tools for Unity. Beyond just documentation and tutorials, support means engaging with new developers and giving them a place to cooperate and share information. This hub will be a new site attached to dfworkshop.net with a community focus. I want to make the emphasis all about you and what you create, no matter how large or small. There’s no reason we can’t build a microcosm of the lively mod scene enjoyed by later Elder Scrolls titles. I am planning out the beginnings of this site now and should be ready to launch in first half of 2015.

So that’s the tools in review, with exciting new things to come. I’m feeling very positive about next year and look forward to meeting new Daggerfall fans in the future.

One more thing. If you’d like to keep tabs on my daily progress, I try to tweet small updates as frequently as possible. You will find me on Twitter @dfinterkarma.

First Android Build

This is cool. One of our community members, Eric, successfully created a standalone city build on Android using Daggerfall Tools for Unity.

daggerfallTCC27

There are some issues with the sky and controls (these are bugs on my side), but on the whole everything seems to be working OK. Interior transitions and sounds are all working. Great work Eric!

What’s great about the above screenshot is that it shows Daggerfall could run on tablets without emulation. That’s not a DOSBox build up there, that’s a native Android build. The textures, models, and sounds are all created dynamically from raw Daggerfall binary files at runtime.

I’ve created a new blog category called “Community Spotlight”. Let me know if you make anything with the toolset and I’d be more than happy to feature it here.

Release 1.1 and City Basics Part Two

Daggerfall Tools for Unity 1.1 is now available for Download. This version introduces PlayerGPS and WorldTime components, along with several bug fixes and other enhancements.

There is also a new tutorial following on from City Basics, called City Basics Part Two. You will find this both inside the latest distribution and on the Tutorials & Docs page. This tutorial will help you create a fully automated day/night/season cycle using world time and a variable timescale.

I hope you enjoy this release and new tutorial. As usual, please let me know if you find any bugs or have trouble following the documentation.

Full 1.1 release notes are below.

  • Tutorials are now included with zip distribution.
  • Fixed inconsistent origins between blocks and world space. Imported blocks and locations are now all laid out in a positive X-Z direction with origin at south-west corner.
  • Added WorldTime and PlayerGPS components to core DaggerfallUnity singleton. These manage flow of time and player’s virtual position in world.
  • Added Time & Space options to DaggerfallUnity options. These options automate many time-based changes such as day/night cycles and seasonal changes.
  • Fixed RMB and RMB static assignments not working as they should.
  • Locations now store additional metadata about their world position.
  • Static door enumeration is now performed by API when initially processing model data. Door finding now has minimal overhead compared to previous post-layout method. Doors are also cached along with model data, so zero impact on future calls to GetModelData().
  • Removed individual door triggers for buildings and interiors. Doors are now tracked by a single component attached to building mesh. It stores an array of door positions evaluated used only when user clicks on building.
  • Added support for animated texture on imported Daggerfall models.
  • Added a SunlightManager to control intensity of sunlight rigs (including any number of secondary lights) and simulate time of day using a single key light for the sun.
  • Improved player position and facing when exiting buildings. The player is now positioned above ground using a ray hit and facing is determined by door normal.