Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  2D Lighting System  (Read 10583 times)
0 Members and 1 Guest are viewing this topic.
Offline mike_bike_kite
« Reply #30 - Posted 2012-07-08 11:18:13 »

while I'm willing to explain my techniques, I'm keeping my code proprietary at the moment.
This is obviously entirely your choice and the code is yours to do with how you want. It's a shame though, it would be nice to have the option to use a simple shading system.

Arcade swarm
Board Chess - Checkers - Othello
Offline CodeBunny
« Reply #31 - Posted 2012-07-08 14:15:47 »

I understand, and as I previously stated, I'm going to make it an open-source plugin for jRabbit v2.0. It'll just take a while.
Offline CodeBunny
« Reply #32 - Posted 2012-07-09 00:15:05 »

The second part of the tutorial is up. This video explains how to create cast shadows.

<a href="http://www.youtube.com/v/4BtjcH-iLR0?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/4BtjcH-iLR0?version=3&amp;hl=en_US&amp;start=</a>

What do you guys think?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #33 - Posted 2012-07-09 01:22:22 »

Nice breakdown, and I'm sure it will help some people who have no idea what a lighting system consists of, but it doesn't go into any detail on the polygon clipping algorithm (which is the heart of your system). Clearly you are trying to help people... Why not provide source code or a detailed explanation of the algorithm? Otherwise I don't really see the point of your videos.

I like your system, though. Mind you: there's no need to bind/sample a texture. The radial fade out and colouring can be done in a shader, probably more efficiently.

For soft shadows, you could apply a full-screen blur shader to all of your shadow maps at once. Depending on your scenario, it may be much faster than blurring each shadow map individually. For added effect, you could increase the blur size based on the distance from the light center. The result will look very good, probably identical to my own lighting tests, the only difference is that yours requires much less overdraw. Smiley

Offline CodeBunny
« Reply #34 - Posted 2012-07-09 02:14:26 »

I'm glad you liked the overview.

I've already talked about the source code issue - I even explain why in the video. I really do understand why you want it, but I've decided to not release it. That said, polygon clipping isn't that hard, and people should be able to get something together if they can get everything else working.

I think binding a texture is faster than computing the lighting fade-off in a shader (texture lookup vs. distance calculation), but if there's any difference, it's so negligible as to not be an issue. Additionally, I don't think you're realizing the advantages of using a texture - I can have masked lights! I could make lights out of any of these:
So yes, potentially it's useful. It allows me to customize my lights individually without needing to utilize any uniforms.

The blur shader was to be applied after the final lighting mask was calculated (not each light as it was rendered), so yes, you're correct. Render all of the lights normally, and then do a blur pass.

Eh, I'm not a per-pixel lighting kind of guy. I figure that super-fast and good is preferable to slow but perfect.
Offline davedes
« Reply #35 - Posted 2012-07-09 03:53:22 »

Regarding closed source, it's your call. I just don't really see how helpful it is to write a tutorial and leave out the most important part -- i.e. the actual implementation. It's like writing a cooking book where you don't include any recipes, but instead just show how good all the food looks when it's done. Smiley

Quote
I think binding a texture is faster than computing the lighting fade-off in a shader (texture lookup vs. distance calculation)
In my experience, texture fetching is pretty expensive. Simple arithmetic like this would lead to better performance, and has the same result as using a radial gradient texture. Another minor bonus is that it doesn't require an extra glBindTexture per frame.
1  
2  
   float dist = length(gl_TexCoord[0].st - 0.5) * 2.0;
   gl_FragColor = vec4(color.r, color.g, color.b, 1.0 - dist);


Of course, it's all relevant -- you probably won't even notice a difference unless you are rendering many lights. Smiley

Offline sproingie

JGO Kernel


Medals: 202



« Reply #36 - Posted 2012-07-09 05:29:39 »

He's made good on releasing source before, so if he wants to make it part of his engine before releasing anything, I might not agree with it 100% but that is his call.
Pages: 1 [2]
  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.

TehJavaDev (38 views)
2014-10-27 03:28:38

TehJavaDev (29 views)
2014-10-27 03:27:51

DarkCart (43 views)
2014-10-26 19:37:11

Luminem (24 views)
2014-10-26 10:17:50

Luminem (29 views)
2014-10-26 10:14:04

theagentd (35 views)
2014-10-25 15:46:29

Longarmx (63 views)
2014-10-17 03:59:02

Norakomi (61 views)
2014-10-16 15:22:06

Norakomi (50 views)
2014-10-16 15:20:20

lcass (46 views)
2014-10-15 16:18:58
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!