Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Iso 2D engine using CG Shaders [video]

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
Iso 2D engine using CG Shaders [video]
Edgar Reynaldo
Major Reynaldo
May 2007
avatar

GullRaDriel
Member #3,861
September 2003
avatar

Dario, no new shader code ? Do you give up ??

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Dario ff
Member #10,065
August 2008
avatar

I wouldn't if that error made sense. :-/ How is it possible that just doing a simple substract operation as that makes the whole shader compiling fail? Even with a set value like 0.12? I'll try and debug it later on an ATI card instead.

EDIT: Now that I think about it, it just might be that it's running out of video memory, and since I forgot to put some checks, it might cause that weird behaviour. As Jones64 said, it was using almost 236 of VRAM, which I could cut down to nearly a third of it by merging some of the maps.

So I'll try and code a less expensive version. What utility do you guys use to check out the VRAM usage?

EDIT: Actually, it could be reduced even more since I didn't even used a Cache to load the bitmaps. ;) So yeah, I was repeating for all those tiles.

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Jones64
Member #10,718
February 2009

Dario ff said:

What utility do you guys use to check out the VRAM usage?

I used GPU-Z. It gives me enough info to notice extreme changes to Vmemory usage.

Dario ff
Member #10,065
August 2008
avatar

So, I've ported the (still horrible) shader code to GLSL, so feel free to try the new EXE and shaders(replace the contents of the old folder with this one). It might take a bit longer to load the first time since it has to cook the height map into the normal map the first time. The video ram usage got reduced by half when using a cache, but it didn't reduce as much as I expect when using the height and normal map in the same texture. I guess the GPU did some compression of its own?

The main reasons I switched to GLSL:

  • CG likes to have the weirdest bugs ever on ATI Hardware(believe me, I tested it on a decent card)

  • AMD provides a GPU shader analyzer for testing the fragment shader, simulating various cards. And I was astounded by the amount of crap NVidia lets me write with their compiler. It provides support for GLSL, but not CG. (Though HLSL is quite similar, but I'm not sure if it'll be safe either).

And yes, I got it working finally on an ATI card with this utility. When trying to compile the shader with the X### mobile models in the GPU Shader Analyzer, it just said "Hardware compilation failed", not detailing anything at all. But it also said the same error with even the most simplest fragment shader ever(Just fetching the color).

EDIT: Consider the thread title changed to GLSL. 8-)

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

