Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (546)
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  
  [Help] 2D Shadows/Image Modes  (Read 706 times)
0 Members and 1 Guest are viewing this topic.
Offline InfiniteCoder

Senior Newbie





« Posted 2013-05-21 22:51:20 »

I was watching https://www.youtube.com/watch?v=4BtjcH-iLR0 and he was explaining how a 2d shadow system would work.
I made a little image using minecraft textures in gimp and used the image mode 'Multiply' on it.
-=Without Light=-


-=With Light=-


-=Remember=-
Remember, these are just images, not the real game.

-=Need Help With=-
  • Texturing a light
  • Using the image mode 'multiply' to draw it

If you can help, that'd be great!
Offline davedes
« Reply #1 - Posted 2013-05-21 22:56:18 »

If you are using LibGDX there is Box2DLights which will make your life easier. If you are using LWJGL then you have to learn about glBlendFunc to achieve the lighting in your screenshots; or shaders. And it won't be "dynamic" in the sense that objects won't affect the light -- for that you need to use meshes or shaders.

Offline InfiniteCoder

Senior Newbie





« Reply #2 - Posted 2013-05-21 22:57:57 »

I am using LWJGL, and am pretty new to it, so I'll learn some stuff. It also wont be dynamic. It will be a game which revolves underground with wall torches as light.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline alaslipknot
« Reply #3 - Posted 2013-05-22 18:51:36 »

i don't know if this is the good way to do it, but i did this effect once in a flash game, i made it like this :
-layer 1 = game (your 1st picture)
-layer 2  = a whole black square that cover the game with alpha value lower than 100%
-"layer" 3  =  i said "layer" cause this one is related to the 2nd layer, it's a mask form that "delete" a certain area of the 2nd layer, so like that you'll have a light effect.
now i hope LWJGL expert will help you to realize these steps or give you a magic method to do it  Roll Eyes

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #4 - Posted 2013-05-22 19:31:35 »

You could render light images in a FBO in one pass, and in the second pass, simply use a shader which computes the screen position and fetches the color from the light FBO and multiplies it by the color of the to-render-pixel.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline _Scyth_

Junior Member





« Reply #5 - Posted 2013-05-27 11:19:56 »

Any one know how to do this in Java2D
Offline Longarmx
« Reply #6 - Posted 2013-05-27 11:58:23 »

Any one know how to do this in Java2D

Sure, you could cycle through all of the light sources close enough to a certain pixel. Then, you could find an average value of the distances and multiply that by a light intensity constant. Then, repeat, for all of the pixels within a light source's radius.

Offline _Scyth_

Junior Member





« Reply #7 - Posted 2013-05-27 12:06:34 »

Does that mean that I will need to access all the pixels of the textures used to make up the game?
Offline opiop65

JGO Kernel


Medals: 154
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2013-05-27 12:09:25 »

Does that mean that I will need to access all the pixels of the textures used to make up the game?
No, the textures have nothing to do with the lighting. What you need to do is blend the textures, and a "second" layer of pixels together. You change the color of the pixels and then blend them together with the texture. You should not change the RGB of the texture itself. I have no idea how to do blending in J2D though.

Offline _Scyth_

Junior Member





« Reply #9 - Posted 2013-05-27 12:16:25 »

Opiop, I understand what your saying, basically its like like having a black overlay, and then using longarmx's formula to calculate the "transparency" of the pixels depending on how far away from the light source the pixels are, which means I'm going to need to work out radii of the circle of range for each light source.

Would the same go for depth fog? Like the further down you go, the darker it gets?
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.

atombrot (20 views)
2014-08-19 09:29:53

Tekkerue (21 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (55 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (27 views)
2014-08-08 02:01:56

Norakomi (35 views)
2014-08-06 19:49:38

BurntPizza (64 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!