Page MenuHome

World Material For The Game Engine

Authored by Diego Lopes (TwisterGE) on Feb 15 2016, 5:09 AM.



This patch allows to render the world material in the game engine exactly like it's rendered in the viewport.
Every world setting was exposed to the game engine: Zenith Color, Horizon Color, Paper/Blend/Real Sky, Environment Texture, etc...
You can Enable/Disable it in the Shading panel

A few screenshots:

Test .blend:

Diff Detail

rB Blender

Event Timeline

Diego Lopes (TwisterGE) retitled this revision from to World Material For The Game Engine.
Diego Lopes (TwisterGE) updated this object.
Diego Lopes (TwisterGE) set the repository for this revision to rB Blender.

Can this setting be moved to the shading panel in rendering tab and be enabled by default?


As this API is deprecated, I think it's better to rewrite using VBO.

@Diego Lopes (TwisterGE): Here is an example that HG1 gave me in the past if you want (to avoid glBegin...):

Diego Lopes (TwisterGE) updated this revision to Diff 6093.EditedFeb 15 2016, 3:12 PM
Diego Lopes (TwisterGE) updated this object.
Diego Lopes (TwisterGE) edited edge metadata.

Updated patch:

  • VA support
  • Render only the first scene (To avoid rendering the world background of all active scenes)
  • Remove the Game Sky option from World panel and move it to Shading panel. It's now called "Render World Background"
168 ↗(On Diff #6098)

Why is this in BKE_global.h and not DNA_scene_types.h?

1113 ↗(On Diff #6098)

This looks strange, should it be "&" instead of "|="?

Ulysse Martin (youle) edited edge metadata.

For me, all is ok :)

This revision is now accepted and ready to land.Feb 16 2016, 1:07 AM

It this done toward the end of drawing so that the full screen quad can take advantage of depth testing?


Is this supported in multitexture mode? If not it should be under the GLSL option. If it is, that seems odd since it requires shaders.


If no material is found, shouldn't we skip drawing the full screen quad and rely on the glClear call? If we are trying to avoid deprecated code, we probably should not be adding matrix stack manipulation.


I think we will eventually be getting rid of vertex arrays and replacing them with VBOs. If we are avoiding glBegin/glEnd, we might as well do it with VBOs.


I will try to fix this. But I just copied this part from view3d_draw.c (view3d_main_region_clear)


A VBO for only 4 vertices is a waste of memory in my opinion.

Mitchell Stokes (moguri) requested changes to this revision.Feb 16 2016, 4:14 AM
Mitchell Stokes (moguri) edited edge metadata.
Mitchell Stokes (moguri) added inline comments.
1065 ↗(On Diff #6103)

I'm guessing world rendering and all of the BGE's old material controls are incompatible? That would be quite a shame, but also understandable. I think we could support both by having the existing BGE interfaces write data back to Blender data like we do for lights and materials. I wouldn't consider this a blocking issue, but something to think about (possibly for a future patch).


We should call RenderWorld() at the beginning of KX_KetsjiEngine::EndFrame(). This way we don't have to deal with multiple scenes and we can take advantage of depth testing to avoid extra fragment shader invocations. However, this does mean we'll have to pick a scene to use for world rendering. Picking the first scene does not work well since background scenes are inserted into the front of the scene list.


Since this patch does not disable any of the original clear code, I think we can just bail out of this function if we don't have a material (probably with some sort of error/warning).


While the vertex arrays are okay, I would have actually preferred sticking with glBegin/glEnd. Both Blender and the BGE make use of full screen quads in a few places, and I'm sure we'll eventually create a single bf_gpu function to render a full-screen quad with VBOs. If/when that happens, we can clean up all full-screen quad code at once.

This revision now requires changes to proceed.Feb 16 2016, 4:14 AM

@Mitchell Stokes (moguri): We can't move this code before because the cmaera matrix will be not set(= it will use the previous one in the last scene)


What about glRectf ?


This isn't really specific to backgrounds. I'd re-work this into a generic RenderFullScreenQuad().


You should update the comment


It's no longer needed

BGE was removed in Blender 2.80 this patch is being closed as a result.