Iso 2D engine using CG Shaders [video]
Dario ff

So I've been playing around with this pretty much all day, just placing and rendering random objects. So much fun that I felt like recording a video to show this!

[The video is inside the spoiler since the new thumbnail size is messing with the forum, but once you click it, it'll play fine!]

video

I saw a guy long time ago doing something like this(and quite better in some ways) using XNA, but since he kind of disappeared and never heard from him of releasing the engine, I just started playing with the idea.

Til now, it features the dynamic lighting showed off, and shadows casted by the directional light. They're not really accurate, but I think they look great. Trying to figure out how to do shadows casted by the dynamic lights as well.

And this must've been the simplest thing I ever wrote! Just two fragment shaders, some math and some bitmaps. It's built on Allegro 5 + the CG shaders. ;)

I'm looking for feedback on how could I improve the looks even more. Maybe ambient occlusion? Bloom? :) I was thinking of trying out water next.

GullRaDriel

You should add collision instead of occlusion.

It's a nice thing thought.

Mark Oates

That's pretty cool.

Dario ff said:

I'm looking for feedback on how could I improve the looks even more.

For the fun of it, how about a depth of field blur since you have the depth map.

What does it look like with the shaders turned off? 8-)

Dario ff

For the fun of it, how about a depth of field blur since you have the depth map.

I must admit that for some reason, I hate depth of field blurs. :P Anyway, I don't think it'd work well since it's not a perspective camera, it's isometric. And iso isn't really doing "focus" on a particular point.

Quote:

What does it look like with the shaders turned off? 8-)

Like the first part of the video. I even lowered the quality of the music in that part to show how crappy it looks with no lighting. :P And it wouldn't have any object intersections at all.

AMCerasoli

I like that... Could you attach the .exe? it's possible?

I don't like using 3D models with static cameras because you have to create an entire model and just one side is going to be visible...

But I really like isometrics games in 3D, with some perspective it looks really awesome. So I'm always thinking in a way to create a 3D world using an static camera, but take advantage of the entire mesh, material and texture...

Dario ff

But I really like isometrics games in 3D, with some perspective it looks really awesome.

But... then it's not isometric. :-/ It's just a camera angle.

EDIT: Mine isn't perfect isometric either, I think it's called an ortographic projection actually. But it doesn't take perspective into account. Bleh, I don't really know how it's called. It's just isometric with a slightly modified angle.

imaxcs

You probably mean orthogonal. :)
Anyway, it's looking really nice! Keep up the good work!

AMCerasoli

Where is the exe? where is the exe?!

Dario ff
imaxcs said:

You probably mean orthogonal.

Ah, I knew I was close, thanks. Pure isometric doesn't look really good IMO, I prefer the style used in the Infinity Engine games. It uses as similar angle, but slightly rotated.

Where is the exe? where is the exe?!

Umm, wouldn't you prefer I at least put some editor's functions, like selecting and moving the objects? It's all big one hack at the moment just moving the pilar, the robot, and the sphere. ;D

(And you could screw up the whole lighting by just pressing random buttons)

gnolam

You were right from the start with orthographic (if no perspective is involved). :P
(And an isometric projection is a special case of orthographic projection, where the projected unit axes are the same length with an angle of 120 degrees between each other)

Dizzy Egg

Looks frikkin awesome to me! Nice work.

Neil Walker

I remember watching the original ages ago and this look just the same. Keep it up and turn it into a useable api :)

Dario ff
gnolam said:

You were right from the start with orthographic (if no perspective is involved)

Then orthographic it is, I guess.

I'm trying out another angle camera at the moment and it looks sweet. Much better IMO. Compare the house to the one in the video for reference.
{"name":"603208","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d377a9a9895980e4fd8fa13ded954b6a.png","w":629,"h":468,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/3\/d377a9a9895980e4fd8fa13ded954b6a"}603208
I built it in a way that it's quite easy to change the projection settings. :) The thing is I have to render again all the objects.

And I've discovered there was a pretty horrible bug on the depth rendering, so yeah, quite a big part of the video was rendering it wrong. :-/ (At least the parts where the objects were elevated)

Keep it up and turn it into a useable api

Yeah, it can be easily plugged in since it just uses a Renderer class, a Camera, and the list of objects and lights. So just calling the renderer when drawing the frame should do all the work. ;) I need to do a usable editor though.

