UPBGE: Realtime Cubemaps Reflections tutorial



Warning: The API changes a bit with 0.1.5 as cubemaps API have a common base with planar reflections/refractions API.
Tips:
– You can try to share cubemap texture for 2 different objects but only 1 viewpoint for texture capture will be taken into account.
– Working on mesh normals (with modifiers for example) can improve reflections on some types of meshes, but by default, cubemaps don’t work well on flat surfaces and in most cases you have to smooth your object.
– If you want to deform the reflection with a normal map, the normal map texture has to be in a slot before cubemap texture slot.
– Cubemaps uses lots of performances. Try to avoid reflecting objects with huge number of vertices using ignoreLayers and cliStart/clipEnd options.
– Don’t forget that you can use this feature to have « static » cubemaps (with auto update option)
– The better filtering option for me is Linear filtering but you can also use MipMap filtering: It allow you to use texture lodbias option
on cubemap textures (costs a lot performances)
– A python API is available in upbge (help–python API reference) to help you. the cubemap is accessed like that:
cubemap = own.meshes[0].materials[index].textures[index].cubeMap
then you can do cubemap. »attribute » = … or use cubemap methods.
All of this attributes/methods are in KX_CubeMap.
– The cubemap texture resolution is automatically corrected if you enter a wrong value but it has to respect 2 criterias:
1) cubemap height must be a power of 2
2) cubemap width must be equal to 3/2*height
– Why cubemaps rendering costs a lot performances? Because the scene has to be render 6 times for each cubemap texture. But a culling system improves performances.
– For planar reflections, use ImageMirror.
– Don’t update cubemaps when it is not needed (static cubemaps)
– Don’t use too much objects with realtime cubemap reflections (and realtime update) in your scene.
– Materials options are available as for other materials. You can work on material to obtain the result that fits your needs. You can also work on most of texture options but geometry options are not working for cubemap textures. Some blend types options give interesting results.
– You can mix/multiply… your cubemap with other textures but always be carefull about texture stack order. You can have nice results with alpha textures and stencils.

source

KA2Studio
Logo
Compare items
  • Total (0)
Compare
0