I let it run for 10 minutes and all I got was a black screen. ESC didn't work so I had to call up Task Manager and then I got a window that said Terra-ge.exe had stopped working :
{"name":"603273","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/5\/25ea6bc4f98ae2522cac71ebbe67643e.png","w":503,"h":409,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/5\/25ea6bc4f98ae2522cac71ebbe67643e"}603273

It crashed inside atioglxx.dll for some reason.

The game log didn't say much, but maybe you can see how far it got with it :
game_log.txt

Dario ff
Member #10,065
August 2008
avatar

Are your drivers up to date?

EDIT: Or maybe try putting this dll on the game folder?

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Dario ff said:

Or maybe try putting this dll on the game folder?

That didn't help. This time, all it did was open a console window with a blinking cursor and did nothing.

Dario ff said:

Are your drivers up to date?

I have to download my graphics driver from Gateway. There's one driver that's only a few months more recent than the one I have, and there's another driver that I'm not sure is actually for my laptop, so I'm not going to mess with it. It would take over 10 hours for me to download it anyway.

If you upload a debugging exe, I'll run it through gdb for you.

gnolam
Member #2,030
March 2002
avatar

Dario ff said:

And I was astounded by the amount of crap NVidia lets me write with their compiler.

IME, that's true for GLSL as well - Nvidia lets you get away with some pretty awful standards violations.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

GullRaDriel
Member #3,861
September 2003
avatar

IT WORKS !
But I didn't leave it running enough long to experience what Edgar said.

One thing: the light spot isn't moving accordingly to the scroll.

Ho, and it's running damn slow, near 20 fps.

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Dario ff
Member #10,065
August 2008
avatar

Ho, and it's running damn slow, near 20 fps.

Mostly because no optimizations are done yet. Heck, it's even drawing stuff that it's offscren. :P And the sprites aren't resized and are built around a 1920x1080 resolution. First optimization would be loading a lower-res version if the resolution is small(like in laptops). And the second one, resizing them to fit the display well.

I'm glad it works on Gull's comp, but Edgar's problem is beyond my knowledge. :-/ Here's a debug build.

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

Thomas Fjellstrom
Member #476
June 2000
avatar

If you'd like me to test on my laptop (GL 2.1, intel 4500MHD on linux), I'd need source, or a linux binary.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Dario ff said:

Here's a debug build.

Well, I ran it through gdb, but it didn't give that much info. When it crashed, the backtrace looked like this :

#0  0x02dfa197 in atioglxx!DrvGetProcAddress ()
...
...
...
#1710 0x00410bf9 in TerraGE::Renderer::Render ()
Previous frame inner to this frame (corrupt stack?)

But it didn't list the line of source code that came from, so it's probably not too helpful to you, sorry.

GullRaDriel
Member #3,861
September 2003
avatar

Edgar, did you install the latest 10.12 drivers ?

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Edgar, did you install the latest 10.12 drivers ?

Edgar said:

I have to download my graphics driver from Gateway. There's one driver that's only a few months more recent than the one I have, and there's another driver that I'm not sure is actually for my laptop, so I'm not going to mess with it. It would take over 10 hours for me to download it anyway.

I don't know if I have a backup driver anywhere, so I don't want to take the chance that the new driver won't work for my laptop.

It's not that important that the program work on my laptop anyway.

GullRaDriel
Member #3,861
September 2003
avatar

Do you still surf @ 56k ?

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

GullRaDriel
Member #3,861
September 2003
avatar

That's hell of a slow one !! You're an internet gladiator Ed' ;-)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Dario ff
Member #10,065
August 2008
avatar

I figured out there was something pretty awful going on regarding the normals map and the lighting. But I corrected it, and it looks pretty awesome. :) I have to re-render all the normal maps though. But I better set the proper way to do it now or suffer the consequences later. ;)
{"name":"603300","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/2\/f2a0441d4347247ff2506f9007106383.png","w":894,"h":894,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/2\/f2a0441d4347247ff2506f9007106383"}603300
(The little block represents the light source)

It turns out, my older maps were being rendered relative to the screen, and not the local axis of the 3d object. So the vectors of the normal space were in screen coordinates, and using the dot product with the internal light vector didn't give good results at all. That's why I just did some hacks to get something similar working.

Turns out I figured out later how to render the normal maps relative to the local axis, and now it looks pretty sweet. For example:
{"name":"603301","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/1\/f131865e618c25a45fcc6a092139bd26.png","w":973,"h":800,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/f\/1\/f131865e618c25a45fcc6a092139bd26"}603301
Here the normal vectors are mapped correctly. The green channel goes with the Y coordinate, red with X, and blue with Z. Calculating the dot product between the light and the normal vector gave the results seen above(plus adding it to the directional light).

Just thought of sharing this little problem if someone wants to do something similar. :)

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

imaxcs
Member #4,036
November 2003

That looks way to cool to not be used in a game!! :o

Dario ff
Member #10,065
August 2008
avatar

imaxcs said:

That looks way to cool to not be used in a game

And just imagine how it'll look with animations! 8-) (Which I'm adding now)

Here's some more eye candy now that the normals are right.
{"name":"603308","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/0\/401e6cd9964742666b72163ed3320d14.png","w":923,"h":654,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/0\/401e6cd9964742666b72163ed3320d14"}603308

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

kenmasters1976
Member #8,794
July 2007

Looks great. Too bad my machine is so ancient to try it.

Dario ff
Member #10,065
August 2008
avatar

Ah Ken, when will you start saving up for the future? The prices have reduced quite a lot now, you're missing quite a big chunk of cool stuff with that old rig of yours. :( Pretty sure you could even trade it in and reduce the price a lot, since some of that hardware isn't available anymore. ;)

(Though I would keep an old computer just for history's sake, but...)

EDIT: Playing around with supporting animated objects now. Of course it's just a cube for the sake of testing if it works well, but this opens up possibilities for very complex animated characters rendered with per-pixel lighting. :) Here's a video:

video

It'd be awesome if I could get one of these in. 8-)
{"name":"baldurs2_screen005.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/d\/8dd7ba4986cb46b5c258498d8c26cde3.jpg","w":640,"h":480,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/8\/d\/8dd7ba4986cb46b5c258498d8c26cde3"}baldurs2_screen005.jpg

TranslatorHack 2010, a human translation chain in a.cc.
My games: [GiftCraft] - [Blocky Rhythm[SH2011]] - [Elven Revolution] - [Dune Smasher!]

 1   2   3 


Go to: