Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Flashlight Example; need one
Topic Started: Jun 17 2013, 01:55 AM (1,649 Views)
Monty
Member Avatar
Forum Leader
[ *  *  *  *  * ]
We are both saying correct things but different things.

You are multiplying (and overlaying) two arbitrary colors. In this case, it's true that you get different results. I am simply taking an arbitrary color and scaling the R,G,B values by a certain scalar value. Using the overlay method, only grayscale lighting is therefore achievable.

The image of a scene can be multiplied by a single-colored bitmap full of (0.5, 0.5, 0.5, 1) pixels to make it half as dark right?
Math: (a,b,c,1)*(0.5, 0.5, 0.5, 1)=(0.5a, 0.5b, 0.5c, 1)

However, it can also be overlaid with a completely black, image with an alpha of 0.5.
(a,b,c,1) overlaid with (0,0,0,0.5): Math: 0.5(0-a,0-b,0-c)+(a,b,c) = (-0.5a,-0.5b,-0.5c)+(a,b,c) = (0.5a,0.5b,0.5c), which is the exact same color result with the alpha still 1. Swap 0.5 for 0.75 or 0.25 and it still works, although (the gray color you would multiply by) = 1 - (the alpha of the overlay)

(a,b,c,1) is the arbitrary screen pixel of the game, and (0,0,0,0.5) is a sample pixel from the light overlay. It could also be (0,0,0,0.25) for example, or (0,0,0,0.6), depending on the part of the overlay texture.

Your overlay in the images looks like the clear pixels are (1,1,1,0), the pixels in between are (0.5,0.5,0.5,0.5), and only the black pixels are (0,0,0,1). That's not what we want.
We want the clear pixels to be (0,0,0,0), the pixels in between to be (0,0,0,0.5), and the black pixels (0,0,0,1)
Edited by Monty, Jun 19 2013, 12:52 AM.
Offline Profile Quote Post Goto Top
 
Gandalf20000
Member Avatar
Geek
[ *  *  *  *  *  * ]
And my point is this: I don't think you'll want that effect. It would, quite frankly, look terrible.
Offline Profile Quote Post Goto Top
 
alexmach1
Member Avatar
Graphics addict
[ *  *  *  *  *  * ]
In halo 1, cubemaps were used to simulate real-time lights, such as 343 guilty spark; the cube was rotated with the model and applied to the level geometry's normals in an additive layer to give him a glowing effect, most noticeable near walls. would that kind of method work in U3D? it may solve the flashlight issue.
Offline Profile Quote Post Goto Top
 
Monty
Member Avatar
Forum Leader
[ *  *  *  *  * ]
alexmach1
Jun 18 2013, 09:53 PM
In halo 1, cubemaps were used to simulate real-time lights, such as 343 guilty spark; the cube was rotated with the model and applied to the level geometry's normals in an additive layer to give him a glowing effect, most noticeable near walls. would that kind of method work in U3D? it may solve the flashlight issue.
Is it called precomputed radiance transfer?

If so then no.
Edited by Monty, Jun 19 2013, 03:36 AM.
Offline Profile Quote Post Goto Top
 
ScottyAnimation
Member Avatar
Advanced Member
[ *  *  * ]
@Monty, thanks for the idea of "lagging" the flashlight, that's going in my next game update. As for me and lights.... Using a real light in 3D looks good but then, "Aw man, that needs to cast shadows!" but casting shadows is super expensive. If speed is an issue, the "flashlight" texture idea works pretty good and just have "baked" textures on your models. No real-time lights + no real_time shadows = no real-time speed issues.
Don't get upset, it's just zeros and ones. -Scotty
Offline Profile Quote Post Goto Top
 
Animaster78900
Member Avatar
Forum Reaper(Highest Ranked)
[ *  *  *  *  *  * ]
I believe I made a Flashlight Tutorial probably 2 or 3 years ago. Donno where it is, shall look for it later.
Posted Image
Current Projects: Hack Attack, Red Lion, X-Falcon: Redux
Offline Profile Quote Post Goto Top
 
Monty
Member Avatar
Forum Leader
[ *  *  *  *  * ]
ScottyAnimation
Jun 30 2013, 11:43 AM
@Monty, thanks for the idea of "lagging" the flashlight, that's going in my next game update. As for me and lights.... Using a real light in 3D looks good but then, "Aw man, that needs to cast shadows!" but casting shadows is super expensive. If speed is an issue, the "flashlight" texture idea works pretty good and just have "baked" textures on your models. No real-time lights + no real_time shadows = no real-time speed issues.
When you say "baked" do you mean that the shadows are baked onto the texture? That is what most people usually mean by that.

You can't really do that though because I assume your flashlight source is moving around, and therefore the shadows cast by it will move around too. Therefore if you want real shadows, they must be dynamic, and cast from a real light. This may be confusing, because it would seem that the overlay texture is taking the place of your real light, but actually you need both a real light and a fake-overlay-texture light to achieve the right effect.

If it were me doing it, I would set up the overlay texture light like you probably have it, and THEN create a directional light that always points the way the camera is facing (or maybe off by a couple of degrees so that you can see the shadows and so it appears the light sources is the player's hand not their face). That way you will have a nicely lighted scene that appears to be lighted per-pixel with a flashlight.
Offline Profile Quote Post Goto Top
 
ScottyAnimation
Member Avatar
Advanced Member
[ *  *  * ]
Monty
Jul 13 2013, 04:26 AM
ScottyAnimation
Jun 30 2013, 11:43 AM
@Monty, thanks for the idea of "lagging" the flashlight, that's going in my next game update. As for me and lights.... Using a real light in 3D looks good but then, "Aw man, that needs to cast shadows!" but casting shadows is super expensive. If speed is an issue, the "flashlight" texture idea works pretty good and just have "baked" textures on your models. No real-time lights + no real_time shadows = no real-time speed issues.
When you say "baked" do you mean that the shadows are baked onto the texture? That is what most people usually mean by that.

You can't really do that though because I assume your flashlight source is moving around, and therefore the shadows cast by it will move around too. Therefore if you want real shadows, they must be dynamic, and cast from a real light. This may be confusing, because it would seem that the overlay texture is taking the place of your real light, but actually you need both a real light and a fake-overlay-texture light to achieve the right effect.

If it were me doing it, I would set up the overlay texture light like you probably have it, and THEN create a directional light that always points the way the camera is facing (or maybe off by a couple of degrees so that you can see the shadows and so it appears the light sources is the player's hand not their face). That way you will have a nicely lighted scene that appears to be lighted per-pixel with a flashlight.
You made some good points I didn't think about it, I will give them consideration. Thanks!
Don't get upset, it's just zeros and ones. -Scotty
Offline Profile Quote Post Goto Top
 
« Previous Topic · Tutorials and examples · Next Topic »
Add Reply