Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (739)
Games in Android Showcase (224)
games submitted by our members
Games in WIP (820)
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 1682 times)
0 Members and 1 Guest are viewing this topic.
Offline InfiniteCoder

Senior Newbie

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

I was watching 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, 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: 138
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 Devvie

« 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 Devvie

« 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 Opiop
« 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 Devvie

« 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.

Ecumene (48 views)
2017-09-30 02:57:34

theagentd (72 views)
2017-09-26 18:23:31

cybrmynd (182 views)
2017-08-02 12:28:51

cybrmynd (180 views)
2017-08-02 12:19:43

cybrmynd (187 views)
2017-08-02 12:18:09

Sralse (194 views)
2017-07-25 17:13:48

Archive (744 views)
2017-04-27 17:45:51

buddyBro (877 views)
2017-04-05 03:38:00

CopyableCougar4 (1424 views)
2017-03-24 15:39:42

theagentd (1316 views)
2017-03-24 15:32:08
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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!