Ultra Mode 7

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
301
Reaction score
312
First Language
Croatian
Primarily Uses
RMMV
Ultra Mode 7 v1.5.3
Blizzard

Introduction

Ultra Mode 7 simulates the Mode 7 rendering mode from the SNES by using 3D rendering (hence the "Ultra"). Sprites are scaled appropriately and use additional code to determine whether they are visible, because of cut-off distance. The view of a Mode 7 map is defined by the following parameters:
  • camera distance
  • camera Y position
  • field of view
  • pitch rotation angle
  • yaw rotation angle
  • maximum Z coordinate

This work is licensed under BSD License 2.0:
Copyright (c) Boris "Blizzard" Mikić
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
You may use this script for both non-commercial and commercial products without limitations as long as you fulfill the conditions presented by the above license. The "complete" way to give credit is to include the license somewhere in your product (e.g. in the credits screen), but a "simple" way is also acceptable. The "simple" way to give credit is as follows:
Ultra Mode 7 licensed under BSD License 2.0, Copyright (c) Boris "Blizzard" Mikić
Alternatively, if your font doesn't support diacritic characters, you may use this variant:
Ultra Mode 7 licensed under BSD License 2.0, Copyright (c) Boris "Blizzard" Mikic
In general other similar variants are allowed as long as it is clear who the creator is (e.g. "Ultra Mode 7 created by Blizzard" is acceptable). But if possible, prefer to use one of the two variants listed above.

If you fail to give credit and/or claim that this work was created by you, this may result in legal action and/or payment of damages even though this work is free of charge to use normally.

Features
  • render map in 3D
  • control rendering with various parameters and even change them on the fly
  • supports white fading of horizon
  • supports auto-scaling for sprites depending on distance from camera
  • high performance
  • easy to use

v1.5.3
  • improved compatibility code for KhasUltraLighting

v1.5.2
  • added camera Y position

v1.5.1
  • added color fade begin to map parameters
  • added color fade end to map parameters

v1.5.0
  • added map parameters for map borders

v1.4.6
  • added compatibility for newer pixi-tilemap versions

v1.4.5
  • added compatibility with Quasi Simple Shadows

v1.4.4
  • added compatibility with Thomas Edison MV
  • fixed issue with fixed-coordinate parallax not working

v1.4.3
  • changed NEAR_CLIP_Z from constant to plugin parameter

v1.4.2
  • added new parameter FADE_Z_COLOR
  • added option to setup custom fade colors for specific maps
  • added option to change fade color at any time

v1.4.1
  • added compatibility with Yanfly's Gridfree Doodads
  • added compatibility with MOG's Character Motion

v1.4.0
  • added new license
  • added usage and crediting instructions

v1.3.8
  • added script call to enable/disable pixelated rendering during runtime
  • reduced WEBGL_MAX_VERTICES to reduce possibility of glitched rendering

v1.3.7
  • added experimental compatibility for BattleLighting plugin

v1.3.6
  • added experimental compatibility for BattleLighting plugin

v1.3.5
  • corrected some minor positioning and scaling calculation errors
  • improved compatibility code for KhasUltraLighting

v1.3.4
  • added compatibility code for KhasUltraLighting
  • added compatibility instructions for Terrax Plugins - Lighting system

v1.3.3
  • fixed issue with event visibility on map borders when using looping maps

v1.3.2
  • added coordinate rounding for X and Y coordinates
  • improved code that handles sprite visibility when outside of the view frustum
  • removed some leftover debug prints

v1.3.1
  • fixed a crash with event testing

v1.3.0
  • implemented map looping functionality
  • added workaround for PIXI bug where a lag spike would occur about every 10 seconds
  • fixed issue where sprite direction didn't display properly at certain yaw angles
  • fixed issue where movement controls didn't adjust to yaw angle
  • added CHARACTERS_ADJUST_SPRITE_DIRECTION option
  • fixed coordinate offset when using yaw angle

v1.2.4
  • fixed accidental removal of animateCameraDistance function

v1.2.3
  • added parallax distance parameter in maps for parallax movement with yaw and pitch
  • renamed "Camera" functions to "CameraDistance"
  • fixed bug with parallax scrolling on non-Mode 7 maps
  • fixed bug with shaking the screen
  • removed FOV limit and implemented orthogonal projection with FOV of 0°

v1.2.2
  • fixed a syntax error that was caused by code cleanup

v1.2.1
  • fixed save data issue

v1.2.0
  • fixed FPS drop problem while moving

v1.1.0
  • added animation function for parameters
  • renamed RENDER_PIXELATED option to TILEMAP_PIXELATED
  • added CHARACTERS_PIXELATED option
  • fixed issue with floating characters
  • fixed issue with normal maps not working anymore
  • added some code to prevent compatibility issues with some map scripts