Neil Walker

I wouldn't push the boat out on an api or editor unless you really want to. The one here:
http://retrospec.sgn.net/users/ignacio/isoeng.htm

Has only attracted 1500 in 6 years ;)

Dario ff

Maybe a clean API for everyone isn't really needed, but an editor would be a must. And I have all my GUI code to reuse anyway.

I think you showed me isomot in the past. Must've been another of my isometric engine threads. ;D

Jones64

Wow! looking great!
Waiting for a wip version ;)

Dario ff

Here you go so you can play around a bit.
It isn't optimized at all, so framerate drops might be possible. And I'm not sure if the shader even works on most cards.

F1 - Show/Hide light positions.
F2 - Toggle Height Map
F3 - Toggle Normals
F4 - Toggle Lighting
F5 - Toggle Editor mode.

It might lag quite a bit more in editor mode since I'm just using al_get_pixel to know if I'm picking a certain object. I will replace that later.

In the editor, select an object with the middle click. Left click to move it to an X/Y position, and hold right click and move up/down to change Z. If you hold Left control while using right click, you can scale the objects.

It should adapt to your display's desktop resolution in the fake fullscreen mode. If not, you can replace some settings in the .ini.

Edgar Reynaldo

I ran your program, and there was about 30 seconds of black screen, then the screen turned gray. I messed around with the F-keys and F5 brought up a view of an isometric tiled square with a pale brownish texture on it. F1 drew a little yellow circle and a vertical line on the screen. Whatever it was supposed to do, I don't think it did. Of course this is on my laptop, with crappy onboard graphics though.

What was it supposed to look like?

Dario ff

Nothing like that really. It's just that the shader doesn't compile for some reason since I'm still learning about profiles. I tried with a 6100 and pretty much the same happened.

What's your GPU model?

Edgar Reynaldo

ATI Radeon X1270.

Dario ff

It's an integrated GPU right? I didn't really expect it to run well on that hardware...

All I guess you could try is going to the assets/shader folder and replace the profile in the .cgfx files with a text editor. Try out the glslf profile. The line is near the end of the file.

For example:
FragmentProgram = compile latest ps_main();
to
FragmentProgram = compile glslf ps_main();

And the loading time is because the bitmaps are pretty big. :-/

EDIT: I've always had some quirks when using the CG Effects file when compiling. I remember being able to compile almost anything by just extracting the fragment shader program from the first pass without anything else.

Neil Walker

The mouse doesn't work for me and the scrolling is really slow and jumpy, probably because I'm only getting 8fps according to fraps.

I've got an nvidia geforce 8400m gs running on an intel core 2 duo T8100.

AMCerasoli

I ran your program, and there was about 30 seconds of black screen, then the screen turned gray. I messed around with the F-keys and F5 brought up a view of an isometric tiled square with a pale brownish texture on it. F1 drew a little yellow circle and a vertical line on the screen.

I had the same problem... then I changed the game_config.ini file to see the program in windowed mode.. and the console after the gray screen says "Technique lighting did not validate. Skipping."

then I wrote in the console: "don't skip please"

and then the computer wrote "Sorry..." and the program closed...

EDIT: BTW my graphic car is also an ATI 12..something... in a laptop...

Dario ff

I'll try my luck in just extracting the shader program rather than using the full CGFX file.

EDIT: For reference, my GPU is an NVidia Geforce 9600 GT. I get 60fps almost all the time. Integrated GPUs have never worked well for me when shaders are involved. :-/

Neil Walker

I should add I have a laptop so it's the mobile version of the card, but dedicated non the less and is DX9 compatible.

Edgar Reynaldo
Dario ff said:

