SyntaxBomb - Indie Coders

General Category => Worklogs => Topic started by: iWasAdam on January 16, 2018, 10:46:35

Title: testing OpenGL UV stuff...
Post by: iWasAdam on January 16, 2018, 10:46:35
Here's a quick shot of something I'm slowly working on...
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-16-at-10-40-51.png)

I'm testing static UV stuff in the hope of correcting everything that went wrong last time ;)
Title: Re: testing OpenGL UV stuff...
Post by: col on January 16, 2018, 11:00:36
Heh,

I use the same image for testing too, except the colours are slightly different and includes white  :)
Very handy to see where things aren't correct.
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 16, 2018, 11:16:36
Yep, the only way to know exact positions.
Here's an animated shot of the finished thing in testing with live update of the input image
(https://vjointeractive.files.wordpress.com/2018/01/uv.gif)

This is the start of external lighting calculations
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 16, 2018, 12:33:38
And here with a 'light grid' applied
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-16-at-12-31-47.png)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 16, 2018, 14:32:57
Just done a quick windows compile and all runs smoothly - YAY!!!!
Title: Re: testing OpenGL UV stuff...
Post by: Derron on January 16, 2018, 14:48:10
Whats that image in "Reply #2" showing: something to create an epileptic fit?

Hope this time things run on Win, Mac and Linux.

bye
Ron
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 16, 2018, 14:52:53
Yep, running brilliantly on Windows and Mac. Linus is currently a non starter as I cant get monkey to actually run on linux yet!!!

The Linux thing is a whole mess of pain which Monkey2 does NOTHING to help matters. There is NO help whatsoever about how to install and actually run it. the only words I have so far in regard to Linux is : PAIN IN THE ASS!

The fit image... was a test to see about having a separate canvas which could be drawn onto with full 2d and updated offscreen. it is then used as an input image for the 3d - hence animated!
Title: Re: testing OpenGL UV stuff...
Post by: col on January 16, 2018, 22:04:58
Quotetesting with live update of the input image
Do you mean you're rendering to ( or modifying ) the texture that's applied to a model already?
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 17, 2018, 06:03:35
QuoteDo you mean you're rendering to ( or modifying ) the texture that's applied to a model already?
yep, exactly that
Title: Re: testing OpenGL UV stuff...
Post by: col on January 17, 2018, 08:03:24
And each red part that's flickering is an an area of influence for a single light? You'll sum each one for a final lighting calculation?
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 17, 2018, 08:24:06
mmmm, sort of.
here's a look with the first light calculations in place
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-17-at-08-16-36.png)

there are 3 lights added and a set of light blockers forming a right angle (I think you can see where they are?)

in essence you add some lights, and light blockers. then run the simulation. The light will sort of flow around until it meets a blocker and then will go around them. of more blockers are used, then you will get a sort of wall effect where the light will cast shadows where the light can't get around.

It gives a sort of soft area light affect with shadows as a by-product
Title: Re: testing OpenGL UV stuff...
Post by: col on January 17, 2018, 10:53:28
That sounds and looks quite an interesting technique 8)

Could you also post separate pics of the same scene which shows a break down of the process?
Such as showing the area(s) as red, the 'blockers' and also the final image, all with the camera from the same position, so to clarify how it all fits together.
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 17, 2018, 12:45:28
no problem. Here's a gif showing the addition of lights and blocks
(https://vjointeractive.files.wordpress.com/2018/01/light.gif)

if you look to the right where there is an opening, you can see the light bleeding through as lights are added/removed.
Sorry about the gif compression...

I've used very defined light colors to show how they mix and are affected by the blocks
Title: Re: testing OpenGL UV stuff...
Post by: col on January 17, 2018, 17:03:16
Thanks,

In the example where you show 'shadows', there isn't a visible blocker (wall?) there - it's just for illustration purposes to show the effect working here yes? In a real world scene I assume you would place some sort of geometry, a wall or similar, there?

I was just confused as to why there is a 'shadow' or 'blocker' without visible geometry or am I going completely mad and the whole world really is turning upside down, inside out for me :p

It's a good effect  8)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 18, 2018, 11:37:31
Don't forget that the actual light processing is not done in 3d, but is all done in code and fed into the 3d.
So... That's why there are no actual 3d objects blocking things. But you can still see them!

In practice, you will need to update the light systems separately from the 3d system!
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 18, 2018, 14:29:15
Here's a better example with 2 lights in front of the archway, plus 2 blockers forming the base of the arch
(https://vjointeractive.files.wordpress.com/2018/01/test.png)

The archway and base plate are not textured in any way. and there is NO actual lights being used in the 3d scene itself.
I've draw in where the lights are so you get a feel for them...
Title: Re: testing OpenGL UV stuff...
Post by: Rick Nasher on January 18, 2018, 15:58:42
It's looking quite interesting. How fast is this?
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 19, 2018, 06:53:44
currently hyper stable at 60fps on MacOS and Windows
Title: Re: testing OpenGL UV stuff...
Post by: col on January 19, 2018, 08:11:19
Certainly looks good 8)
You're calculating on the cpu or the gpu?
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 19, 2018, 08:51:27
the lighting is calculated on the CPU:
It currently uses a 64x64 grid of cells.
Light is added as rgb floats (0..255) to the required cells. But higher values can be used for bigger spread.
Blockers are added to any cells.
The light spread is then calculated
The calculations are done again to give a smoother look and make sure the light is creeping/fading around blocked corners etc.

The cells are transferred to an image and then out to the shaders where the light is added to the 3d objects.
The light grid is then decayed (not cleared) for the next set of light calculations. I decay it to prevent any hiccups and also it simulates that a light has persistence when switched off. it doesn't instantly go dark.
Title: Re: testing OpenGL UV stuff...
Post by: col on January 19, 2018, 09:43:16
Thanks for the detailed explanation! Sounds like a viable system. From what I've seen you doing you seem to have a respectable grasp on shaders - have you thought of doing the math on the gpu? or it doesn't need it?

Your screenshots remind me of a couple of classics such Knight Lore and Head Over Heels, but with a visual style similar to Crash Bandicoot.
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 19, 2018, 12:17:15
It's been a log-term project to get the elements right. I thought I had the opengl right before but it all collapsed around me.

This is the latest version which has very good performance and I am slowly bringing the shaders back online.
Here's the latest tweak with the base textures added:
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-19-at-12-11-59.png)

