SyntaxBomb - Indie Coders

Languages & Coding => Unity => Topic started by: Alienhead on January 09, 2024, 04:56:42

Title: Just getting ....
Post by: Alienhead on January 09, 2024, 04:56:42
Just getting started with Unity, I wanted to do some webGL stuff and the engines I use don't support it, so after experimenting with godot and unity for a few weeks I've decided Unity is what I will use.  Heh, lesser of two evils?

Whoa, what an ecosystem Unity has though, I've been working with game engines all my life, but this Unity seems like it's going to be challenging.

More later !
Title: Re: Just getting ....
Post by: 3DzForMe on January 13, 2024, 03:57:40
Had a dabble with Unity a while back, hows it going?
Title: Re: Just getting ....
Post by: Kronos on January 13, 2024, 12:27:15
I must be getting old because I just can't get my head round these modern engines like Unity, Godot, Flax Engine etc. So many controls for everything.
Title: Re: Just getting ....
Post by: Alienhead on January 14, 2024, 04:35:50
Quote from: 3DzForMe on January 13, 2024, 03:57:40Had a dabble with Unity a while back, hows it going?
It's a lot different from engines I have used in the past.  I really hate a game engine that tries to do everything for you. It ultimately just gets in the way. But I'm getting along with it, making a few components which i will need later on.  The coding side of things is a breeze with unity, c# isn't hard to pick up if you know any other language whatsoever.  The hardest part has been getting my head around their graphical workflow, but even that is starting to make sense to me now..  not sure if thats good or bad hehe.
Title: Re: Just getting ....
Post by: Alienhead on January 14, 2024, 07:29:50
Quote from: Kronos on January 13, 2024, 12:27:15I must be getting old because I just can't get my head round these modern engines like Unity, Godot, Flax Engine etc. So many controls for everything.
Flax Engine is very very nice.  I would had picked it over Unity if it weren't for me needing some WebGL support. Flax engine seemed superior to me over Unity in nearly every aspect. 
Title: Re: Just getting ....
Post by: Alienhead on January 17, 2024, 19:07:15
Day 7, I've actually got a third person controller made, and I got the basis of a map working, really just learning the API thus far. I fear the 'Unity' way is starting to make sense to me now. Not saying that I like their approach but if that's what Unity offers and if I want to use Unity for their webGL support I must surrender my old ways and adapt. :(

This is running in WebAssembly, which is my overall goal to begin with. Picked up a low-poly asset pack ( was like 50% discount ) which had prefabs already in it so I was able to get right into the API and code without having to dibble to much in the art pipeline just yet.

ChatGPT has been a huge help, when I get stuck - instead of combing the unity forums or watching hours upon hours of meaningless tutorial videos - I turn to chatgpt and ALWAYS get/got a direct answer to my problem. I doubt I would had gotten off the ground with Unity unless for chatgpt. :)

I'm wanting to get into WEBGL distribution mainly for the itchio game jams. I had come to learn that webside games are reviewed and played 80% more than standalone entries when it comes to the jams. Of course if I was ever to release a steam game it would be a desktop install but for the game jams I'm going strictly webGL.

Next is getting myself familiar with the Shader graph then bullets! and joystick response over web assembly! Wish me luck :)>