Try out the glslf profile.

This time after the black screen I got a white screen with a dark grey rectangle with a cutout on the bottom of the screen. F5 showed an isometric diamond outline on the screen.

Dario ff

Yup, it seems again, my code never builds on an ATI GPU! :D

I'll be able to debug this later more properly with a friend, so don't worry. It'll work, it's just that there are always some quirks I forget.

EDIT: Yeah, I did the same stupid mistake I did once of mixing up ints and floats. NVidia GPUs are more forgiving in that, and it's been nearly an year from using these that I forgot, sorry. Wait for take #2. :P

AMCerasoli
Dario ff said:

Yup, it seems again, my code never builds on an ATI GPU!

I'll be able to debug this later more properly with a friend, so don't worry. It'll work, it's just that there are always some quirks I forget.

Yes yes yes... I want my money back.

Dario ff

Try out these two shaders if you want. They're pretty horrible at the moment regarding optimizations obviously, but I didn't really expect to even put something like it online. :P

kenmasters1976

Wow! this looks really impressive!. I thought it was 3D until that part where you say it's 2D. Actually, I could've bet that it's 3D.

Nice work!.

GullRaDriel

Does not work there.
Symptoms are the same as Edgar, 30 second black, and a grey background after.

And the good news is that it's running at my display refresh rates ;-)

"Technique lighting did not validate. Skipping."

Edit: BTW I have a Radeon 5470 and MediaPlayerClassic let me play with it's shaders without problems. I use the latests drivers, 10.12, on W7 64.

Vanneto

Works here: nvidia geforce 8600GT.

EDIT: Forgot to say: awesome. :D

Dario ff

Does not work there.
Symptoms are the same as Edgar, 30 second black, and a grey background after.

Did you try the shaders I attached in the last post? Those fixed the problem I had with seeing just a white texture in an integrated 6100GT. Of course, it works incredibly slow, because it's a very crappy card. :P

Of course, it could be that it's still not compiling on ATI, but I can debug that one more in detail later.

I thought it was 3D until that part where you say it's 2D. Actually, I could've bet that it's 3D.

If I rendered much more awesome models(and textured) it would've been more obvious. :) I think the tiles are a pretty good example, those look great since they're textured.

Vanneto said:

Works here: nvidia geforce 8600GT.

Cool, that's my old card.

Edgar Reynaldo
Dario ff said:

Did you try the ones I attached in the last post?

Using the two new shaders you posted had the same result as the last time I tried it.

Dario ff

The shadow shader seems to be compiling correctly, it's the lighting the one with the problem.

Well, I wouldn't know how to debug it without a card for sure. :P All I can say is if you want, start commenting parts, except these lines:

struct PS_OUTPUT
{
    float4 color : COLOR0;
    float depth : DEPTH;
};

PS_OUTPUT ps_main(float2 normalMapTexCoord : TEXCOORD0)
{

    PS_OUTPUT Out;
    float4 color;

color = tex2D(texture, normalMapTexCoord);
Out.color = color;

return Out;

technique lighting {
  pass {
    FragmentProgram = compile glslf ps_main();
    VertexProgram = NULL;
  }
}

So yeah, you can comment pretty much everything inside ps_main(). If you see something visible, then you can try adding more and more lines until it screws up. That would help, if you're willing to do that.

EDIT: Oh, and don't comment the global variables that are above ps_main. Otherwise, the program will fail when setting them.

Neil Walker
Dario ff said:

float4 color : COLOR0;
float depth : DEPTH;
PS_OUTPUT ps_main(float2 normalMapTexCoord : TEXCOORD0)

The colons are baffling me? There are many voids in my C/C++ knowledge but all of them I thought I knew what I didn't know. But not these.

Dario ff

That's CG, not C++. :P Unless I misunderstood what you said.

Neil Walker

Well, that shows I should read the whole thread instead of random bits and why I didn't follow the syntax. I guess if I read all the code and saw the lighting bit at the end I might have realised something was up.

Still, glad to see there's nothing I don't know about C/C++ that I didn't already know I didn't know :)

