Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411546 Posts in 69383 Topics- by 58442 Members - Latest Member: vicemask

May 03, 2024, 05:18:39 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsCommunityDevLogsVatnsmyrkr【submarine exploration】
Pages: 1 2 3 [4] 5 6 ... 18
Print
Author Topic: Vatnsmyrkr【submarine exploration】  (Read 42754 times)
oahda
Level 10
*****



View Profile
« Reply #60 on: February 04, 2015, 12:04:23 PM »


UPDATE 23



Finally got around to implementing the first steps of GPU lighting!

Only point lights ATM. Tried to do it following this tutorial sans the normal map, but I couldn't get it working – however, reading a bit of this article and trying to copy its code along with what little GLSL I had done while implementing shader support in the first place, it seemed I had suddenly gotten to a point where I understood shaders better, and so I threw away the tutorial code and soon I had it working myself, with my own code. Pretty good feeling!

» View animated GIF here.

My code allows me to set the radius, so this is precisely what I wanted. One little quirk that I couldn't get around at first when trying to map the position of this point light to that of the mouse cursor was that its y axis kept being inverted, and multiplying various values by -1 did nothing. Googling, I found that the default origin of fragment coördinates happens to be set to the bottom-left rather than top-left corner of the screen and so I found the proper layout qualifier to change this.

Don't forget this golden little piece of code at the top of your fragment shader!

layout(origin_upper_left) in vec4 gl_FragCoord;

So this works for circular point lights and the next step will be to figure out how to do it with my raytrace (or segment or whatever the future method(s) will be) data. The current shader simply goes by the distance of each fragment coördinate from the position of the point light. Something more complex will be required for those weird polygon shapes.

EDIT:
Got multiple light sources working too.

» View animated GIF here.

-----


Also, of course, I won't be able to use the current sprite eventually, as it is pre-shaded with a specific light source and that sort of stuff has to be done dynamically in the engine. My idea is to use normal maps and other things to get the right effect. For that I need a sprite with little shading, albeit a bit of ambient occlusion to get some basic outlines no matter what.

I've been playing around with my original submarine model in Blender today.

I was trying to achieve the basics of this.



It looks rather bad ATM but I think this sort of basic shading is okay. I need to work on giving it the same nice sort of textures as the current sprite, with all those pretty whirls and twirls across its surface. Then add to that shader effects and a bit of blue colour correction and it might just work out.


-----


Here's an older picture of the model from various views.

In case anybody's curious. I've done some changes to the model today, tho, which are not reflected here, but seen in the render above, such as adding bolts to the tank at the bottom, pushing the windows a bit deeper into their sockets and making the divisions between the shell's sections slightly deeper as well. Apparently the metal ring surrounding the jellyfish is absent here as well.




-----


I've also moved code.

The classes related to levels, layering with parallax stuff as well as light sources were all in the Vatnsmyrkr part of my project up until today, but today I moved it all into the engine Karhu instead. It'll be useful for other projects too.
« Last Edit: May 21, 2015, 07:06:46 AM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #61 on: February 04, 2015, 06:37:36 PM »


UPDATE 24



I got the lantern working on the GPU eventually. At first I had a rather slow algorithm for checking whether or not to occlude the fragments, which I wrote years ago, but then googled up a faster version and now it's pretty smooth.

I got it to fade/smoothen out towards the end of the light cone using the same code I wrote do so for the full circles of my previous point lights but I've been stuck for a couple of hours now, trying many things, as to how I should get it to fade out nicely towards the other edges as well. But I guess sitting up until 3 AM isn't the best solution, so I'll go to sleep now and return to it tomorrow with a fresh mind.

» View animated GIF here.

So other than that it kind of looks and works like before. It'll be fixed up eventually as well, but having this done with shaders for my first time ever is very cool!
« Last Edit: May 21, 2015, 07:06:57 AM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #62 on: February 05, 2015, 07:59:34 AM »


UPDATE 25



So I refactored the code a bit, figuring out how to pass data to GLSL arrays of structs (containing arrays!) and got a neater structure for my lights (point lights and "spot lights" tho of course that's my own version – i.e. the type of light detecting collisions coming from the sub's lantern). I can now add spot and point lights as I wish and my engine takes care of everything under the hood.

So here's a partayous scene showing off some funky coloured lights intermingling:



And here's a more seriously lit scene with a bit of blue ambience added to the whole picture as well:



Still no layering, so the light is casted onto the foreground crane and stuff and is drawn on top of the submarine. That'll be the next step.

It's running very smoothly, anyhow! It didn't at first, but I figured out a couple of optimisations and boom~
« Last Edit: May 21, 2015, 07:07:06 AM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #63 on: February 05, 2015, 02:05:13 PM »


UPDATE 26



Woop!

WOBBLY WATER SHADER.



I hadn't been sure how to do this since fragment shaders are said not to be able to modify positions, but colours only, but I knew that there were ways, since I've seen the effect before, of course.