(https://i.postimg.cc/tgPwR4JD/web.png)
Title: Re: Just getting ....
Post by: blinkok on January 18, 2024, 00:15:46
I would love to know how you navigate the scene objects with the camera. What is the logic?
Title: Re: Just getting ....
Post by: Alienhead on January 18, 2024, 00:31:55
Sure!,  this is a VERY simple tpc I worked on today.

Quoteusing UnityEngine;
public class ThirdPersonController : MonoBehaviour
{
   
public float speed = 6.0f;        // Character movement speed
    public float rotationSpeed = 300.0f; // Character rotation speed

    private void Update()
    {
       
// Get input axes
        float horizontal = Input.GetAxis("Horizontal");
       
float vertical = Input.GetAxis("Vertical");
       
// Calculate movement direction
        Vector3 movement =
new Vector3(horizontal, 0.0f, vertical);
        movement.Normalize();
// Ensure diagonal movement is not faster

        // Calculate and apply movement
        Vector3 moveDirection = Camera.main.transform.TransformDirection(movement);
        moveDirection.y =
0.0f; // Keep the character grounded
        transform.Translate(moveDirection * speed * Time.deltaTime, Space.World);
       
// Rotate the character to face the direction of movement
        if (movement != Vector3.zero)
        {
            Quaternion toRotation = Quaternion.LookRotation(moveDirection, Vector3.up);
            transform.rotation = Quaternion.RotateTowards(transform.rotation, toRotation, rotationSpeed * Time.deltaTime);
        }
    }
}

The camera is just parented to the player object and is pulled around with the rig.
Title: Re: Just getting ....
Post by: Alienhead on January 18, 2024, 00:39:51
Getting to know the shader graph is a whole nother' beast in Unity.  And I can see that most everything I want to do revolves around shader work.. 

In the video lessons I watched on Shader graphing in Unity, I was able to create a dissolve shader, for when the player is blocked by some other object.

You may notice some of the house is hidden to unblock the view of my player.
Hey it's a start, my first unity shader hehe.

To be honest, I've been working with game engines since the early DB days and before that actually ( ti994a) and I feel so overwhelmed by Unity, it's just to massive to try and pick up everything. I'm hoping to learn just the parts I need to make some kinda little webgl game then hopefully I can build on that knowledge with another game project etc etc..  If you are new to unity, and I am, looking at the big picture is enough to scare anyone away.  


(https://i.postimg.cc/NjNwp985/grips.png)
Title: Re: Just getting ....
Post by: Alienhead on January 18, 2024, 04:48:34
I'm actually having a lot of fun with the Shader graph feature in Unity, its quite powerful! I don't miss having to debug on shader toy anymore :)

Here's a toon shader implemented as a post-effect and not a per-material pass.  Needs some more "rim" tweaking, but again I'm just learning so like a bottle of wine.... it'll get better with time.

(https://i.postimg.cc/3w0G8tGg/toon.png)

Next up ... to SSAO or AO...  this is the question. Although the question may be answered for me already, I'm not sure webgl supports screen spacing. Soooo most likely I'll try to work some standard ao in there.
Title: Re: Just getting ....
Post by: Matty on January 18, 2024, 05:20:44
In my opinion the biggest difference between engines like Unreal and Unity versus those with older tech like Blitz3d is that if you want a realistic looking 3d scene you mostly just put the models in, turn on the lights, and make sure the objects have the correct material settings and it looks like a somewhat realistic scene. Whereas in blitz and older tech you pretty much have to do a whole heap of fakery and tricks to make scenes look somewhat real. That's a gross simplification, but it's akin to how with the old 8 bit arcade games the developers had to pull all sorts of hardware tricks sometimes to do things that today we just throw a bunch of sprites at the screen and the hardware is all powerful enough to do everything needed by default.
Title: Re: Just getting ....
Post by: Alienhead on January 18, 2024, 13:41:26
One thing I've noticed and I don't like at all with unity is each and everything you add to the system requires tons of optimization. 

For example, I wrote a little small script to check for impact with a bullet layer, if found it breaks a plane ( simulated breaking glass ).  I was wondering why my FPS dropped about 60% just by initiating this script in game.  I later found out that collision checking is another world in Unity.  Setting up collision layers for do's and don't s is a major requirement in unity if you want to do anything special and keep your FPS rate normal.  I since optimized it but what a pain in the ***.  You literally have to optimize and stress test any and everything you add to the engine. Perhaps this is because I'm so new to the engine, like anything else  - with time you pick up on the do's and dont's and then you don't really have to to pay such attention to optimizing on every little thing you do.

Excuse the choppiness, my Radeon gpu doesn't record and play at the same time near as good as my nvidia, and the AMD is about 6 years newer than my nvidia! Ha, go figure.  From here out I'm sticking with nvidia. ( Radeon RX 6800 XT vs  Geforce GTX 1080. )



I'm wondering if this would be a good stopping point, I would like to spend the same amount of time in Godot and replicate the exact same scene just to see and compare the differences in dev time, difficulty level and performant variables.. Hmm however, I don't think godot offers shadowing in WebGl builds.. I need to check up on a few things first - I suppose.  

More later !
Title: Re: Just getting ....
Post by: Matty on January 18, 2024, 20:27:51
I like the video but some tips that you might consider:

Adding some kind of at least a blob shadow beneath the character would make it look like he's walking on the ground more...without it it doesn't always look like he's walking on the ground.

In terms of frame rate - it feels as if the framerate is a little choppy for just a single animated character walking around.

Other than that though it does look quite nice. The cell shading is good too.
Title: Re: Just getting ....
Post by: Alienhead on January 18, 2024, 22:25:35
Thanks for the comments. 

A couple things, in that video the game was actually running at 300+ FPS,  The rig I'm on has AMD gpu in it and their video recording software is horrid.  I so miss my nvidia. :(

Another thing, this is html5 build, so things arent 100% smooth as they are with a regular desktop build.  I switched the target over to PC and did a test build and i was getting over 600 fps with that scene.

And another thing to consider, I'm 8 days into learning Unity, no question I'll pick up on tons of optimizing techniques in the near future.

I've ditched Unity's shadowing shaders in favor of Shader graphing me some more up to date soft shadows, those unity hard shadows I cannot stand. :)

Anyways, appreciate the comments, always good to hear something from someone else.

Revision - screenshot:

(https://i.postimg.cc/N0RzDHyZ/REVAMP.png)

The terrain is nothing more than parallax mapping with a slight touch of tessellation ( although tessellation does not work in webgl, Im going to leave it in for pc builds ), Unity has a gorgeous 'displacement' system at it's core. It's just a matter of getting your heightmaps just right so they look real in realtime.
Title: Re: Just getting ....
Post by: Qube on January 19, 2024, 06:36:12
Great progress ;D

Unity does soft shadows too, not just hard shadows. Not sure if you are doing this but if you Instantiate objects then your FPS can take a hit whilst it does it, so object pooling is the recommended method.
Title: Re: Just getting ....
Post by: Alienhead on January 19, 2024, 09:51:10
Not pooling yet, and yes I am creating and destroying bullets non stop.  Thanks for the tip !
Title: Re: Just getting ....
Post by: Alienhead on January 19, 2024, 18:26:00
OMG did the Unity developers go out of their way to make lightmapping difficulty comparable to brain surgery! ? !
After many many hours an many many videos I think I figured it out..  My level is now beast-mapped, no realtime lights as of yet. ( but for a little floating light above the players head ).

I'm using Microsplat terrain shader, for the parallax effect, but I haven't figured out just yet how to get the terrain lightmapping to show up..  Not sure if that shader supports a 2nd UV set..  must dig further!

Time to learn and play with light probes for indoor areas..  This should be fun :9

(https://i.postimg.cc/RFshRxM8/rev2.png)
Title: Re: Just getting ....
Post by: Alienhead on January 19, 2024, 23:13:02
Lightmapping with Beast is no fun, but once you come to grips with it - it's really powerful. After aligning some light probes around certain areas I was able to improve the lightmapping 10-fold!.

I'm doing a full scene bake as I post this message, full details so it's probably got about an hour or so to go, but I think it's going to look nice. I'll post a final later.

I think it's time to get off the lighting stuff and move into some basic Ai and mob spawning. Basic Ai as in Navmesh agents or perhaps for speed purposes some A*star pathing.

+1 for Unity.

(https://forum.unity.com/proxy.php?image=https%3A%2F%2Fi.postimg.cc%2F1z61sJ9f%2Flight2.png&hash=bb3844d02b5041f71fef614f2d6ea983)

The effort to take Unity ( which I knew nothing about last week ) and build a game from ground up, that plays on webgl, in under  a month  ... errrr 2 months CONTINUES...  stay tuned.. :)
Title: Re: Just getting ....
Post by: Alienhead on January 20, 2024, 02:15:18
Ahh nothing fast about beast lightmapping, I see now I'm going to just queue my lightmapping sessions up as I go to bed in the evenings lol.

Added volumetric fog and clouds, this was a free asset I found while combing the unity forums in search of Light probe information.  It should turn out pretty good when I start to work on the weather/rain system.

I think I'll eventually take the volumetric clouds out and put in a dynamic skybox, just to make it a bit more web friendly.

Baked in the ambient occlusion as well, didn't see much reason to runtime the AO with a web-based game.

To me, its got that original Fallout look to it, which came about completely by accident, but hey.... I'm not bitchn' I loved the original fallout game/look.

Results:

(https://i.postimg.cc/m2qKrkbP/LMAP.png)

I think that's about all for today, I'll get started on some Ai and pathing stuff tomorrow.

SATY TUNED !
Title: Re: Just getting ....
Post by: Matty on January 20, 2024, 02:56:12
I love the artistic style of that.
Title: Re: Just getting ....
Post by: Alienhead on January 20, 2024, 05:29:46
Quote from: Matty on January 20, 2024, 02:56:12I love the artistic style
Tyvm.
Title: Re: Just getting ....
Post by: Alienhead on January 21, 2024, 05:02:32
I learned about Unitys Lut's and Post-Processing stacks today, then I watched football. :)
I wrote some sway scripts to rock the sign back in forth slowly, then some light flicker scripts to give the effect of a failing light bulb.  I got into sound and sound probes, ambience and area sounds are now in this map! Spooky actually. Changed the sky to a standard skybox with slow scroll texture. Added some distant volumetric fog, however I'm considering ripping that out for the faster scatter fog technique.

Revision 4: Luts and post processing:

(https://i.postimg.cc/nrghtRtR/ss.png)

The post-apo / steam?punk is starting to show up.. gas masks and toxic smoke/fog is on the menu! :)

Tomorrow: background/horizons, Particle effect system ( i want to get some sparks falling from the neon ). Then I want to look into some auto focusing depth of field routines. if I have time after all that I want to investigate using a detail mask to go under the light mapping uv layer - should I've some roughness to those low poly low textured buildings. a masking layer, this may be more time consuming then I'm thinking so that may have to wait until the following day. Scatter fog around the buildings and center road. 

So far everything in the scene is webgl compliant! I keep testing the builds each process I add.

Post rendering completed over night, this scene is fully baked other than the vig and some dof effect. 

(https://i.postimg.cc/4NyYxqyL/ss2.png)


Stay - tuned !
Title: Re: Just getting ....
Post by: Alienhead on January 21, 2024, 13:23:44
I decided last night I wanted my low poly buildings to fit the scene better, they weren't 'dirty' or 'grungy' enough to match up.

Well instead of throwing more polys at the models or additional addtional shader passes - I took to the Unity Shader Graph ( the very best feature Unity has in my book ). Using Substance painter i made a few noise maps then some heightmaps to match them.  Then imported them into the graph.

I used a perlin algo to randomly position the detail maps around the different faces, this way no two buildings will have the same 'dirty' patterns on them.

I then applied the mask in between the regular mesh material and the uv mapping layer.

Bingo! I got the grunge effect I was hoping for with very little effort. This shader does the regular rendering, the detail masks and the lightmap uv's all in a single draw call! Trying to keep things webgl friendly :)

(https://i.postimg.cc/50p5Ttx9/mask1.png)  (https://i.postimg.cc/HkXYTZVR/mask2.png)

and for original VS final runtime rendering.

(https://i.postimg.cc/ZqzMhjdf/orig.png)  (https://i.postimg.cc/JhcMwsGk/final.png)

The quest continues!  STAY TUNED !

Title: Re: Just getting ....
Post by: Qube on January 22, 2024, 02:06:37
Excellent looking work 8) Guessing you are approaching the status of a Unity convert? or it is, like I have, a love hate relationship with Unity :))  
Title: Re: Just getting ....
Post by: Alienhead on January 24, 2024, 14:37:11
Quote from: Qube on January 22, 2024, 02:06:37Guessing you are approaching the status of a Unity convert? or it is, like I have, a love hate relationship with Unity :)) 

Pretty much I'm sold out on using unity from now on. Mainly due to webgl support and I just cant stand godot's python-like scripting language.

As for desktop builds I'll probably stick to Ultra Engine and cpp.
Title: Re: Just getting ....
Post by: Derron on January 25, 2024, 12:41:43
Quote from: Alienhead on January 24, 2024, 14:37:11... I just cant stand godot's python-like scripting language.

You could use C# or C++ with godot too.


bye
Ron
Title: Re: Just getting ....
Post by: Alienhead on January 25, 2024, 14:45:33
Quote from: Derron on January 25, 2024, 12:41:43
Quote from: Alienhead on January 24, 2024, 14:37:11... I just cant stand godot's python-like scripting language.

You could use C# or C++ with godot too.


bye
Ron

True.
Title: Re: Just getting ....
Post by: Alienhead on January 25, 2024, 14:47:27
Rev. 4,

I've been working with post-processing volumes and scatter shaders, next I'm going to give some attention to the horizon and skybox blending.

(https://i.postimg.cc/FzVnttB0/rev4.png)
Title: Re: Just getting ....
Post by: Steve Elliott on January 25, 2024, 22:06:34
Looking very impressive, and as for Unity use what tool you need!...Personally my old skool efficiency spider senses kick in when I hear about a ton of variables being setup in the background by Unity (which I might not require).
Title: Re: Just getting ....
Post by: Alienhead on January 26, 2024, 05:44:12
Rev. 5 - Nuclear Winter

Complete with sound, ash and debris flying about.

Full spectrum scatter shader with 1 noise mask.. No compute shader needed !  Runs smooth as silk on PC but webgl does not support threading so the scattering happens on the main thread - not the best solution.  I'm considering converting this project over to desktop while I'm still learning Unity then do something 'webgl serious' later on.

(https://i.postimg.cc/Sx7Z5789/rev5.png)  (https://i.postimg.cc/wB5nHYmw/rev5-2.png)  (https://i.postimg.cc/RZ7gJQZF/rev5-3.png)

Nexy up, dust and glitter - wind gusts along the terrain base line only.. That should really give it a nuke-winter look.
Title: Re: Just getting ....
Post by: Alienhead on January 26, 2024, 18:30:29
Started fooling around with Unitys particle editor, WHOA, it's quite powerful.  I started laying out a few emitters for sand storms, ash fallout and other post-apo mood settings.

Here is a two-part emitter, first part lays down a slim layer of blowing sand on the terrain ( obeys to tessellation height maps ),  then the second part is the airborne version with more thinkness in it, it objects to Obstruction layer so as to not blow sand into a closed building.

More later  !

(https://i.postimg.cc/nz3wbd2d/sabd.png)  (https://i.postimg.cc/d1tj9TpM/nuke2.png)

The second effect ( tornadao )  was actually in a 101+ particle asset PACK, NOT MY CREATION.
Title: Re: Just getting ....
Post by: Alienhead on January 27, 2024, 15:36:38
Rev. 6

Started working on populating the map somewhat, atlas texturing everything to keep my batches down.

Thats about it for a few days, got to go offshore.  

Stay Tuned!

(https://i.postimg.cc/vTjSZ4wn/REV6.png)
Title: Re: Just getting ....
Post by: Alienhead on February 07, 2024, 15:37:22
Wow Unity is a massive system, as strong and powerful as it is - it is still very delicate in many areas. I had to re-think my project from ground up , I had to start thinking the Unity way. 

Needless to say, I trashed my previous project but I was able to take from it a month's worth of knowledge dealing with Unity.  I just spent the last 2 weeks getting to understand and learn Unity's animation system.  I really dislike it, but it's what they offer so I'll use it.  I now have enough understanding on their animation system to do something fun and cool with it. I've never touched IK animation before but now that I have absorbed it somewhat - I can't see how I ever lived without it. You can really do some life like stuff with that animation system.

I'm going to use what I've learned and start my project fresh with Optimization in mind.  Everything from culling, lod's, shader optimzation, atlas texturing, surface combining, draw call optimization, batch processing, pooling gameObjects, gpu instancing on skinned animators, baking atmosphere shadowing ( less real time lighting ), serializing my heavily used code sections and much more!  I'm working to get all this in place 'before' I start on any gameplay.  I want this game project to look and feel good and run on lesser than steller hardware.

Like I say Unity is a wonderful tool, but it's soft and delicate - you got to stay on the path from start to end to get the results you would expect, hence my retracing my project and starting fresh. I'm taking my time with this now, I'm getting all the systems I plan to use in place and optimizing as I go. Then I plan to go back over my templates I used to get to this point and start building my ARPG out of it. With some patience and lots of coffee I hope to have something really fun and playable in the upcoming months, even if it's only the start map. :)

I'm finally starting to see some light! More as I delve deeper !

*new project teaser*

(https://i.postimg.cc/DfPzNXnr/sawyer.png)  (https://i.postimg.cc/FsRzMHP7/sawyer2.png)
Title: Re: Just getting ....
Post by: Alienhead on March 04, 2024, 04:02:06
Still learning Unity, I doubt I'd ever took on this project if I knew what i was in store for.. 

Still working on lighting, and post shaders, created an entirely new third person controller. made a Ocean shader system, and a day to night vol-cloud system.

I'm hopeful to perhaps being able to start some game play stuff this upcoming week!
This is all done in the built in rendering pipeline, it seems so much faster than the urp and I havent even touched the hdrp - and I dount I will.

(https://i.postimg.cc/jdjSdYFC/brp.png)

Title: Re: Just getting ....
Post by: Alienhead on March 09, 2024, 03:53:51
Another progress report..

I'm still working on graphical stuff, everything you see in this shot is dynamic, some procedural. The clouds, weather, ocean, and lighting all run off a main brain script. I've been messing around with Unity's differed rendering techniques and I must say I've been able to achieve some very high frame rates for everything that is going on in this scene.  I must confess that Unity is really starting to grow on me, what started out as a simple webgl app I was wanting to make has turned into a whole new ball game.

The stuff I couldn't stand about Unity has now settled in and I'm finally able to work on my project without having to stop and pull up some docs or watch a lengthy tutorial video etc..  Don't get me wrong, there's still tons of stuff I'm still needing to learn but it's starting to flow together now and becoming an enjoyable experience.

With Unity's new webGPU (https://forum.unity.com/threads/early-access-to-the-new-webgpu-backend-in-unity-2023-3.1516621/) right around the corner, it's a great time to get the hang of the system! Crysis type graphics in a webpage running at 60 fps.. That's going to change a lot of thoughts towards web-based 3d development.

(https://i.postimg.cc/k4vfGThQ/def.png)

More later !
Title: Re: Just getting ....
Post by: playniax on April 17, 2024, 02:04:54

QuoteI must confess that Unity is really starting to grow on me
Took me a while too.

Nice stuff.