Let's Make A New Demo!

Discuss Daggerfall Unity and Daggerfall Tools for Unity.
User avatar
LypyL
Posts: 514
Joined: Sun Mar 22, 2015 3:48 am

Re: Let's Make A New Demo!

Post by LypyL » Mon Apr 27, 2015 5:57 am

I'll see if I can iron this out, if LypyL doesn't get there first. Alternatively, implement a jet-based version of Joust. :D
I'm working on a improved jet script, and I've got this fixed (though I like the sound of jet jousting :lol: )

User avatar
Nystul
Posts: 1423
Joined: Mon Mar 23, 2015 8:31 am

Re: Let's Make A New Demo!

Post by Nystul » Mon Apr 27, 2015 10:19 am

Interkarma wrote: I agree completely. A big part of this is how Daggerfall's content is constructed, all those hundreds of tiny tiling textures. I already do a lot to atlas textures and combine meshes to help things get batched together. Fortunately there are still a few more tricks I can use before we start edging into "prebake" territory, which isn't somewhere I want to go.
repositioning of unity terrain is also very costly. I would love to have a fasttravel event (same mechanism with delegates/event as with positionupdate script by lypyl - so I would have an easy way to determine when to update world terrain.
In theory it is sufficient to update only on a floating origin update and a fast travel event ;)
I have a workaround in the meantime, but it is suboptimal (update function inside IncreasedTerrainDistance):

Code: Select all

        void Update()
        {
            if (!ReadyCheck())
                return;

            if (!dfUnity.MaterialReader.IsReady || dfUnity.MaterialReader.TextureReader.TextureFile == null)
                return;

            if (worldTerrainGameObject == null) // lazy creation
            {
                worldTerrainGameObject = generateWorldTerrain();

                // set up camera stack - AFTER layer "WorldTerrain" has been assigned to worldTerrainGameObject (is done in function generateWorldTerrain())
                Camera.main.clearFlags = CameraClearFlags.Depth;
                secondaryCamera.clearFlags = CameraClearFlags.Depth;
                secondaryCamera.depth = 1; // rendered first
                Camera.main.depth = 3; // renders over secondary camera
                secondaryCamera.transform.SetParent(Camera.main.transform); // make 2nd camera inherit transform from main camera
                
            }                      

            // Handle moving to new map pixel or first-time init
            DFPosition curMapPixel = playerGPS.CurrentMapPixel;
            if (curMapPixel.X != MapPixelX ||
                curMapPixel.Y != MapPixelY)
            {
                if (worldTerrainGameObject != null) // sometimes it can happen that this point is reached before worldTerrainGameObject was created, in such case we just skip
                {
                    // Get terrain key
                    int key = TerrainHelper.MakeTerrainKey(curMapPixel.X, curMapPixel.Y);
                    Transform playerTerrainTransform = streamingWorld.PlayerTerrainTransform;
                    //Debug.Log(String.Format("playerTerrainTransform (x,z,y): {0}, {1}, {2}", playerTerrainTransform.position.x, playerTerrainTransform.position.z, playerTerrainTransform.position.y));

                    if ((playerTerrainTransform.position.x < MapsFile.WorldMapTerrainDim * MeshReader.GlobalScale * 0.5f) && (playerTerrainTransform.position.z < MapsFile.WorldMapTerrainDim * MeshReader.GlobalScale * 0.5f))
                    {
                        // do not forget to update shader parameters (needed for correct fragment discarding for terrain tiles of map pixels inside TerrainDistance-1 area (the detailed terrain))
                        Terrain terrain = worldTerrainGameObject.GetComponent<Terrain>();
                        terrain.materialTemplate.SetInt("_PlayerPosX", this.playerGPS.CurrentMapPixel.X);
                        terrain.materialTemplate.SetInt("_PlayerPosY", this.playerGPS.CurrentMapPixel.Y);

                        // update water height (thanks Lypyl!!!):
                        Vector3 vecWaterHeight = new Vector3(0.0f, (TerrainHelper.scaledOceanElevation + 1.0f) * streamingWorld.TerrainScale, 0.0f); // water height level on y-axis (+1.0f some coastlines are incorrect otherwise)
                        Vector3 vecWaterHeightTransformed = worldTerrainGameObject.transform.TransformPoint(vecWaterHeight); // transform to world coordinates
                        terrainMaterial.SetFloat("_WaterHeightTransformed", vecWaterHeightTransformed.y);

                        Vector3 offset = new Vector3(0.0f, 0.0f, 0.0f);
                        updatePositionWorldTerrain(ref worldTerrainGameObject, offset);

                        MapPixelX = curMapPixel.X;
                        MapPixelY = curMapPixel.Y;

                        updateSeasonalTextures();
                    }
                }
            }
        }