This new version has a much better fidelity that the old version:
(https://vjointeractive.files.wordpress.com/2017/07/screen-shot-2017-07-25-at-14-11-57.png)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 19, 2018, 15:30:41
Last post showing something "looking" very nice as dev is worked on and stuff gets activated and tested:
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-19-at-15-28-271.png)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 20, 2018, 11:59:33
first look with initial particle code - this is just adding the smoke that the lights will have...
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-20-at-11-57-39.png)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 20, 2018, 14:27:20
and a mouse-eye view with different coloured pure red and pure blue lights:
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-20-at-14-25-00.png)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 21, 2018, 12:07:00
Here's the final result:
(https://vjointeractive.files.wordpress.com/2018/01/screen-shot-2018-01-21-at-12-02-42.png)

and animated:
(https://vjointeractive.files.wordpress.com/2018/01/flame.gif)

each light includes the following:
3 particle systems
- 1 for the flame
- 1 for rising smoke
- 1 for rising lit smotes (those little tiny glowing bits)

6 separate large particles for the additional smoke effect
1 separate large particle for the lens flare

All of these have random rotations, size, motion applied during their birth.

Title: Re: testing OpenGL UV stuff...
Post by: Derron on January 21, 2018, 12:29:49
You need some thing like "coals" or "liquids" acting as the source of the fire. Do not forget a slight random rotation on the z-axis - so the "direction" of the fire (aka the textures displaying a prerotated flame) changes from time to time.

Texture scale of the items is differing too much (crisp door and torch texture vs pixelated texture on the floor). Floor tiles use different texture scale.

Lighting looks good/cool.


bye
Ron
Title: Re: testing OpenGL UV stuff...
Post by: col on January 21, 2018, 18:00:12
I think if you add in normal maps then it would look absolutely awesome with the lights flickering away there... instead of just awesome :)
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 22, 2018, 06:32:45
Agreed, texturing should be the same though-out ;)

Col, there is one slight problem with normal maps - they depend on light sources. Currently there is NO light - yep, I know, it does my head in as well - hehehe

But there is are no lights being used in the 3d. in essence you are looking at non lit 3d. The lighting that you see, is completely separate from the 3d.

I have got my thinking cap on to see what I can come up with though. what visual effect were you longing to see??
Title: Re: testing OpenGL UV stuff...
Post by: Derron on January 22, 2018, 07:20:48
am not sure whether you still asked col for the desired effect - so excuse if I reply now.

If your torch gets some black liquid filled in (petroleum or so) then make sure it covers the bottom area of the flames - or better: make the flames texture more "flat" at the bottom (means it freshly "emerges from the liquid").


@ normal map
Do you want to calculate it too - so similar to the blockers affecting the light.

bye
Ron
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 22, 2018, 07:38:56
nah, I can calculate the normals no problem, but I think col was thinking about bumps and reflections - but I'm not sure.

In this case the best thing is to talk about the effect you want to see, and I'll think about how it could be achieved....
Title: Re: testing OpenGL UV stuff...
Post by: col on January 22, 2018, 10:53:38
Adam is correct.
I was referring to light interacting with bumps in the surrounding textures. For eg, you have 'highlights' in the textures for the floor, door frame and the door itself - if you had the light bouncing off of those correctly then that would finish the effect.

I know that the lighting is done in 2d... however your code is set up is it not possible to use one of the older 2d bump mapping techniques?
Title: Re: testing OpenGL UV stuff...
Post by: iWasAdam on January 25, 2018, 14:16:45
just been doing a bit of testing - to check how it was all working on windows and an old macbook.

Results Just in... Stable 60fps across all platforms including old Macbook!!!