Page MenuHome

World Material For The Game Engine
AbandonedPublic

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

Details

Summary

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

Repository
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.
source/blender/makesrna/intern/rna_world.c
492–496 ↗(On Diff #6081)

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

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1607

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...): http://www.pasteall.org/64654

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"
source/blender/blenkernel/BKE_global.h
168 ↗(On Diff #6098)

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

source/blender/blenloader/intern/versioning_250.c
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?

release/scripts/startup/bl_ui/properties_game.py
399

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.

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1598

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.

1619–1622

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.

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1598

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

1619–1622

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.
source/blender/blenloader/intern/versioning_270.c
1065

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).

source/gameengine/Ketsji/KX_KetsjiEngine.cpp
1171

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.

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1598

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).

1619–1622

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
source/gameengine/Ketsji/KX_KetsjiEngine.cpp
1171

@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)

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1619–1622

What about glRectf ?

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
1576

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

source/gameengine/Rasterizer/RAS_IRasterizer.h
464

You should update the comment

source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
58

It's no longer needed

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