User avatar
Uncanny_Valley
Posts: 162
Joined: Mon Mar 23, 2015 5:47 pm

Re: Let's Make A New Demo!

Post by Uncanny_Valley » Mon Apr 27, 2015 11:20 am

No idea on this one, I'm not able to reproduce anywhere after quite a bit of testing. The weapons aren't aware of the player location at all, so it shouldn't matter where you are. Hmm, maybe there was an input glitch, considering jet and weapons both use Mouse1 for input. Can you try a freshly loaded demo and see if you can reproduce from the start?
I tried to reproduce it myself but with no luck. I don't know how or why I got this bug. Last time it happened I went into a dungeon, noticed that I couldn't attack, went outside, I could attack, went inside the dungeon again, couldn't attack, went outside, could attack, fast traveled to a town, could still attack, went inside a house, couldn't attack. I do remember flying around with the jet for quite a while before this, I tried to press all different buttons to see what it could do, I remember testing to see if I could spawn the jet inside a dungeon (you can't :) ) and I fast traveled a few times with the random travel. But as I said, I tried everything that I did before and I can't reproduce it. So, perhaps it was just a random input glitch.

User avatar
Interkarma
Posts: 5478
Joined: Sun Mar 22, 2015 1:51 am

Re: Let's Make A New Demo!

Post by Interkarma » Mon Apr 27, 2015 10:58 pm

Lord Berandas wrote:Hey guys! You're doing really awesome job! I just tried the new demo and it's completely perfect, all the fine details like grass or birds...just awesome!
But the messed up music bug is still present, don't know what's the reason for that, but my music plays very choppy or slow and this is happening since the very first demo you published.
Keep up the good work! ;)
Good news! I've fixed that music glitch. I'll pop up RC2 of demo as soon as possible for you to test.
LypyL wrote:I'm working on a improved jet script, and I've got this fixed (though I like the sound of jet jousting :lol: )
Thanks mate. :)
Nystul wrote: I have a workaround in the meantime, but it is suboptimal (update function inside IncreasedTerrainDistance):
Thanks again. :) I'll pop this and try it soon.
Uncanny_Valley wrote:But as I said, I tried everything that I did before and I can't reproduce it. So, perhaps it was just a random input glitch.
Thanks x3 for testing that out. :) It's probably some interaction between the weapon input and jet inputs. Doesn't seem too common though, so good enough for a demo.

User avatar
LypyL
Posts: 514
Joined: Sun Mar 22, 2015 3:48 am

Re: Let's Make A New Demo!

Post by LypyL » Sun May 03, 2015 9:45 am

edit: Updated version here


Simple fast travel map

Image

Just a super simple fast travel solution I whipped up for the demo. Currently it's limited to using the sliders to selecting x,y coordinates (there are functional input fields for getting Region and location names that will set the sliders, but they are disabled for the time being )


The red dot on the map represents the current location, and the other shows the travel destination.


Setup:

1. Add ToggleTravelMap to input manager.

2. Add TravelMapContainer prefab to scene. You might see some errors on dropping the prefab into the hierarchy (something like modifications.empty() ), this is apparently a known bug in unity and doesn't seem to have any effect.

Post Reply