Jones64

I tested it just now, it's pretty impressive :)
I haven't seen much of this way of 2D rendering before. Do you have any plans of making a full engine or a game with this? Would be interesting :p

Performance seems fine, but one thing I noticed is that the application uses about 236MB of video memory. Will this increase a lot if you build this into a full game?

Works smooth with a GeForce 8800GT in Win7-64.

Dario ff
Jones64 said:

Performance seems fine, but one thing I noticed is that the application uses about 236MB of video memory.

Well, the images I included had some useless empty spaces, and were very high-res, so it's expected. I could map the height map into the normal's alpha channel to reduce it 1/3 ;). And the shadow map is unnecesarily big as well, and I'll try to optimize it so it gets cropped as well. That should reduce the usage to a bit more than 1 half probably.

Mark Oates
Vanneto said:

Works here: nvidia geforce 8600GT.

That's the card I have!

Dario ff said:

Cool, that's my old card.

It's my new card. :-/

Then again, I did buy it like 2 years ago. That's "new" to me, since I'm old now.

Chris Katko

That's the card I have!

That's the same card my friend has. :o He's looking into a 460 for an upgrade. (Only $160)

Edgar Reynaldo
Dario ff said:

So yeah, you can comment pretty much everything inside ps_main(). If you see something visible, then you can try adding more and more lines until it screws up. That would help, if you're willing to do that.

Speaking of the second object_light.cgfx :

First, I went back to using
FragmentProgram = compile latest ps_main();

Then if I comment out lines 79-234 (everything), then I get to see the assorted isometric diamond floors, the mansion, the guy in armor, and the column. I tried to take a screen shot, but it captures the desktop underneath for some reason.

If I comment out line 219
// Out.color = color;
and line 233
// Out.depth = 1.0-depth;
which effectively returns the color retrieved from the Tex2D call at the beginning, then I get a gray screen, which makes no sense, since it is returning the same PS_OUTPUT as it was when I commented everything out.

