Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (808)
Games in Android Showcase (239)
games submitted by our members
Games in WIP (872)
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 38612 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

Senior Devvie

Medals: 4
Projects: 3

« 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

Senior Devvie

Medals: 4
Projects: 3

« 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=";hl=en_US&amp;start=" target="_blank">;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

Senior Devvie

Medals: 4
Projects: 3

« 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

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

Riven (848 views)
2019-09-04 15:33:17

hadezbladez (5799 views)
2018-11-16 13:46:03

hadezbladez (2605 views)
2018-11-16 13:41:33

hadezbladez (6215 views)
2018-11-16 13:35:35

hadezbladez (1501 views)
2018-11-16 13:32:03

EgonOlsen (4736 views)
2018-06-10 19:43:48

EgonOlsen (5794 views)
2018-06-10 19:43:44

EgonOlsen (3278 views)
2018-06-10 19:43:20

DesertCoockie (4176 views)
2018-05-13 18:23:11

nelsongames (5503 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 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!