Show Posts
|
|
Pages: [1]
|
|
2
|
Game Development / Newbie & Debugging Questions / Re: [libgdx] Shaders, Light system.
|
on: 2013-02-16 16:05:52
|
Let me show the code, hope you guys can pinpoint what am I doing wrong here. (please help!) Box2dLight used. The Application Listener:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| public void create() { testStage = new BaseStage(800, 480, true); FileHandle backgroundPicture = Gdx.files.internal("assets/sampleBG.png"); texture = new Texture(backgroundPicture); Image img = new Image("bg", texture); img.x = 0; img.y = 0; testStage.addActor(img); } @Override public void render() { GLCommon gl = Gdx.gl; gl.glClearColor(0.0f, 0.0f, 0.0f, 1.0f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); testStage.act(Gdx.graphics.getDeltaTime()); testStage.draw(); } |
The Base Stage:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| public class BaseStage extends Stage implements InputProcessor { RayHandler rayHandler; World world; OrthographicCamera camera; public BaseStage(float width, float height, boolean stretch) { super(width, height, stretch); Gdx.input.setInputProcessor(this); camera = new OrthographicCamera(80, 48); world = new World(new Vector2(0, 0), true); rayHandler = new RayHandler(world); rayHandler.setCulling(true); rayHandler.setCombinedMatrix(camera.combined); rayHandler.useDiffuseLight(true); rayHandler.setAmbientLight(0.2f, 0.2f, 0.2f,1.0f); }
@Override public void draw () { super.draw(); rayHandler.updateAndRender(); } @Override public void dispose() { rayHandler.dispose(); } public Vector2 gdxCoordinateToBox2D(float x, float y) { float K = 10; return new Vector2(x/K-width/(2*K), height/(2*K)-y/K); }
@Override public boolean touchUp(int x, int y, int pointer, int button) { Vector2 coordinate = gdxCoordinateToBox2D(x, y); Color clr3 = new Color(0.5f,0.8f,0.2f, 0.9f); Light pt = new PointLight(rayHandler, 5, clr3, 30, coordinate.x, coordinate.y); pt.setStaticLight(true); return false; } } |
The Problem: So when lights overlap, instead of getting more greener, it kinda cancels itsef and get's to original picture. I guess I am using it wrong, any help will be so much appreciated!
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: [libgdx] Shaders, Light system.
|
on: 2013-02-09 13:48:54
|
|
Oh well, that's great to hear then! we just go ahead and try to use it then! Thanks a lot!
First i read through the code of box2light I was a bit worried that it uses a physics engine to do a calculations, and I thought it might be slow, but yeah if you say it's not then it's great news.
I hope it is possible to use it with Stage class right?
|
|
|
|
|
8
|
Game Development / Newbie & Debugging Questions / Re: [libgdx] Shaders, Light system.
|
on: 2013-02-08 21:30:03
|
|
Wow, thanks! I think I am more interested in the one where it is pseudo dynamic, I am afraid bo2xlight might be using too much resources, so I'll take a look at your example code, looks pretty good so far! This is nor a primarily Android game, it is PC, but with a possibility of future Android port. I will look at the example code more detailed tomorrow, but just to clarify, is this the right method? 1) Draw entire screen to buffer 2) Overlay Light to buffer using shaders 3) Render buffer to actual screen 4) Render elements that are not affected to light on screen.
If so, is there a room for optimization like: 1) render only parts that are expected to be affected by light to buffer so buffer will take less memory? (Does this make sense?) 2) Any caching techniques maybe?
Thanks a lot again!
|
|
|
|
|
10
|
Game Development / Newbie & Debugging Questions / Re: [libgdx] Shaders, Light system.
|
on: 2013-02-08 14:35:31
|
I am not sure about the naming, I am looking for effect that looks like a round circle. (you can see it on a screenshot) Basically it's a simple effect of a gradient fading circle that overlays the scene. It gives the near surroundings a color. It does not have direction or anything. And most importantly it does not need any fancy things like stop on walls or whatever. What I need, looks like this  
|
|
|
|
|
12
|
Game Development / Newbie & Debugging Questions / Re: [libgdx] Shaders, Light system.
|
on: 2013-02-08 13:15:51
|
Thanks a lot guys, I'll read through some links!  But it's worth mentioning that I do not need any complex type of lights like directional ones, just point light that ill illuminate it's surroundings in a round shape. I can basically do this with a small fragment shader code for one texture, but if used on entire screen I guess a Frame Buffer Object needs to be used, and here I am not sure about architecture and best practices.
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / [libgdx] Shaders, Light system.
|
on: 2013-02-08 12:13:53
|
Hi, new here! So me and my friend are working hard on our 2D game engine based on LibGDX, and it can do a lot but there is no support for Lights, So we need to implement a good lighting system, I am relatively new to shaders though, while I've read lot's of cool tutorials on how it's done, the question that is left for me is an architecture of that all. There are tons of tutorials on how to cast a light on one particular texture, but we have an entire scene, build of many many textures. So what is the best way to do that? Render all scene to FBO, then apply light to it? if so, is it optimal to render entire scene to FBO or maybe just parts that potentially will be light up? What are the common practices/mistakes? Basically I am not seeing entire picture of how is this usually done  Anyone did this before? would really appreciate any help or advice, and I can provide a screenshot of a level for example to make it really clear what I need to be done. Thank!
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|