Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (702)
Games in Android Showcase (203)
games submitted by our members
Games in WIP (775)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Shared Code / Re: 2D normal maps on: 2013-11-03 11:24:55
Danny02: Wouldn't four normalize calls do more performance damage than a matrix multiply though? Admittedly, the solution I proposed isn't as versatile when it comes to deformation and the like. Also admittedly, I don't really know what I'm talking about when it comes to shader optimisation so maybe I should just be quiet. Smiley

Nate: I think cylab is describing just taking the light's position and getting it in tangent space, rather than getting the normals and putting them in world space. I think that solution should work, and it might maybe even play nice with soft skinning...? But yeah I don't think the images would need to be changed for that, so it shouldn't mess up batching.

This conversation has also made me realise that an atlas tool that handles normal maps without knowing that that's what it's doing might screw things up (by rotating them). I have to give this some thought, because it sounds like something Sprite Lamp ought to deal with intelligently.
2  Game Development / Shared Code / Re: 2D normal maps on: 2013-11-03 06:40:51
Danny02 speaks the truth, unfortunately. If Spineboy was rotated 180 degrees, the unrotated normals would make his head look concave, for instance. It'd get weird.

Fortunately, the maths for this is pretty well-trodden ground, because it's a requirement of doing normal mapping in 3D applications (or even just vertex lighting, from back in the day). The long and the short of it is, you have to multiply the normals by the inverse of the transpose of the model view matrix, and then everything works out okay. Smiley You do this after extracting the normal value from the texture, so you can avoid any texture-dependent lookup shenanigans - the only price to pay is a vertex-matrix multiplication in the pixel shader. I think this is possible even on phone GPUs these days, although perhaps just barely, especially with pixel density being what it is these days.

Things do get a bit hairier if you want to deal with stuff like soft skinning or other per-vertex deformation - basically, all the stuff they're going to add to Spine after this next Kickstarter. Smiley

Also, thanks! I'm glad you like the preview. I totally agree about the diffuse map - having it be separate from the normal map allows really easy recolouring of characters and the like, like a super powerful palette swap.

 ~ Finn
3  Game Development / Shared Code / Re: 2D normal maps on: 2013-11-02 00:59:35
So, turns out it's difficult to do artwork for a tool without being familiar with the tool. Smiley We're gradually improving the normal maps at our end and sending them through to Nate but there are still some issues - for instance, we didn't realise that the 'eyes open' and 'eyes closed' frames needed to be done separately, so in the runnable JAR that's up there now, the area around Spineboy's eyes are weird and flat.

matheus23: Since you asked what it would look like with a less rough normal map, I've taken the liberty of assembling the normal/diffuse maps we do have into a neutral pose and exporting a lighting preview via Sprite Lamp. This includes a few fancy shader effects, but nothing that would make it incompatible with Spine animation. Smiley Unfortunately, right at the moment I don't have the time to fully implement these effects with Spine's runtimes, but I'm starting to think it would make a cool stretch goal for my kickstarter.

Click to Play

davedes: Sprite Lamp is definitely more like the first thing you mentioned - the whole reason for its existence is to make dynamic lighting possible while preserving styles unique to 2D art, such as visible brushstrokes or pixel art. In other words, it's a way of creating normal maps in specific styles that are hard to do with 3D modelling. Of course, a rendering implementation involving normal maps doesn't care about such things - it doesn't matter whether the normal maps come from Sprite Lamp, a depth map, a mesh, or anything else you can think of. One of the key design decisions with Sprite Lamp was that it was for processing images, and how you create those images is up to you - I figured artists are so used to using Photoshop or ArtRage or whatever that trying to make an interface for them to paint in that won't be frustratingly limited would be out of my scope. Smiley

Also, am I right in thinking you're the one I should thank for implementing normal mapping in the Spine runtime? If so, thanks! I have a feeling at some point I'll be working with that code. I'm wondering, do you have any thoughts on what I mentioned up thread, regarding correct rotation of normal maps? Having looked at the JAR posted here, I strongly suspect that that problem is present (that is, the normals aren't being correctly rotated with the underlying geometry). The best way to see the issue is to position the light about here:

See how given the position of the light source (that white dot I drew in), Spineboy's right forearm ought to be underlit, but instead the top is lit?

Anyway, I'm just wondering if you think I might be right about that - not asking you to rework the code or anything! If the problem is what I think it is, the solution is likely to be nontrivial anyway - especially once Spine gets soft skinning and freeform deformation added, which will serve to further complicate things. I'm just trying get a feel for what I'm up against if the time comes. Smiley

 ~ Finn
4  Game Development / Shared Code / Re: 2D normal maps on: 2013-10-31 13:27:24
Hey all, Sprite Lamp guy here. Damn cool seeing some normal maps from my software in conjunction with skelmesh animation!

Nate: You are correct, this was processed by Sprite Lamp. I actually think the normals mostly came out okay, except for the head (as matheus23 mentioned), because it has a big old hard edge running right down the side. That should be a pretty easy fix, except that it's the middle of the night here (east coast of Australia) and the artist in question is asleep so the fix will have to wait. Smiley

Also - and I'm coming from a position of some ignorance here, and squinting through tired eyes at foreign code, so I could be wrong - but I suspect there might be a bug in that normal map demo. You can see there's a discontinuity in the lighting at some of the joints, particularly the character's right (camera-facing) elbow. I suspect what's going on is that the normal value is being read directly from the map, but not correctly rotated in the pixel shader. This will result in roughly correct lighting on body parts that are rotated roughly in the same way as they appear in the texture atlas (like the head), but the further from that orientation they deviate, the worse it will get. Normally this is fixed by adding full normal/tangent information to the vertices of a mesh and multiplying by the TNB matrix (I think that's what they call it?). Because in this case we're working in 2D, there might be some clever way to avoid that. Again, this is just my suspicion having looked at the code and the screenshot, but I could be way off base - apologies to the person who wrote the code if I'm full of crap!

Okay, I'm new here so I don't know how fast this forum moves, but in case anyone responds to me - I apologise for not getting back to you in a timely fashion, because for the moment, I have to go and sleep. Smiley

 ~ Finn
Pages: [1]
Lunch (103 views)
2016-12-06 16:01:40

ral0r2 (325 views)
2016-11-23 16:08:26

ClaasJG (458 views)
2016-11-10 17:36:32

CoffeeChemist (545 views)
2016-11-05 00:46:53

jay4842 (594 views)
2016-11-01 19:04:52

theagentd (626 views)
2016-10-24 17:51:53

theagentd (605 views)
2016-10-24 17:50:08

theagentd (541 views)
2016-10-24 17:43:15

CommanderKeith (535 views)
2016-10-22 15:22:05

Roquen (480 views)
2016-10-22 01:57:43
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!