Author Topic: multiple lights  (Read 3794 times)

Offline kupiecu

  • byte
  • *
  • Posts: 9
    • View Profile
multiple lights
« on: December 08, 2013, 12:24:24 am »
Hello.  :)
I found for solution of my problem but I don't know still. Is it possible samething like "multiple lights" in jpct-ae?
ex:
http://commons.wikimedia.org/wiki/File:Subway_lights_in_tunnel.JPG
or
http://www.creativecrash.com/system/photos/000/174/605/174605/big/Guest_room_001_1.jpg?
I was add two light to world, but I see only one. .

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: multiple lights
« Reply #1 on: December 08, 2013, 07:23:51 am »
   Yes, you can do that! Possible solutions are-->
1 .You can use your own lighting shaders.
2 . If Your scene is static and does not need dynamic lighting , you can use easy tricks so that you can fake the lighting effects by using lightmaps. This uses multi-texturing approach. Check this for reference - http://www.jpct.net/forum2/index.php/topic,3451.msg24809.html#msg24809 
3.  You can consider to bake your lightmap and colors to a single texture image. This is quite easy and my preferred way too . You can easily obtain these textures from blender .There are plenty of tutorials for the same.
for example-
This is the texture with lighting patterns and colors-

And this the .3ds model on which above texture is applied ,ready to load in jpct-ae -
« Last Edit: December 08, 2013, 08:33:00 am by Wolf17 »

Offline kupiecu

  • byte
  • *
  • Posts: 9
    • View Profile
Re: multiple lights
« Reply #2 on: December 08, 2013, 12:05:43 pm »
I write what i want. I have a "room" model, which i load to world. I move a camera, and object isn't move. And i want add to room 2 light (ex. one on ceiling, and other to wall). I want 4 options dor this. No lights, 1 lights on, 2 lights on, and 1 and 2 lights on together. So if I think about 2, 3 your proposytion I must have 4 lights map? And where I found samething about writing shader (hmm in open gl? ) and how merge open gl with jpct.
Thanks for your post, but I'm begginer , and I still have no idea.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: multiple lights
« Reply #3 on: December 08, 2013, 12:09:06 pm »
I'm not 100% sure what your actual problem is. You can add multiple lights and they will all have an effect on your scene...but maybe not in the way you expect them to have. Maybe two screen shots for comparison might help...

Offline kupiecu

  • byte
  • *
  • Posts: 9
    • View Profile
Re: multiple lights
« Reply #4 on: December 08, 2013, 12:21:47 pm »
I'm surprised. I think that I do not have big demands, so probably something I'm doing wrong. I have to go, but when I get home that I edit this post, I'll post my code and screens. :)

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: multiple lights
« Reply #5 on: December 08, 2013, 12:36:54 pm »
  I see. Yes, as stated in earlier post , It only works for static scenes with no changes in lighting . That is the drawback of the methods 2 and 3 which  I suggested . JPCT AE comes with point light ,ambient light support out of the box . But for stuffs like shadows ,spotlights ,area light etc.. you would have to write shaders . I saw some users doing this in their work . If you are willing to learn writing shaders , then there are plenty of tutorials for opengl es 2.0 scattered on the web .
Writing shaders are hard if you are a complete beginner(and may be that applies to you!) and you may even find it difficult for testing and make it work on various devices ! So maybe you should stay away from it (Even I do not know that stuff and I stay away from that dimension ! :P )! 
I suggest you to experiment a little with the default stuffs .
For now ,I can suggest you to try scaling your room model and 3d objects larger and see if there is some difference .
« Last Edit: December 08, 2013, 12:59:03 pm by Wolf17 »

Offline kupiecu

  • byte
  • *
  • Posts: 9
    • View Profile
Re: multiple lights
« Reply #6 on: December 08, 2013, 10:42:20 pm »
Ok, it's mayby a other kind of subject, but I'm writing my actual problem.

I built a model of the box, with 6 "walls". This box is empty inside. Im not translate box, and light, so light is inside the box. And the 5 walls is light, but  one of 6 ("ceiling") is completely dark. I tried set a position of light but it's still dark.

It's my light and camera code:
Code: [Select]
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
cam.lookAt(model.getTransformedCenter()); //w srodku - model, obok - pokoj

SimpleVector sv = new SimpleVector();
sv.set(pokojs.getTransformedCenter());
sv.y = 0;
sv.z = 0;
sv.x = 0;
sun.setPosition(sv);

pokojs = "box"
model = only the horizontal walls, no ceiling and floor

and the screen shot:



Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: multiple lights
« Reply #7 on: December 09, 2013, 08:08:07 am »
Make sure that the light is really inside(!) the box. Faces that point away from the light won't be lit and so won't be back faces (with culling disabled).

Offline kupiecu

  • byte
  • *
  • Posts: 9
    • View Profile
Re: multiple lights
« Reply #8 on: December 09, 2013, 08:29:00 pm »
So, can I found where is my light source?. I have setposition and getposition method for light. Can I example getposition of light and set this position for object3d, ex cube - samething like marker? But How I can getposition of any object? getTranslation? .. When I add light source and not specify the position, it's in (0 0 0) ?

And other question. I lighting my scene but I haven't shadow. I found "setShadingMode" but I have no idea about this.

Sorry for my very begginer question, and Thanks very much. :)
« Last Edit: December 09, 2013, 08:32:57 pm by kupiecu »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: multiple lights
« Reply #9 on: December 09, 2013, 09:56:55 pm »
If you don't move the light, it's at (0,0,0). The object's "position" can be obtained by either getTranslation() or (maybe better in this case) by getTransformedCenter().

What exactly do you mean by "shadow"? Just darker regions on an object or "real" shadows casted by objects?

Offline Wolf17

  • int
  • **
  • Posts: 77
    • View Profile
Re: multiple lights
« Reply #10 on: December 10, 2013, 05:25:18 am »
The "setshadingmode " is used for setting the shading mode (flat or gourad shading) .It has nothing to do with shadow casting.
If your scene is extremely small (like confined to a room only) then maybe you should use the multitexturing approach with different lightmpas per same model  and switch them according to the lighting you want(I know that it is a quick dirty solution ,but there is nothing bad in giving it a try!).This will actually make sure that your scenes are visually apealing(FOR STATIC SCENES ONLY!) !
Just make sure that your lightmaps are reasonably sized(or it will cause memory problems)!
The "virtualizer" will come handy to save you from memory problems. ;)
« Last Edit: December 10, 2013, 08:18:37 am by Wolf17 »