Ultra Mode 7

Discussion in 'JS Plugin Releases (RMMV)' started by bblizzard, Apr 15, 2018.

  1. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    Ultra Mode 7 v1.4.2
    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
    • field of view
    • pitch rotation angle
    • yaw rotation angle
    • maximum Z coordinate

    This work is licensed under BSD License 2.0:
    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:
    Alternatively, if your font doesn't support diacritic characters, you may use this variant:
    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.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

    [​IMG]
    [​IMG]
    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: Apr 16, 2019 at 8:20 PM
    #1
    Zeriab, Acer2020, Jellicoe and 42 others like this.
  2. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,540
    Likes Received:
    1,276
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    you forget add a package.json,.
    I just try demo , this its fu%$*g awesome !!!
     
    #2
  3. Jonforum

    Jonforum Veteran Veteran

    Messages:
    1,540
    Likes Received:
    1,276
    Location:
    Canada / Québec
    First Language:
    French
    Primarily Uses:
    RMMV
    upload_2018-4-15_9-47-41.png
    :popcorn:
     
    #3
    bblizzard likes this.
  4. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    Whoops. Fixed. xD
     
    #4
  5. Oscar92player

    Oscar92player Veteran Veteran

    Messages:
    413
    Likes Received:
    172
    Location:
    Benalmádena - Málaga - Spain
    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: Apr 16, 2018
    #5
  6. Jaiden

    Jaiden RMXP Fiend Veteran

    Messages:
    62
    Likes Received:
    43
    First Language:
    English
    Primarily Uses:
    RMXP
     
    #6
    Oscar92player and bblizzard like this.
  7. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    @Oscar92player As Jaiden already quoted, looping maps aren't supported for now.
     
    #7
    Oscar92player likes this.
  8. Oscar92player

    Oscar92player Veteran Veteran

    Messages:
    413
    Likes Received:
    172
    Location:
    Benalmádena - Málaga - Spain
    First Language:
    Spanish
    Primarily Uses:
    RMMV
    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!
     
    #8
  9. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    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.
     
    #9
    Oscar92player likes this.
  10. elpeleq42

    elpeleq42 Yeet Veteran

    Messages:
    422
    Likes Received:
    245
    Location:
    Brazil
    First Language:
    Portuguese(BR)
    Primarily Uses:
    RMMV
    This is simply awesome!
    Thank you so much for it!
     
    #10
    bblizzard likes this.
  11. KaYsEr

    KaYsEr Koruldia Veteran

    Messages:
    206
    Likes Received:
    438
    Location:
    London
    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. :)
     
    #11
    bblizzard likes this.
  12. Frogboy

    Frogboy I'm not weak to fire Veteran

    Messages:
    1,585
    Likes Received:
    1,975
    Location:
    North Carolina, U.S.
    First Language:
    English
    Primarily Uses:
    RMMV
    You released it. Sweet!
     
    #12
  13. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    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?
     
    #13
    Oscar92player likes this.
  14. KaYsEr

    KaYsEr Koruldia Veteran

    Messages:
    206
    Likes Received:
    438
    Location:
    London
    First Language:
    French
    Primarily Uses:
    RMMV
    Yes, it's probably a good method to improve the render. Good luck! :)
     
    #14
    Oscar92player likes this.
  15. AdamSakuru

    AdamSakuru Veteran Veteran

    Messages:
    300
    Likes Received:
    166
    Location:
    Calgary, Alberta.
    First Language:
    English
    Not sure if this is intentional, but when you set the pitch to 0 (for non-mode 7 maps) the sprites disappear.
     

    Attached Files:

    #15
  16. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    Nope, it's a bug. I'll look into it.
     
    #16
    Oscar92player likes this.
  17. Bricabrac

    Bricabrac The Storyteller Veteran

    Messages:
    111
    Likes Received:
    203
    Location:
    Italy
    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.
     
    #17
  18. Espilonarge

    Espilonarge Veteran Veteran

    Messages:
    100
    Likes Received:
    31
    Location:
    Australia
    First Language:
    English
    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.

    [​IMG]

    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: Apr 20, 2018
    #18
  19. bblizzard

    bblizzard Veteran Veteran

    Messages:
    215
    Likes Received:
    231
    Location:
    Croatia
    First Language:
    Croatian
    Primarily Uses:
    RMMV
    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.

    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

    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.

    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'll check it out. I expected these kind of issues.
     
    Last edited: Apr 23, 2018
    #19
    KaYsEr likes this.
  20. Espilonarge

    Espilonarge Veteran Veteran

    Messages:
    100
    Likes Received:
    31
    Location:
    Australia
    First Language:
    English
    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).

    [​IMG]
     
    Last edited: Apr 23, 2018
    #20

Share This Page