mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
New 3D Mode: Pageflip
The pageflip mode requires a stereo quadbuffer, and a modern graphic card. Patch tested with NVidia 3D Vision. The mini-map is not drawn, but that's what is done for topbottom and sidebyside modes as well. Also most of the time the user would prefer the HUD to be off. That's for the user to decide though, and toggle it manually. Finally, the interocular distance (aka eye separation) is twice as much as the "3d_paralax_strength" settings. I find this a strange design decision. I didn't want to chance this though, since it's how the other 3d modes interpret this settings.
This commit is contained in:
parent
fe3f6be4d2
commit
9943ae3f1a
@ -454,7 +454,8 @@ fall_bobbing_amount (Fall bobbing) float 0.0
|
|||||||
# - interlaced: odd/even line based polarisation screen support.
|
# - interlaced: odd/even line based polarisation screen support.
|
||||||
# - topbottom: split screen top/bottom.
|
# - topbottom: split screen top/bottom.
|
||||||
# - sidebyside: split screen side by side.
|
# - sidebyside: split screen side by side.
|
||||||
3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside
|
# - pageflip: quadbuffer based 3d.
|
||||||
|
3d_mode (3D mode) enum none none,anaglyph,interlaced,topbottom,sidebyside,pageflip
|
||||||
|
|
||||||
# In-game chat console background color (R,G,B).
|
# In-game chat console background color (R,G,B).
|
||||||
console_color (Console color) string (0,0,0)
|
console_color (Console color) string (0,0,0)
|
||||||
|
@ -518,7 +518,8 @@
|
|||||||
# - interlaced: odd/even line based polarisation screen support.
|
# - interlaced: odd/even line based polarisation screen support.
|
||||||
# - topbottom: split screen top/bottom.
|
# - topbottom: split screen top/bottom.
|
||||||
# - sidebyside: split screen side by side.
|
# - sidebyside: split screen side by side.
|
||||||
# type: enum values: none, anaglyph, interlaced, topbottom, sidebyside
|
# - pageflip: quadbuffer based 3d.
|
||||||
|
# type: enum values: none, anaglyph, interlaced, topbottom, sidebyside, pageflip
|
||||||
# 3d_mode = none
|
# 3d_mode = none
|
||||||
|
|
||||||
# In-game chat console background color (R,G,B).
|
# In-game chat console background color (R,G,B).
|
||||||
|
@ -512,6 +512,9 @@ bool ClientLauncher::create_engine_device()
|
|||||||
u16 bits = g_settings->getU16("fullscreen_bpp");
|
u16 bits = g_settings->getU16("fullscreen_bpp");
|
||||||
u16 fsaa = g_settings->getU16("fsaa");
|
u16 fsaa = g_settings->getU16("fsaa");
|
||||||
|
|
||||||
|
// stereo buffer required for pageflip stereo
|
||||||
|
bool stereo_buffer = g_settings->get("3d_mode") == "pageflip";
|
||||||
|
|
||||||
// Determine driver
|
// Determine driver
|
||||||
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
|
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
|
||||||
std::string driverstring = g_settings->get("video_driver");
|
std::string driverstring = g_settings->get("video_driver");
|
||||||
@ -537,6 +540,7 @@ bool ClientLauncher::create_engine_device()
|
|||||||
params.AntiAlias = fsaa;
|
params.AntiAlias = fsaa;
|
||||||
params.Fullscreen = fullscreen;
|
params.Fullscreen = fullscreen;
|
||||||
params.Stencilbuffer = false;
|
params.Stencilbuffer = false;
|
||||||
|
params.Stereobuffer = stereo_buffer;
|
||||||
params.Vsync = vsync;
|
params.Vsync = vsync;
|
||||||
params.EventReceiver = receiver;
|
params.EventReceiver = receiver;
|
||||||
params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
|
params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
|
||||||
|
@ -404,6 +404,84 @@ void draw_top_bottom_3d_mode(Camera& camera, bool show_hud,
|
|||||||
camera.getCameraNode()->setTarget(oldTarget);
|
camera.getCameraNode()->setTarget(oldTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void draw_pageflip_3d_mode(Camera& camera, bool show_hud,
|
||||||
|
Hud& hud, std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
|
||||||
|
scene::ISceneManager* smgr, const v2u32& screensize,
|
||||||
|
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv,
|
||||||
|
video::SColor skycolor)
|
||||||
|
{
|
||||||
|
/* preserve old setup*/
|
||||||
|
irr::core::vector3df oldPosition = camera.getCameraNode()->getPosition();
|
||||||
|
irr::core::vector3df oldTarget = camera.getCameraNode()->getTarget();
|
||||||
|
|
||||||
|
irr::core::matrix4 startMatrix =
|
||||||
|
camera.getCameraNode()->getAbsoluteTransformation();
|
||||||
|
irr::core::vector3df focusPoint = (camera.getCameraNode()->getTarget()
|
||||||
|
- camera.getCameraNode()->getAbsolutePosition()).setLength(1)
|
||||||
|
+ camera.getCameraNode()->getAbsolutePosition();
|
||||||
|
|
||||||
|
//Left eye...
|
||||||
|
driver->setRenderTarget(irr::video::ERT_STEREO_LEFT_BUFFER);
|
||||||
|
|
||||||
|
irr::core::vector3df leftEye;
|
||||||
|
irr::core::matrix4 leftMove;
|
||||||
|
leftMove.setTranslation(
|
||||||
|
irr::core::vector3df(-g_settings->getFloat("3d_paralax_strength"),
|
||||||
|
0.0f, 0.0f));
|
||||||
|
leftEye = (startMatrix * leftMove).getTranslation();
|
||||||
|
|
||||||
|
//clear the depth buffer, and color
|
||||||
|
driver->beginScene(true, true, irr::video::SColor(200, 200, 200, 255));
|
||||||
|
camera.getCameraNode()->setPosition(leftEye);
|
||||||
|
camera.getCameraNode()->setTarget(focusPoint);
|
||||||
|
smgr->drawAll();
|
||||||
|
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||||
|
|
||||||
|
if (show_hud) {
|
||||||
|
draw_selectionbox(driver, hud, hilightboxes, show_hud);
|
||||||
|
|
||||||
|
if (draw_wield_tool)
|
||||||
|
camera.drawWieldedTool(&leftMove);
|
||||||
|
|
||||||
|
hud.drawHotbar(client.getPlayerItem());
|
||||||
|
hud.drawLuaElements(camera.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
guienv->drawAll();
|
||||||
|
|
||||||
|
//Right eye...
|
||||||
|
driver->setRenderTarget(irr::video::ERT_STEREO_RIGHT_BUFFER);
|
||||||
|
|
||||||
|
irr::core::vector3df rightEye;
|
||||||
|
irr::core::matrix4 rightMove;
|
||||||
|
rightMove.setTranslation(
|
||||||
|
irr::core::vector3df(g_settings->getFloat("3d_paralax_strength"),
|
||||||
|
0.0f, 0.0f));
|
||||||
|
rightEye = (startMatrix * rightMove).getTranslation();
|
||||||
|
|
||||||
|
//clear the depth buffer, and color
|
||||||
|
driver->beginScene(true, true, irr::video::SColor(200, 200, 200, 255));
|
||||||
|
camera.getCameraNode()->setPosition(rightEye);
|
||||||
|
camera.getCameraNode()->setTarget(focusPoint);
|
||||||
|
smgr->drawAll();
|
||||||
|
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
|
||||||
|
|
||||||
|
if (show_hud) {
|
||||||
|
draw_selectionbox(driver, hud, hilightboxes, show_hud);
|
||||||
|
|
||||||
|
if (draw_wield_tool)
|
||||||
|
camera.drawWieldedTool(&rightMove);
|
||||||
|
|
||||||
|
hud.drawHotbar(client.getPlayerItem());
|
||||||
|
hud.drawLuaElements(camera.getOffset());
|
||||||
|
}
|
||||||
|
|
||||||
|
guienv->drawAll();
|
||||||
|
|
||||||
|
camera.getCameraNode()->setPosition(oldPosition);
|
||||||
|
camera.getCameraNode()->setTarget(oldTarget);
|
||||||
|
}
|
||||||
|
|
||||||
void draw_plain(Camera& camera, bool show_hud, Hud& hud,
|
void draw_plain(Camera& camera, bool show_hud, Hud& hud,
|
||||||
std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
|
std::vector<aabb3f> hilightboxes, video::IVideoDriver* driver,
|
||||||
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv)
|
bool draw_wield_tool, Client& client, gui::IGUIEnvironment* guienv)
|
||||||
@ -466,6 +544,13 @@ void draw_scene(video::IVideoDriver *driver, scene::ISceneManager *smgr,
|
|||||||
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
|
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
|
||||||
show_hud = false;
|
show_hud = false;
|
||||||
}
|
}
|
||||||
|
else if (draw_mode == "pageflip")
|
||||||
|
{
|
||||||
|
draw_pageflip_3d_mode(camera, show_hud, hud, hilightboxes, driver,
|
||||||
|
smgr, screensize, draw_wield_tool, client, guienv, skycolor);
|
||||||
|
draw_crosshair = false;
|
||||||
|
show_hud = false;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
draw_plain(camera, show_hud, hud, hilightboxes, driver,
|
draw_plain(camera, show_hud, hud, hilightboxes, driver,
|
||||||
draw_wield_tool, client, guienv);
|
draw_wield_tool, client, guienv);
|
||||||
|
@ -1872,6 +1872,10 @@ void Game::run()
|
|||||||
|
|
||||||
void Game::shutdown()
|
void Game::shutdown()
|
||||||
{
|
{
|
||||||
|
if (g_settings->get("3d_mode") == "pageflip") {
|
||||||
|
driver->setRenderTarget(irr::video::ERT_STEREO_BOTH_BUFFERS);
|
||||||
|
}
|
||||||
|
|
||||||
showOverlayMessage(wgettext("Shutting down..."), 0, 0, false);
|
showOverlayMessage(wgettext("Shutting down..."), 0, 0, false);
|
||||||
|
|
||||||
if (clouds)
|
if (clouds)
|
||||||
|
Loading…
Reference in New Issue
Block a user