Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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 12: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 07: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 01: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.



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 14: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]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!