Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit/AppGameKit Studio Showcase / [AGKv1] Normal mapping

Author
Message
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Oct 2014 00:20 Edited at: 22nd Oct 2014 00:23
So I'be been tinkering with some of Cliff M's shaders and come up with a ghetto normal map shader... it doesn't quite work right now, and it would be great to get some insight into how I can orientate the normals correctly. Anyway, it's something... and it might be a good start for a fake 2D engine, with plain objects as sprites.



I'm gonna make a little tech demo once I find some cool normal mapped models and try and iron out some of the shader issues, then I'll release it.

I am the one who knocks...

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 22nd Oct 2014 10:19
Wow, this is my first time seeing any AppGameKit 3D materials looking like this.

fog
21
Years of Service
User Offline
Joined: 5th Oct 2003
Location: Newcastle, England
Posted: 22nd Oct 2014 14:30
Nice effect. Do you have a higher res footplate texture? That one looks a bit blurry and out of place.

CodeMonkey
11
Years of Service
User Offline
Joined: 6th Mar 2013
Location: Ireland
Posted: 22nd Oct 2014 17:43 Edited at: 22nd Oct 2014 17:48
I'm planning on using normal mapping in Skyway when I start creating more assets for the game..
AGK Normal Mapping

I found this tutorial very helpful:
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 22nd Oct 2014 17:59
it's great. It's a 2D scene (sprite) or 3D (plane) ?

http://www.dracaena-studio.com
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 22nd Oct 2014 18:06
Its basically a random maze, the metal and wood bits are the floor, and thats the top of a cube shown. It seems pretty good as long as the orientation doesn't change, which is why I thought it might be interesting for a fake 2D project.

I will watch that tutorial tonight CM, thanks for posting and your project looks great... I have a soft spot for these style of games ever since AudioSurf

Fog, yeah - it's just the first 2 textures I could lay my hands on, I plan to make a decent example with it, once I find a good normal mapped scene or model. Shame I don't have Mudbox, or I'd be making normal maps left and right


Thanks for the comments guys, will post more screenies as I go.

I am the one who knocks...
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 22nd Oct 2014 23:45 Edited at: 22nd Oct 2014 23:46
id be interested in seeing a 3d cube map shader. any ideas on how to write a shader like that...or even a sphere map simular to dbpros?

i think with agk you can set multi textures to an object with the stage flag so you must be able to do a cube map using shader code.

looks like a nice shader you got going!

i wish there was more information available for writting shaders for agk. i just dont know where to start.

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Oct 2014 00:48
I have been thinking about that, but with repeating textures, so rather than UV mapping an object, there are different textures for X Y and Z, and they get blended to suit the normal. I think it would work well for rock surfaces, giving a lot of detail and maybe also including normal maps. Could be used on terrain as well as geometry as I'd just use the 3D position to calculate each UV coordinate. Now this would be really cool in a voxel game using several small objects, not sure AppGameKit has the guts for it though.

That's something I want to try next I think. Kinda dragging my heels getting AGKv2, got a few interesting things to play with in v1 still

I am the one who knocks...
SoftMotion3D
AGK Developer
19
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 23rd Oct 2014 19:19
Quote: " Now this would be really cool in a voxel game using several small objects, not sure AppGameKit has the guts for it though."


maybe if your using c++, im not sure where the performance snag is using basic ,but i think its in the for x loops trying to update all those boxes. i have only successfully updated 16x7x16 blocks without a performance hit. if i increase that....my frame rate starts to drop rapidly.

now if you had a block object that consisted of several blocks each...that may work as i dont see the performance hit being too many polys, i think its the too many objects problem [related with using a for x loop to update them]

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 26th Oct 2014 01:09 Edited at: 26th Oct 2014 01:10
Little update - 3 lights now...



I am the one who knocks...

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Oct 2014 19:29
looks cool van
I hope I will be able to get back on coding soon ???
have you done anything more since the last version I sent you of eat drink slay ??

My girlfriend is still a pain in the ass that's why I haven't got back anytime sooner with the coding

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Oct 2014 09:55
Cheers Cliff, good to see you on the forums