Screenshots

https://i.gyazo.com/9c7d3250509a967665e978ea608f46af

How to Use

All instructions are inside the script in the first comment.

Demo

Ultra Mode 7 Demo

Script

Script Download

FAQ

Q: Why does the script not work with canvas?
A: The script was written with the 3D capabilities that WebGL offers. Any implementation ported to work with canvas would be too slow anyway.

Q: Can I change map parameters on the fly?
A: Yes, there are instructions in the script how the script calls are used. There are also examples in the demo.

Credit and Thanks
  • Boris "Blizzard" Mikić
Author's Notes

Compatibility:
  • Requires WebGL. Does not work with canvas and due to how canvas works, it can never support canvas.
  • Because the tilemap is rendered entirely flat, tile priority isn't used.
  • Scaling has been optimized for usage of an FOV of 60°. Using different values will cause some weird scales being used for characters.
  • Due to yaw rotation requiring turning of characters, 8-directional characters sprites might have only limited support.
Make sure to read the instructions and study the demo before asking questions.

You might find this utility script useful that let's you manipulate the anchor point for the sprites: https://forums.rpgmakerweb.com/index.php?threads/character-anchors.105599/

If I'm not active here at some point, you can contact me at my forum about the script: http://forum.chaos-project.com/index.php/topic,15899.0
 
Last edited:

Jonforum

Veteran
Veteran
Joined
Mar 28, 2016
Messages
1,606
Reaction score
1,399
First Language
French
Primarily Uses
RMMV
you forget add a package.json,.
I just try demo , this its fu%$*g awesome !!!
 

Oscar92player

Veteran
Veteran
Joined
Jul 26, 2012
Messages
450
Reaction score
199
First Language
Spanish
Primarily Uses
RMMV
Umm... @bblizzard , I have one question about the Mode 7. Is it made to work with looping maps? Because in your demo, I'm having issues when trying to put the map with loop. Part of the map disappears, like in this picture:
Mode7_001.png
 
Last edited:

Jaiden

RMXP Fiend
Veteran
Joined
Sep 27, 2015
Messages
100
Reaction score
78
First Language
English
Primarily Uses
RMXP
Umm... @bblizzard , I have one question about the Mode 7. Is it made to work with looping maps? Because in your demo, I'm having issues when trying to put the map with loop. Part of the map disappears, like in this picture:
View attachment 87394
Q: Why are looping maps not supported?
A: They require rewrites in some core functionality and can also cause issues depending on the map parameters so this was left out for now.
 

Oscar92player

Veteran
Veteran
Joined
Jul 26, 2012
Messages
450
Reaction score
199
First Language
Spanish
Primarily Uses
RMMV
@Oscar92player As Jaiden already quoted, looping maps aren't supported for now.
Oooh, I get it, thanks for the info! I hope this can be supported someday, since it is a very needed function to make a proper worldmap. But it is admirable that this Mode7 has no lag after all, it's very well optimized, and I hope you can work on more functions in future versions!
 

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
301
Reaction score
312
First Language
Croatian
Primarily Uses
RMMV
Yes, I will add loopable maps in the near future. :) The only reason I didn't add them right now is because my original game code didn't require it so I haven't implemented it there either.

Yeah, I know how the driver usually optimizes rendering and where performance is faster so I know where and how I need to generate and cache rendering data to optimize performance. My very first implementation actually started lagging a lot on larger maps. But I resolved this when I restructured the code later on.
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
472
Reaction score
283
First Language
Portuguese(BR)
Primarily Uses
RMMV
This is simply awesome!
Thank you so much for it!
 

KaYsEr

Koruldia
Veteran
Joined
Mar 14, 2014
Messages
218
Reaction score
447
First Language
French
Primarily Uses
RMMV
Already looks pretty cool so far, congrats and thank you for doing it.
Curious to see where it can lead, I can think of some ideas/tricks but it might still be a bit rough now in order to create something that could look good from a strictly graphical pov, but sure from a technical one it's a nice achievement.

Would be nice to have sprite (events) filtering when scaled (gets really pixelated when too close), and having those in a distance getting “lost in the fog” (Silent Hill style) because right now they stand out (above the “horizon gradient effect”) and just disappear suddenly when too far away, if it’s possible to draw those sprites under the “horizon effect” it might do the trick. :)
 

Frogboy

I'm not weak to fire
Veteran
Joined
Apr 19, 2016
Messages
1,676
Reaction score
2,116
First Language
English
Primarily Uses
RMMV
You released it. Sweet!
 

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
301
Reaction score
312
First Language
Croatian
Primarily Uses
RMMV
Already looks pretty cool so far, congrats and thank you for doing it.
Curious to see where it can lead, I can think of some ideas/tricks but it might still be a bit rough now in order to create something that could look good from a strictly graphical pov, but sure from a technical one it's a nice achievement.

