Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Shadows - Why can't we use a pointlight as the shadow source?

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 21st Aug 2017 21:44
I'm guessing it's because there's only one vector used for the sun and a point light will want to cast shadows in all directions?
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 22nd Aug 2017 20:34 Edited at: 22nd Aug 2017 21:28
Also a point light needs the shadow-map to be rendered into a cube-map or at least dualparabolic-map.
Paul needs to implement cube-mapping or there are 2 other texture stages(for dualparabolic-mapping) gone again.
And I think it's nothing you would want to calculate every frame for an average mobile game.

Cube-mapping would be useful for other things like reflections/environment-mapping though.

Small excursion:
For directional shadow-mapping we iterate through the texels and cast a ray towards the sun.
If the sun is blocked by an object, we draw the texel in ambient color and the rest in light, we can check that by comparing the texel depth with the corresponding depth of the shadow-map.
It's the same for point lights, but as it would want to cast a shadow in all directions we need a shadow-map that can represent the depth of all objects viewed from the point light, so we can compare against it.
We can render the cube-map into 6 textures representing each side of the cube, which leaves us with only 2 texture stages for lets say diffuse and normal-mapping...
We could also write the 6 images into a single big texture but it's not possible to do it fast in AGK(I already tried it) and there is a technique in OpenGl ES called cube-mapping(surprise) that does this for us.
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Aug 2017 21:11
Cube mapping sounds really useful. Reflections would be really nice.

janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 22nd Aug 2017 21:18 Edited at: 22nd Aug 2017 21:28
Convince Paul to implement something like SetObjectMeshCubeMap(ObjectID,MeshID,CubeImageID,CubeSideID,StageID) and I'll make you glass shader where you can set the reflectivity and refraction value
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Aug 2017 23:41
Better start a new thread, as this started off about lights.
Perhaps some of the code is already there in the skybox stuff?
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 22nd Aug 2017 23:49
Quote: "We could also write the 6 images into a single big texture but it's not possible to do it fast in AGK(I already tried it) and there is a technique in OpenGl ES called cube-mapping(surprise) that does this for us.
"

If the big texture was like an unwrapped cube, this wastes a lot of GPU memory doesn't it? 6 empty faces.
I think 6 images is too much to use up.. Maybe in pairs?
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 23rd Aug 2017 09:07
It would be simpler in the mean time to use an environment map to simulate reflections. If you have a skybox, you could use the textures of the skybox as a cubemap, or use the skysphere texture as a spheremap. It wouldn't be realtime, but at least the skybox would be reflective. This is the technique older games used to use (And some modern games still do) to fake believable reflective surfaces. And it should be quite quick as well. (Certainly for the spheremap method.)
Click here for VR Legend of Zelda stuff
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 23rd Aug 2017 14:06
Quote: "Perhaps some of the code is already there in the skybox stuff"

Actually I found something in Pauls shader code: texture%d CubeMap%d uvBounds%d

nz0 wrote: "6 empty faces"

Why empty ?
Lets say I render 6 faces into 1024*1024 big textures then the self made texture array was 6144*1024 pixels in size.

@Mobius: The problem is, we don't have access to the skybox texture in in glsl and it would be a cube-map for sure, regardless of realtime or not
Environment-mapping is either sphere-mapping which is not accurate, dualparabolic-mapping which uses 2 textures but wastes texture space and needs a extra calculation to unwrap the paraboloid and there is cube-mapping which is precise doesn't waste texture space and you can just use the normal or reflection vector to get the uv coordinates, so no extra calculation

Login to post a reply

Server time is: 2024-09-30 07:18:11
Your offset time is: 2024-09-30 07:18:11