www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: robert on October 11, 2012, 01:20:46 am

Title: Fake volumetric lights
Post by: robert on October 11, 2012, 01:20:46 am
Is this doable in JPCT-AE ?
Title: Re: Fake volumetric lights
Post by: EgonOlsen on October 11, 2012, 07:13:48 am
Depends on what exactly you mean???
Title: Re: Fake volumetric lights
Post by: Thomas. on October 11, 2012, 07:23:20 am
You can do it by transpatent plane  ;)
Title: Re: Fake volumetric lights
Post by: EgonOlsen on October 11, 2012, 07:26:02 am
So...something like this:

(http://www.jpct.net/pix/high_poly_car.jpg)

 ???
Title: Re: Fake volumetric lights
Post by: robert on October 11, 2012, 10:53:33 am
Something more like http://udn.epicgames.com/Three/rsrc/Three/VolumetricLightbeamTutorial/lightbeams.jpg (http://udn.epicgames.com/Three/rsrc/Three/VolumetricLightbeamTutorial/lightbeams.jpg)

The lights on the car look more flat, I would like to use a conse instead of a plane, as explained here: http://udn.epicgames.com/Three/VolumetricLightbeamTutorial.html (http://udn.epicgames.com/Three/VolumetricLightbeamTutorial.html)

But to be honest, I don't even know if that is what I'm really looking for.... I want to achieve something like this:

(http://bargainbabe.com/wp-content/uploads/2009/10/Halloween-pumpkin-carved-classic-happy-face-CC-300x225.jpg)

Title: Re: Fake volumetric lights
Post by: EgonOlsen on October 11, 2012, 11:16:49 am
Something like a...missing image...?
Title: Re: Fake volumetric lights
Post by: K24A3 on October 11, 2012, 11:52:44 am
You could cheat and change the texture of the inside of that pumpkin, make the inside colors pure white so it appears lit up.

Additionally, you could separate the inside and outside of the 3D pumpkin object and setAdditionalLighting(200,200,200) to the inner Object3D. Or perhaps pop a small hardware Light in the center.
Title: Re: Fake volumetric lights
Post by: robert on October 11, 2012, 12:22:47 pm
Something like a...missing image...?

I don't know what happened, the image was shown the first time I put it. Anyway, what I want to achieve is the lighting of the inside of a halloween pumpkin.
Title: Re: Fake volumetric lights
Post by: robert on October 11, 2012, 12:24:53 pm
You could cheat and change the texture of the inside of that pumpkin, make the inside colors pure white so it appears lit up.

Additionally, you could separate the inside and outside of the 3D pumpkin object and setAdditionalLighting(200,200,200) to the inner Object3D. Or perhaps pop a small hardware Light in the center.

I will try your first method, but I'm afraid I'll need two pumpkins because as far as I know, a texture can't be mapped to both sides of a mesh. The downside of this method is that I won't get a "glow" effect.

About the second method... what do you mean a hardware Light ? a light done with fragment shaders ?
Title: Re: Fake volumetric lights
Post by: K24A3 on October 11, 2012, 02:07:25 pm
You wont need two pumpkins, 3D modelling programs like blender allow you to select all the vertices and extend them inwards, effectively creating a complete 3D object with both inner and outer walls. Once that is done, apply a white part of the texture to the inner faces.

OpenGL hardware typically have 8 hardware lights you can use. Refer to the "Light" class in jPCT, set it's position to the center of the pumpkin to light it up. You could use shaders but it can be a steep learning curve if you are just starting to use OpenGL.

...Edit: Well actually yes you could use two pumpkins and invert the faces of the inner one and apply a bright texture to it, but you may run into visible artifacts or 'jaggies' at the edges of the objects if they are too close in 3D space.
Title: Re: Fake volumetric lights
Post by: robert on October 11, 2012, 02:12:04 pm
You wont need two pumpkins, 3D modelling programs like blender allow you to select all the vertices and extend them inwards, effectively creating a complete 3D object with both inner and outer walls. Once that is done, apply a white part of the texture to the inner faces.

OpenGL hardware typically have 8 hardware lights you can use. Refer to the "Light" class in jPCT, set it's position to the center of the pumpkin to light it up.

I have been using Blender for years occassionally, but I'm far from being an expert :) How do you apply a texture to both sides of a mesh using the UV editor ? When you unwrap a mesh it is unwrapped on one side only  ???
Title: Re: Fake volumetric lights
Post by: K24A3 on October 11, 2012, 02:24:53 pm
I must agree it was a battle learning even the basics of Blender.

jPCT doesn't support dual sided polygon textures (which is good in a way, keeps things simple) so you will need to solidify the object as mentioned. Rather than copy the outer texture co-ordinates to the inner faces, you would want to simply apply white to the inside to mimic the light volume. You do this by selecting all the inner faces and either apply a white material from the materials menu on the right, or hop into texture mode, load up your texture, select a portion of the texture that contains white, then wrap that portion to the polygons you have selected. It's not easy to do so I wont go into it in detail, but there are plenty of video guides on youtube that will get you started.
Title: Re: Fake volumetric lights
Post by: robert on October 11, 2012, 02:48:30 pm
I must agree it was a battle learning even the basics of Blender.

jPCT doesn't support dual sided polygon textures (which is good in a way, keeps things simple) so you will need to solidify the object as mentioned. Rather than copy the outer texture co-ordinates to the inner faces, you would want to simply apply white to the inside to mimic the light volume. You do this by selecting all the inner faces and either apply a white material from the materials menu on the right, or hop into texture mode, load up your texture, select a portion of the texture that contains white, then wrap that portion to the polygons you have selected. It's not easy to do so I wont go into it in detail, but there are plenty of video guides on youtube that will get you started.

Thank you.
Title: Re: Fake volumetric lights
Post by: K24A3 on October 11, 2012, 03:20:20 pm
No probs. If you want a glow effect as well you could experiment with a simple transparent plane centered near the front-center of the pumpkin with a 32bit (RGBA) texture that fades out from the middle. Beyond that you would need to use shaders, i.e. if you wanted a fancy glow extruding out of the pumpkin.
Title: Re: Fake volumetric lights
Post by: robert on October 14, 2012, 01:25:03 pm
No probs. If you want a glow effect as well you could experiment with a simple transparent plane centered near the front-center of the pumpkin with a 32bit (RGBA) texture that fades out from the middle. Beyond that you would need to use shaders, i.e. if you wanted a fancy glow extruding out of the pumpkin.

Hey K24A3, better than using a plane, I think I'm going to use 2 textures, the base one and one for the glow. Then I'll turn up and down the opacity of the glow texture. I got the idea from here: http://www.purebasic.fr/english/viewtopic.php?f=16&t=46130 (http://www.purebasic.fr/english/viewtopic.php?f=16&t=46130)

What do you think ?
Title: Re: Fake volumetric lights
Post by: K24A3 on October 15, 2012, 09:23:29 am
Yeah that may do the trick, assuming jPCT allows you to change the opacity of the 2nd texture leaving the base texture opaque. Haven't tried it myself but Egon can help you with that.
Title: Re: Fake volumetric lights
Post by: EgonOlsen on October 17, 2012, 08:23:33 pm
It's simple additive blending...yes, you can do this.
Title: Re: Fake volumetric lights
Post by: robert on October 20, 2012, 01:28:00 pm
It's simple additive blending...yes, you can do this.

Egon, with additive blending you use a black texture with no alpha, right ? Is there any reason I can't do this with alpha blending ? Note that I don't know much about OpenGL so sorry if this question sounds obvious.

Also, what is the correct way of altering the opacity of the texture every frame ?

Thank you!