I haven't done much with EDS recently, there are a few more levels now but that's about it. I will try and get rolling on content for it as soon as - trying to compress an 18 month diploma course into 6 months, so I don't have much time right now. Lets try and both get back onto it properly in the new year - make it a new years resolution

I am the one who knocks...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Nov 2014 10:42
Van B. Would this shader work on sprites?
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Nov 2014 11:44 Edited at: 8th Nov 2014 15:12
Yeah, the same method should work on plains at least, it might need some tweaks to suit the lack of normals, like taking all the normals from the normal map and ignoring the plains normals. I'll see what it does with some flat sprite plains.

I tested the 3 light shader with a standard plain and it works fine, normals seem to calculate fine, but I haven't allowed for alpha transparency in the shader yet. I think it would work really well for the right game, something spooky maybe. I'll see what I can come up with, maybe use standard sprites for collision and movement etc, then mimic them with shaded plains, that could be interesting. Although adding lights can be a pain, it is doable - they are all handled through passed variables like this:

if l=0 then SetShaderConstantByName( Shader_Point, "PLightPos", lx#,ly#,lz#, 1.0 )
if l=1 then SetShaderConstantByName( Shader_Point, "PLightPos2", lx#,ly#,lz#, 1.0 )
if l=2 then SetShaderConstantByName( Shader_Point, "PLightPos3", lx#,ly#,lz#, 1.0 )

Obviously some optimasations could be made with the AppGameKit code, but the shader would probably need different versions for different light counts.

When I get round to getting v2, hopefully I'll be able to make a sprite shader with the same techniques.

I am the one who knocks...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 8th Nov 2014 23:53 Edited at: 8th Nov 2014 23:55
Now this I like



Still some work to do, but I think it has potential.

I am the one who knocks...

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Nov 2014 00:22
Ohh, also I have this cheeky little idea to combat the issue of using tile sheets... I mean with plain objects you'd have to really use individual images, because there's no direct way to change the UV coords. But, by specifying which tile to use through the shader would mean the UV coords could be adjusted on the fly. But the only way I can think of to 'transmit' the tile info, is through the objects diffuse colour, so that means the object can't have its colour specified, because it would be used to set the tile XY and size for the plain.

I have an animated sprite with normal map I'm gonna experiment with next.

I am the one who knocks...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Nov 2014 00:39
Here's a little demo, move the mouse to control the yellow light.

I am the one who knocks...

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Nov 2014 13:22
Tile sheets are now supported

I use the object colour to specify the UV offset, so like RGB(128,128,128) would make it use the bottom right corner of a 2x2 tile map, as the red and green components offset on X and Y, and the blue component sets the scale.

Should be much more useful now that animating sprites doesn't have to involve changing textures, which is always slow.

I do have to figure out the rotation on planes though, the light sources all work fine, but the rotation isn't accounted for in the normal calculation.

I am the one who knocks...
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 9th Nov 2014 20:38 Edited at: 9th Nov 2014 20:53
Hi

Thank you, it's very interesting.
Do you think it's possible to do a 2D iso scene with this lighting ?
For example, like that :


My test (I'm not convinced for the moment by my test) :


I would like the same sort of lighting on the ground (like on the first image), and a sort of fall-off for the light, but I don't know how to do that.

EDIT :
The light seems to be a sort of spot, is there a way to have a sort omni-directionnal light ?

http://www.dracaena-studio.com
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 9th Nov 2014 20:48 Edited at: 9th Nov 2014 21:18
Hey,

I modified your version a bit u had some unnecessary equations and I think I fixed your "rotation" problem.
You can use your old Vertex shader..

PixelShader:




As i mentioned somewhere else we could make it for sprites maybe..
by cloning the sprite and set it up for the shader wich only darken some pixels over the source sprite..

I love it.. when i see what is possible with AGK..
And I see that it is capable of doing all these nice things the other big engines can do too.

Attachments

Login to view attachments
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 9th Nov 2014 21:22 Edited at: 9th Nov 2014 21:39
@Janbo : great, thanks, it works fine !
Do you know a way to have a sort of "fall-off" (distance when the light doesn't lighting the rock for example) for the light ? (not lighting all the scene)

EDIT :
My actual test for 2D iso lighting


I'm trying to have this result (photoshop modification), but I don't know how to change the distance of "fall-off" for the light :


http://www.dracaena-studio.com
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 9th Nov 2014 21:34
Thanks Janbo - I'm a strict noob at this shader stuff.


Blendman, it would maybe be easiest to just have an ambient light setting, I will look into it.

I am the one who knocks...
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Nov 2014 01:39 Edited at: 10th Nov 2014 16:41
@Van B: I'm not better than you I ..tryed that before ^^ and had a problem wich I found solved in your code ..now i solved our problem so we're even

@Blendman: I hacked a new version ..Play a bit with the Falloff vector i don't know good settings..

PixelShader:


It does have AmbientColor too but I better rewrite some parts and make a working demo so everybody can access it easy.
And I really want it for REAL sprites.. any advice on that ..somebody?

[Edit]
Attached is a new demo

I have a new Idea to make sprite normalmapping possible without an sprite image index..
we could make an fullscreen shader(using the quadobject) and render sprites with the normalmapping image into the image for the fullscreen shader(using render to image) wich then just darken the pixels for every sprite(having an equivalent as normal image) on the screen. (That would require AGKv2 ofc)
[/Edit]

Attachments

Login to view attachments
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 11th Nov 2014 10:30
Yay for normal mapping!!
This looks great

Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 11th Nov 2014 14:05
Hi

Thank for the ambient light, it's great, and thanks for the new demo.

I have tried this technic on my samsung galaxy note10.1, and the fps is 40 with the shaders and 4 objects.
Have you test this demo/code on your tablet/smartphone ?
How is the fps for you ?

http://www.dracaena-studio.com
janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 11th Nov 2014 21:21 Edited at: 11th Nov 2014 21:48
@Blendman: With the demo I posted above ,I got 7.5k fps on my PC,
60fps on my smartphone and all 60fps on my tablet..but Im sure my devices forces a 60fps limit.
Phone: Mobistel Cynus E1
Tablet: Lifetab E10310

I created 5 objects and still no changes to the fps on both devices.

@Van B: Sorry for hijacking your thread

Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Nov 2014 22:43
Not at all Janbo - this is exactly what I hoped would happen with this, something for us to discuss and improve

Plus, I'm out of office so I can't work on anything right now, it's great to see peoples results though - so please guys, see this as a general thread for discussing any methods, issues or results with normal mapping.

I am the one who knocks...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 14th Nov 2014 09:59
Van B, check out SetSpriteAdditionalImage() in AppGameKit V2 Alpha 9
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Dec 2014 01:10
I seam to not have answered before van
Its a bit messed up here with a heavy load of work and my little 3d printer side project
We nead to go thru our game at the end of the year when we have more time and port it completely to agk2 and all its improvements

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Dec 2014 12:53
Actually Cliff, could you send me your latest version?

I have some new heroes and weapon stuff to add, plus I'm intrigued to see how AGKv2 takes to it. The last time I played it was a couple of days ago... and I got annihilated by robots - so we will probably have to do some work on difficulty progression too... I was playing as the drunk armed with just a switchblade, so maybe that's to be expected.
Anyway, if you send me the latest version I'll get all the new stuff added, then see how it translates to v2.

I am the one who knocks...
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 1st Dec 2014 13:28
Baxslash - I really like the sprite shader stuff in AGKv2, currently trying to get a nice gem shader, with refraction, density, diffuse and normals all coming from the same image. If I can get it working how I imagine it, it'll be damn pretty - it'll make Candy Crush sweets look like turds
Currently trying to get a backdrop image passed through a special refraction normal map (using offset texture coords) - slow going but I'm sure I'll get there somehow.

I am the one who knocks...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Dec 2014 16:13
I like the sound of that shader! I'm not terribly hot on shaders but let me know if I can help

Login to post a reply

Server time is: 2024-11-21 22:50:09
Your offset time is: 2024-11-21 22:50:09