I'd kind of left the idea aside for later, tho. I just happened to be randomly flipping through my orange GLSL bible for ideas on anything and I just so happened to find a section titled Wobble. I read the first few paragraphs to realise that the way to indeed modify those positions in the fragment shader was to modify the texture coördinates, which is possible in there.

How to do so was found out by kind of just skipping the rest of the section and the most of the code and finding the difference. I simply had to let the snippet texture(imgTex, coordTex) become texture(imgTex, coordTex + something). That something would have to be related to a sine wave in order to achieve the desired effect. So I passed in the game's time variable to the shader and used that combined with a sine wave and the gl_FragCoord constant to do the work incredibly easily and incredibly fast.

Within minutes of toying with this, the effect seen in the GIF above had been achieved! Thank you, orange GLSL bible!

So I probably won't be using a very extreme version of this effect for the game at all times. I think I'll have a slight hint of it going on constantly, tho, just to help sell the underwater effect a bit more (especially in places where you can see the intersection between the water and the surface, applying this effect below the surface but not above) and then it will be exaggerated when things are moving (maybe a trail of a harder effect following the submarine as it moves) and during screen shakes and so on.

Add to that particles (which I hadn't quite realised just yet that I also would be able to do with shaders pretty much purely, until I saw a section on that during this GLSL bible flipping session as well) and whatnot and I think a lot of underwaterness may be expressed eventually!

SHADERS ARE FUN AND HAVE OPENED UP SO MANY NEW POSSIBILITIES FOR THIS GAME I AM SO HAPPY ÆÆÆÆÆÆ

And of course this added not even the least bit of decrease in performance. Shaders are awesome.
« Last Edit: May 21, 2015, 07:07:15 AM by Prinsessa » Logged

Schrompf
Level 9
****

C++ professional, game dev sparetime


View Profile WWW
« Reply #64 on: February 05, 2015, 03:39:12 PM »

Cool indeed. I love playing with shaders, and I love seeing people playing with them :-)
Logged

Snake World, multiplayer worm eats stuff and grows DevLog
oahda
Level 10
*****



View Profile
« Reply #65 on: February 05, 2015, 04:25:16 PM »

I'll just try not to overuse them all too much~
Logged

oahda
Level 10
*****



View Profile
« Reply #66 on: February 06, 2015, 05:57:21 AM »


UPDATE 27



Playing around with the lights. Made the one surrounding the entire sub go brighter and larger when the lantern is on. Added light to the window and green light to the tank. Made all these three light sources pulsate slightly both in radius and intensity.

I also added an autolight/self-light value to images so that they can set whether they should produce some light of their own, even in a scene with complete lack of ambient light and added a small hint of that to the jellyfish to give it some bioluminescence of its own.

Also did a quick hack to clip the light cone specifically behind the boat to see what it would look like. Much better!



And, yeah. Environment lighting. And ambience colour. Those have been added as adjustable settings to the engine now, and I have a quick button on the gamepad mapped to turning the entire light system of as well. So step by step, here is lighting off ⇒ lighting on ⇒ lantern on ⇒ debug draw on:



This was recorded before adding all of those fancy extra lights.

Here are some variations on the environment light intensity and ambient colour variables:

« Last Edit: May 21, 2015, 07:07:29 AM by Prinsessa » Logged

oldblood
Level 10
*****

...Not again.


View Profile
« Reply #67 on: February 06, 2015, 06:26:46 AM »

You've been making excellent progress this week. This will add a lot to the atmosphere.
Logged

oahda
Level 10
*****



View Profile
« Reply #68 on: February 06, 2015, 01:35:38 PM »

Thanks! I'm quite happy about all the news this week too.

I've fixed that spotlight raytracing bug now, which was especially visible when pointing the lantern towards the spinning water wheel in the scene. Apparently I wasn't making sure in my code to always use the shortest ray when multiple hits would be detected within a single cast.



All smooth now!
Logged

jamesprimate
Level 10
*****


wave emoji


View Profile WWW
« Reply #69 on: February 08, 2015, 05:47:23 PM »

^ absolutely love this gif
Logged

oahda
Level 10
*****



View Profile
« Reply #70 on: February 09, 2015, 04:44:50 AM »

It's pretty neat! Shame it isn't seamlessly looping too.
Logged

oahda
Level 10
*****



View Profile
« Reply #71 on: February 11, 2015, 08:54:54 AM »


UPDATE 28



Got around to fixing that layering system for lights up, so now foreground elements don't get lit.

« Last Edit: May 21, 2015, 07:08:30 AM by Prinsessa » Logged

oldblood
Level 10
*****

...Not again.


View Profile
« Reply #72 on: February 11, 2015, 09:08:34 AM »

So much atmosphere. Amazing how the small aesthetics can add so much visually. Really giving the impression you're deep underwater.