Would be nice to have sprite (events) filtering when scaled (gets really pixelated when too close), and having those in a distance getting “lost in the fog” (Silent Hill style) because right now they stand out (above the “horizon gradient effect”) and just disappear suddenly when too far away, if it’s possible to draw those sprites under the “horizon effect” it might do the trick. :)
Changing filtering is simple. I can make that an option like the filtering of the tiles.
I wasn't sure how exactly I should handle the sprites close to the fade fog. Might be the best to simply fade their color into white as well. What do you think?
 

AdamSakuru

[Null_Value]
Veteran
Joined
Mar 14, 2014
Messages
314
Reaction score
170
First Language
English
Primarily Uses
N/A
Not sure if this is intentional, but when you set the pitch to 0 (for non-mode 7 maps) the sprites disappear.
 

Attachments

Bricabrac

The Storyteller
Veteran
Joined
May 24, 2016
Messages
113
Reaction score
212
First Language
Italian
Primarily Uses
RMMV
Whoa! This is incredible, excellent work :kaopride:

A curiosity: I remember old mode-7 scripts for XP/VX allowed you to make some tile elements like trees "pop up". Will this ever be possible, or is too much of a hassle?
I remember reading other topics about Mode-7 on MV, and it sounded like the engine is just not very apt for this kind of stuff.
 

Espilonarge

Veteran
Veteran
Joined
Apr 24, 2016
Messages
120
Reaction score
53
First Language
English
Primarily Uses
A curiosity: I remember old mode-7 scripts for XP/VX allowed you to make some tile elements like trees "pop up". Will this ever be possible, or is too much of a hassle?.
You're most likely referring to MGC's Mode7 script for VXAce. This is also a feature I would love to see implemented, however the real issue with that script was that you had to set tiles in the Tilesets with the very limited Terrain Tags (0-7) to set them (which lead to oddities when specified tiles "touched" each other). The only possible way to get around that limitation is to use Regions, however, I don't know if in the plugins current state it would even be possible unless it somehow was coded to set two specific regions, one for simply lifting B-E tiles only and the other to lift A-E tiles.

bblizzard, if you're not sure as to what we're referring to, here's an example.



Thank you so much for working on this plugin bblizzard. I have been hoping to implement it in to a number of maps I've made since my project used to be done in VXAce (which I converted to MV due to VXAce's abysmal performance in a number of key areas of the engine) but it was one of the many scripts that I could never find a replacement for in plugin form (or rather lack there-of anyone releasing one that works naturally some gimmicky limitation or issue).

Also, if I could make a couple of suggestions (apart from the vertically standing tiles).

* The ability to set the "color" variant for the fade-out depth (not just white) and be able to transition between two different colors (eg = aqua -> orange -> dark blue -> aqua).
* Add a "timing" function to set the speed the Mode7 adjustments (eg = UltraMode7.setCamera(Z_DISTANCE, FRAMES) ).

The reason why I'm suggesting these is because I have a day-to-night cycle in my game (white doesn't exactly work well during a "night" time scene). I may also want to transition more slower than the current default speed set in the plugin.

EDIT

It seems I've already ran in to two major issues with the plugin.