If I comment out lines 113-158 (the while (i<32) { block), then I get a gray screen again, so I don't think there's anything wrong with that chunk of code.

If I comment out lines 161-203 (the if (directional_strength > 0) { block, then I still get a gray screen.

If I comment out lines 113-203 (both of the previous blocks of code) then I get a gray screen with all the objects in black, which makes sense since final_light is initialized to 0.0.

What values of final_light would make every color turn grey(transparent?)?

I don't really know how I could isolate the problem anymore.

Something else that doesn't make sense is why it works for some people, but not for others. All ps_main is doing is returning a color, and that should be the same for everyone.

Dario ff

Interesting. Could you do another test? Try these and replace object_light by renaming each of these.

Version _a will just pass the color and output with no depth whatsoever. So you'll likely see an isometric floor.

Version _b will pass both color and depth, but no lighting whatsoever.

Version _c will pass the directional light, but it won't cast any shadows.

Version _d will pass the directional light and cast shadows.

I've removed the parts for iluminating with dynamic lights. The full version would be the one you already have. If one of the versions doesn't work, then we've narrowed down the culprit. The reason it's grey is that it's most likely not compiling well. A final_light with a value of 0 would just turn it black.

Edgar Reynaldo

All four versions have the same result, a white screen with dark grey cutout rectangle on the bottom of the screen.

I changed all the
FragmentProgram = compile glslf ps_main();
to
FragmentProgram = compile latest ps_main();
and reran each test.

Results :

version _a -
Displayed all the objects.

version _b -
Same as _a.

version _c -
Looked somehow different than _a and _b, and the column was tinted pink.

version _d -
Only showed a gray screen.

So it looks like the problem is with casting shadows somehow.

Dario ff

Great. Version _d only has this (horrible I know) chunk of code added:

#SelectExpand
1 if (tz < shadow_f) { 2 float4 new_col; 3 float al; 4 al = 1.0; 5 6 new_col = tex2D(texture_shadow_map, screen_pos+float2((2.0/screen_w), (2.0/screen_h))); 7 float shadow_t; 8 shadow_t = new_col.r*255.0 + new_col.g*255.0*255.0; 9 if (tz < shadow_t) al+=1.0; 10 11 new_col = tex2D(texture_shadow_map, screen_pos+float2((2.0/screen_w), (-2.0/screen_h))); 12 shadow_t = new_col.r*255.0 + new_col.g*255.0*255.0; 13 if (tz < shadow_t) al+=1.0; 14 15 new_col = tex2D(texture_shadow_map, screen_pos+float2((-2.0/screen_w), (2.0/screen_h))); 16 shadow_t = new_col.r*255.0 + new_col.g*255.0*255.0; 17 if (tz < shadow_t) al+=1.0; 18 19 new_col = tex2D(texture_shadow_map, screen_pos+float2((-2.0/screen_w), (-2.0/screen_h))); 20 shadow_t = new_col.r*255.0 + new_col.g*255.0*255.0; 21 if (tz < shadow_t) al+=1.0; 22 23 al /= 5.0; 24 luminance2 -= 0.12*al*directional_strength; 25 }

So I guess you can comment there and see what happens. My guess is that ATI doesn't allow to read from outside the texture, so that's why it crashes probably. If commenting those lines between al=1.0; and al /= 5.0; works, then it's that I guess. I'll try and fix those coordinates inside the texture's limits.

EDIT: Try the attached shader if you want. And thanks, this will help me a lot later. :)

Edgar Reynaldo

Using version _d, if I comment out this line :
luminance2 -= 0.12*al*directional_strength;
Then it displays like version _c, with a pink glow on the column and rectangular prism.

Edit for your edit :
I tried the shader you attached in your last post, and it was back to the white screen with dark grey cutout rectangle again. I changed 'compile glslf' to 'compile latest' again, and then it was back to the gray screen.

If I comment out the same line I did with version _d, then it works like version _c again.

Dario ff

I see. Then I guess you should try either:

luminance2 -= 0.12;
or
luminance2 -= 0.12*al;
or
luminance2 -= 0.12*directional_strength;

To see which of them won't let it compile.

Edgar Reynaldo

Using all the different combinations you posted, I still get a gray screen.

I just noticed on line 218 you have this :
if (luminance2 < 0.0) luminance = 0.0;

See how it sets luminance to 0.0 instead of luminance2?

Well I changed it to :
if (luminance2 < 0.0) luminance2 = 0.0;
and I still get a gray screen.

The only way it works is if I comment out
// luminance2 -= 0.12*al*directional_strength;
and leave
if (luminance2 < 0.0) luminance = 0.0;
as it was.

Dario ff

That weird behaviour reminds me of what might happen when using way too much RAM for the current shader.

I really don't have any clue how to solve that weird problem, other than trying to lower the amount of memory used.

Try lowering these arrays' size:

float light_x[32];
float light_y[32];
float light_z[32];
float light_r[32];
float light_g[32];
float light_b[32];
float light_range[32];

To 24, or 16.

And yeah, I couldn't figure out how to pass float3's arrays instead. :P

Edgar Reynaldo

Sorry, lowering the array size to 16 didn't help. It still only works if
luminance2 -= 0.12*al*directional_strength;
is commented out.

GullRaDriel

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

Dario ff

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.

Jones64

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

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-)

Edgar Reynaldo

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

Are your drivers up to date?

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

Edgar Reynaldo
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
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.

GullRaDriel

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.

Dario ff

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.

Thomas Fjellstrom

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.

Edgar Reynaldo
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

Edgar, did you install the latest 10.12 drivers ?

Edgar Reynaldo

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

Do you still surf @ 56k ?

Edgar Reynaldo

Rockin 2.7KB/sec, baby!

GullRaDriel

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

Dario ff

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. :)

imaxcs

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

Dario ff
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

kenmasters1976

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

Dario ff

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

Thread #606198. Printed from Allegro.cc