Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (524)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [Slick2D] Slick2D AlphaMap, what i do wrong?  (Read 1732 times)
0 Members and 1 Guest are viewing this topic.
Offline marcuiulian13

Senior Devvie


Medals: 5
Exp: 3 years



« Posted 2012-06-25 09:24:20 »

Hello everyone. I can't manage to make the alpha map to render correctly.

Here is what i have:


In the SpriteSheet, the sprites background is transparent and for tiles the same.

Here is my render code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      g.resetTransform();
     
      g.clearAlphaMap();
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
     
      g.setDrawMode(Graphics.MODE_ALPHA_MAP);
      Image alphaMap = ImageLoader.getAlphaMap();
     
      alphaMap.drawCentered(Display.getWidth()/2, Display.getHeight()/2);
         
      GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
      g.setDrawMode(Graphics.MODE_ALPHA_BLEND);

      g.translate(xOffset, yOffset);
     
      //RENDERING EVERITHING

Getting a project done is by far the most hard thing in game development.
Offline davedes
« Reply #1 - Posted 2012-06-25 11:07:39 »

This is a limitation of the technique -- because your sprite has alpha it interferes with the alpha map you're trying to create.

Anybody know a way to work around this with clever blending or some stencil buffer usage..? I haven't looked too much into the problem; sadly this makes the technique not all that practical for lighting.

EDIT: One solution I proposed to this in this tutorial is to "bake" your game to a texture. i.e. Your whole game is rendered as per usual, however it's rendered to an Image rather than to the screen. Then, once your game is rendered, you apply the lighting effect to the image, i.e. as a "post-process," and render the processed image to the screen.

Online theagentd

« JGO Bitwise Duke »


Medals: 361
Projects: 2
Exp: 8 years



« Reply #2 - Posted 2012-06-25 12:07:45 »

This is a limitation of the technique -- because your sprite has alpha it interferes with the alpha map you're trying to create.

Anybody know a way to work around this with clever blending or some stencil buffer usage..? I haven't looked too much into the problem; sadly this makes the technique not all that practical for lighting.

EDIT: One solution I proposed to this in this tutorial is to "bake" your game to a texture. i.e. Your whole game is rendered as per usual, however it's rendered to an Image rather than to the screen. Then, once your game is rendered, you apply the lighting effect to the image, i.e. as a "post-process," and render the processed image to the screen.

Or you can flip it around, and render the game to the screen, then render and accumulate lights to an image and then just draw the light map over the screen.

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline marcuiulian13

Senior Devvie


Medals: 5
Exp: 3 years



« Reply #3 - Posted 2012-06-25 17:44:51 »

Or you can flip it around, and render the game to the screen, then render and accumulate lights to an image and then just draw the light map over the screen.

Oh my.. This is the best idea, and the simplest. I can't belive i didn't think to this. I should simply make an image where i should place the "lights" and then i should only render it over everything.

Thanks to everyone.  Grin

Getting a project done is by far the most hard thing in game development.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (16 views)
2014-11-26 15:22:04

toopeicgaming1999 (15 views)
2014-11-26 15:20:36

toopeicgaming1999 (7 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (24 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!