Excellent work!
Logged

oahda
Level 10
*****



View Profile
« Reply #73 on: February 11, 2015, 09:45:07 AM »


UPDATE 29



Decided I didn't want that fuzzy glow around the boat, so I replaced the point light with simply adding some self-light to the sprite (and increased it slightly for the jellyfish). Tinkered with the values a bit and of course made sure to apply much less of it when the lantern is not turned on.





So much atmosphere. Amazing how the small aesthetics can add so much visually. Really giving the impression you're deep underwater.

Excellent work!
My girlfriend said something similar, about this little update making a big atmospheric change, so double the positive feedback seems good!
« Last Edit: May 21, 2015, 07:11:24 AM by Prinsessa » Logged

oldblood
Level 10
*****

...Not again.


View Profile
« Reply #74 on: February 11, 2015, 09:59:30 AM »

I like it a lot. You may want to increase the light coming from the windows as I'd assume there would be more interior light coming from within the submarine? But I guess that kinda depends on how you view your submarine and envision its operation.
Logged

oahda
Level 10
*****



View Profile
« Reply #75 on: February 11, 2015, 10:50:39 AM »


Yeah. I'll play more with it.



UPDATE 30



Fixed another thing I've had planned for a long time now that it's possible with the new lighting system.



A wider beam is shorter and darker whereas a narrow beam is concentrated, brighter and reaches longer. This is a mechanic and not just a visual detail. Will be used in the extended demo eventually.
« Last Edit: May 21, 2015, 07:11:49 AM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #76 on: February 11, 2015, 01:39:15 PM »


UPDATE 31



Another possible helper of atmosphere: light now getting darker towards the deep. Will obviously be bright up at the surface or wherever other sources of light may slip through. The game obviously isn't going to be pitch black all the way throughout, tho some sections really will be (but there will be various cues such as bioluminescent creatures and the sonar as well as, of course, the lantern to help out).

« Last Edit: May 21, 2015, 07:12:04 AM by Prinsessa » Logged

oahda
Level 10
*****



View Profile
« Reply #77 on: February 18, 2015, 10:29:34 AM »


UPDATE 32



Did some stuff in the last few days. Here's a representative GIF:



  • Light flickering when turned on (GIF recorder is a bit too slow to capture it properly tho).
  • Particles floating around in the water. Barely visible in the dark but all the more reflective of light once they do receive it!
  • Water surface! The underwater game finally has water. Note slight wobble below surface but none above.

Here's showing that driving fast towards the surface does stop you, but isn't like hitting a wall:



As for technical details, the surface is visually all a fragment shader based on a vertical coördinate for the surface. Everything is hacky and hardcoded in various places throughout the codebase ATM, but hey, it works! Cleaning up comes eventually.

I suppose that might be said for my workflow in general. I try to implement things quickly at first so that I can see the results and tweak the variables. Then I generalise what needs to be generalised and clean up what needs to be cleaned. I try not to preöptimise or generalise what does not need optimisation or generalisation right now.

The shader ignores the blue ambient light above the surface, applies one thick, faded line at the top, and a thin, more intense one at the very top. Looks good enough for me! Some slight sine wave movement for now. The water is very still anyway. I'll try to make it react to the submarine later.

-----

Also fixed up the controllers, movement and speed a bit and moved the buttons around (swapped sonar and lantern buttons) after getting some input.

Oh, and I made the magnet glow a little by itself so that you can keep track of it even in complete darkness:

« Last Edit: May 21, 2015, 07:13:30 AM by Prinsessa » Logged

oldblood
Level 10
*****

...Not again.


View Profile
« Reply #78 on: February 18, 2015, 10:38:39 AM »

I think the process you have in place of cranking out the features and then optimizing and improving them later seems to be working well for you. It's almost an "Agile" approach to project management.

It's nice to see the features you've had in place gradually improve and watch these small tweaks and adjustments have such great visual impacts.
Logged

oahda
Level 10
*****



View Profile
« Reply #79 on: February 18, 2015, 11:01:18 AM »

I think the process you have in place of cranking out the features and then optimizing and improving them later seems to be working well for you. It's almost an "Agile" approach to project management.
Oh, I haven't been thinking in terms like that since they were discussed in school a bunch of years ago. Maybe you're right. Seems effective, anyway. Seeing results is motivating!

It's nice to see the features you've had in place gradually improve and watch these small tweaks and adjustments have such great visual impacts.
Yep! Visible water was obviously a pretty big one for this game.

-----

On a less serious note I also got crazy with the wobble shader and recorded...

.

EDIT:
Oh, and while the submarine can't leave the water, it's not impossible that one might be able to reach things with that magnet:

« Last Edit: February 18, 2015, 11:30:06 AM by Prinsessa » Logged

Pages: 1 2 3 [4] 5 6 ... 18
Print
Jump to:  

Theme orange-lt created by panic