* It seems the plugin does not like maps that are large (eg = 256x256). The FPS will stay stable at 60 FPS when you stand still but the moment you move or shift the camera around on large maps, the FPS plummets drastically (below 5 FPS on a NVidia GTX1070 based GPU) until you or the camera stops moving, returning back to 60 FPS (tested in both my game and the demo). I'm not sure if this is an issue caused by using OpenGL or something else entirely.
* It seems not to be compatible with SumRndmDde's Camera Core. MV isn't showing errors in the console, rather all tiles become "invisible" when his plugin is turned on (his plugin can be found at http://sumrndm.site/camera-core/).
 
Last edited:

bblizzard

Veteran
Veteran
Joined
Nov 6, 2017
Messages
301
Reaction score
312
First Language
Croatian
Primarily Uses
RMMV
Whoa! This is incredible, excellent work :kaopride:

A curiosity: I remember old mode-7 scripts for XP/VX allowed you to make some tile elements like trees "pop up". Will this ever be possible, or is too much of a hassle?
I remember reading other topics about Mode-7 on MV, and it sounded like the engine is just not very apt for this kind of stuff.
bblizzard, if you're not sure as to what we're referring to, here's an example.

I see. Yeah, I would need to change many things to make this possible. The biggest problem is that there are so many ways you can do this and you can organize maps. Technically without a lot of custom code you won't be able to do many of these things anyway which is why I decided not to implement this. However, this specific example should be possible with events.

Also, if I could make a couple of suggestions (apart from the vertically standing tiles).

* The ability to set the "color" variant for the fade-out depth (not just white) and be able to transition between two different colors (eg = aqua -> orange -> dark blue -> aqua).
Yeah, sure. I was thinking about adding it in the first release, but I skimmed over it until people request it. Which was a good idea since I didn't think about adding multiple colors and now I can do that. xD

* Add a "timing" function to set the speed the Mode7 adjustments (eg = UltraMode7.setCamera(Z_DISTANCE, FRAMES) ).
Yeah, this is another thing that I didn't bother adding right away since I wanted to see if there's any interest for the script.

* It seems the plugin does not like maps that are large (eg = 256x256). The FPS will stay stable at 60 FPS when you stand still but the moment you move or shift the camera around on large maps, the FPS plummets drastically (below 5 FPS on a NVidia GTX1070 based GPU) until you or the camera stops moving, returning back to 60 FPS (tested in both my game and the demo). I'm not sure if this is an issue caused by using OpenGL or something else entirely.
Hm, this is weird. I ran a more complex version of the script (the one I use in my game) with a 500x500 map on an NVidia GTX 1060 with barely noticeable performance hits so I assumed the driver was able to handle all the vertices and optimize them on the GPU (and basically just cut them off). I guess it doesn't and I'll have to do some manual optimizations. ._.

* It seems not to be compatible with SumRndmDde's Camera Core. MV isn't showing errors in the console, rather all tiles become "invisible" when his plugin is turned on (his plugin can be found at http://sumrndm.site/camera-core/).
I'll check it out. I expected these kind of issues.
 
Last edited:

Espilonarge

Veteran
Veteran
Joined
Apr 24, 2016
Messages
120
Reaction score
53
First Language
English
Primarily Uses
Hm, this is weird. I ran a more complex version of the script (the one I use in my game) with a 500x500 map on an NVidia GTX 1060 with barely noticeable performance hits so I assumed the driver was able to handle all the vertices and optimize them on the GPU (and basically just cut them off). I guess it doesn't and I'll have to do some manual optimizations. ._.
I went and did some testing. First, I turned off the plugin and checked my CPU/RAM usage, then turned it back on and checked again. I noticed the moment I moved around (after one tile) on a map with Mode7 active, the CPU activity "spiked" and there was an large increase in RAM usage. I've also tested this with 1.5.1 and 1.6.1, both having the same results.

The following links show what happens when the plugin is turned off and turned on.

Off - https://i.imgur.com/LqrU48v.png
On - https://i.imgur.com/exYTDBc.png

I've seen this kind of behavior before in a number of games and it's not always easy to identify exactly what causes it but there are a number of possibilities.

One theory I have, it's most likely because the plugin is telling the CPU to make each tile use separate graphics on-the-fly. What I mean by this is that it most likely has to process each tile as a "new" graphic separately (256 tiles using 256 desert ground graphics) rather than using the "same" graphic for all specified tiles (256 tiles using just 1 desert ground graphic). Every time I move a tile forward, it removes 256 of those graphics and than creates 256 new ones (which would explain the sudden jump in CPU and memory usage when moving around).

There's also the possibility of this being a driver or OS platform related problem. I'm currently using Windows 7 64-bit as I outright made sure my system would never allowed itself to "upgraded" to Windows 10 (I have my reasons). There's also the fact that much like the OS, GeForce drivers tend to operate differently depending on the video card and OS (even something subtle as the way shaders, tiles or textures are handled) so that might also be a possibility as well.

There's even the fact that you stated that you're using a "complex" version of the plugin. I'm currently using the one provided in the demo to do these tests so I'm not sure if there is any differences between the demo version and the complex version (unless they're actually identical).

At this point, I couldn't really narrow it down but I'm just throwing possible theories to see how it can be resolved.

On another note, I did run in to a couple of rather odd quirks. First, it seems that the boat, ship and airship is always visible in the top-left corner of the map (even when they're not placed on the map) and using angles in excess of 70 (up to 100) is causing events to become visible in the air (not at the point of origin where they were placed).

 
Last edited:

Users Who Are Viewing This Thread (Users: 0, Guests: 2)

Latest Threads

Latest Profile Posts

I love these real life Oblivion videos:
I'm playing DQ:XI DE in 2d mode with the synthesized soundtrack, the only way a RPGMAKER creator should play it. :D
:/ it really get on my nerves reading stuff about how to write a resume and they say things like "turn your failures into wins!!!" ... no interview Ive ever had cared to hear anything about my failures, and why would they :( ?
"Huh? You haven't backed up yet? *menacing stare* "
Been having a lot of fun playing Hearts of Iron IV. Had to restart a few times, but now I've finally conquerd Europe with my Axis friends, and am currently invading the Soviet Union.

Forum statistics

Threads
93,637
Messages
914,168
Members
123,224
Latest member
Nekko_Hime
Top