Semi-major mojo update

Hi!

Ok, I’ve just committed/pushed some pretty major improvements/changes to mojo.

First up, mojo can now do 2d normal-map style lighting! It’s also very easy to use:

  • Load ‘bumpmap’ images with Image.LoadBump(). This takes 3 file paths – a path for the ‘diffuse’ map, a path for the ‘normal’ map, and an optional path for the ‘specular’ map.
  • Load ‘light’ images using Image.LoadLight(). Currently, all lighting is image based, ie: the image describes the size and and falloff of the light.
  • Inside OnRender, use Canvas.BeginLighting() to put the canvas into ‘lighting mode’.
  • While in lighting mode, use Canvas.AddLight() and Canvas.AddShadowCaster() to add lights and shadow casters to the canvas. These are transformed by the current 2d drawing matrix at the time they are added and, in the case of lights, the light color is also modulated by Canvas.Color.
  • Finally, use Canvas.EndLighting() to actually render (and flush) lights and shadows.
  • As in mx1, you can also add shadow casters to image so they’re automatically added when you DrawImage.

There are few restrictions on what you can do in lighting mode: you can’t modify the viewport, scissor or ambientlight properties, or Clear() the render target – this stuff must all be setup before you enter lighting mode – but apart from that you can use the full canvas API.

There are 2 simple lighting demos in the bananas folder: simplelight and lightsparks.

Secondly (and possibly breakingly) I’ve modified the texture filtering system. TextureFlags no longer contains ‘Filter’ or ‘Mipmap’ enums (currently, it only contains ‘Dynamic’). I considered leaving these in as NOPs for backward compatibility but I think that’d just confuse things. Instead, texture filtering is selected on the fly via Canvas.TextureFilter (similar to Canvas.DisableTextureFiltering – now deprecated), or you can force an image to using a particular filter mode via Image.TextureFilter. This is probably the change that will the affect the most projects (I had to tweak a few bananas) but it should be easy enough to deal with – basically, forget about texture flags unless you’re creating a dynamic image.

Thirdly, I’ve added some renderstate stuff to the Image class including BlendMode, TextureFilter and Color properties. BlendMode and TextureFilter default to ‘null’, which basically means ‘use the canvas property’, ie: old mojo behavior. But if you set these to non-null, they will override the canvas properties. Color defaults to white, and is modulated by canvas color.

Finally, the entire shader system has been completely rewritten. I severely doubt anyone was using the dodgy old undocced (and @hidden) system, but if you were, sorry, but it had to be done. The new system isn’t quite ready for public use yet, but it should be much easier for peple to play with shaders once it is.

Whew! I’ll probably do a follow up post tomorrow going into a bit more detail on how this stuff works, but that’ll have to do for now as I’m stuffed!

Bye,
Mark

0

13 thoughts to “Semi-major mojo update”

  1. Hi,

    are there specific changes in OS X 10.12 you really need? If not, you should always support the two latest releases. Many people don’t upgrade their OS this fast (due to bugs, never change a running…, familiar workflow/working tools/work to do … and jump on late or skip one version entirely. => Support for OS X 10.11 and 10.12, otherwise can’t run m2.

    What’s up with Ted2? Any news about its Retina support?

    What’s up with audio improvements (suggested two options in another thread) and as always 3D?

    0

  2. @taumel

    MX2 needs to work with the latest releases, just because people can use them and buy new hardware that is running the latest versions.

     

    0

  3. are there specific changes in OS X 10.12 you really need?

    Is it not working on 10.11? I have installed sierra but haven’t done anything that means it should require it. If  you’re having problems, perhaps someone could compile mx2cc on 10.11?

    What’s up with Ted2? Any news about its Retina support?

    More ted2 work coming up next month, including more themes – one of which I will make 2x size – but that’s about all I can do as I don’t have a retina machine so I’m  not sure what people are expecting in terms of ‘retina support’.

    What’s up with audio improvements (suggested two options in another thread)

     

    As for the audio stuff, I’m not sure what you mean. Please post an issue at github if you want me to look at something (sure I’ve told tyou this before!) otherwise there’s little chance anything will get done unless it also happens to be on my hit-list.

    and as always 3D?

    Would love to do some 3D, but there’s still a fair bit of grunt work to get out of the way first.

    MX2 needs to work with the latest releases

    It *should* work with macos versions going back quite a way as it doesn’t use any ‘modern’ mac features. SDL2 as far as I know is 10.6 compatible, and I’m only using the gles20 subset of opengl.

     

     

     

     

    0

  4. the most basic “retina” support is providing 2x pixel images and then allowing the user to scale the interface by a percent with images scaling down from the 2x and interface items and fonts drawn with “scaled” sizes… (don’t scale the fonts/interface, change the render sizes)

    better is to not use any pixel based images and use svg or icon fonts for all images

    even better would be to read each monitors system provided scaling setting and default to that (still allowing the user to set it).

    even better, monitor dpi changes as well. (user moves the window from one monitor to another)

    0

  5. Awesome news!

    There are few restrictions on what you can do in lighting mode: you can’t modify the viewport, scissor or ambient light properties, or Clear() the render target

    This concerns me a bit. If I understand this correctly I can only modify the viewport or scissors while not in lighting mode. I’ll have to take a look and see if it an issue for me but I’m basically modifying the viewport and scissors every draw or render frame in my GUI to accommodate window views. Could I do a loop which is  something like set the viewport and scissors then enter lighting and exit lighting?

    0

  6. @Mark
    It refuses to run on 10.11.6, stating it needs 10.12. As i wrote, the majority of Mac users is split upon the two latest releases, just supporting the latest one, when you don’t need a feature badly, reduces the audience without a need. I’m confused about the compilation.

    2x: ted2(lowres) vs. sub3(retina)

    Audio improvements = fmod/wwise support, adding formats like flac … You know there aren’t too many people posting on the forum, it shouldn’t be hard to notice such posts.

    Any rough time estimation for 3d?

    0

  7. It refuses to run on 10.11.6, stating it needs 10.12

    Can you provide the *exact* error you get so I can google it?

    Could I do a loop which is  something like set the viewport and scissors then enter lighting and exit lighting?

    Yes, that’s the idea, something like:

    You might also want to draw non-lit ‘overlays’ after lighting too. It’ll still work if you draw them inside lighting, it’ll just mean the lighting code has a bit less work to do if you do it after.

    Have a play, this is all new stuff!

    0

  8. You know there aren’t too many people posting on the forum, it shouldn’t be hard to notice such posts.

    Sure, I notice most (but not all) forum posts. But unless it’s something I consider high priority, I’ll probably just forget about it.

    If you have a bug report or feature request that you want me to (eventually) respond to, post an issue at github. Don’t just post in the forums and ‘hope’ that I see/remember it – and please don’t spam blog update post replies with feature requests either!

    It takes, what, 30 seconds to post at github, so I really don’t understand your reluctance to use it.

    0

  9. Have a play, this is all new stuff!

    You know I will! I’ll be adding this to my game framework ASAP and have a demo soon.

    Hats off bro and nice job getting lighting into mojo. You are a code machine.   I’ll be increasing my Patreon monthly support this next month. Thanks, was really wanting this feature.

    0

  10. Good work. I’m a bit more seasoned now. I just need to port the ted21 codebase from 1.02 to this new one

    0

  11. @Mark
    It compiles fine but starting ‘Monkey2 (Macos)’ results into a popup with the message that i can’t run this version of the software on that version of OS X i’m running (Auf Ihrem Computer ist OS X 10.11.6 installiert. Das Programm erfordert OS X 10.12 oder neuer.). I can compile my own stuff with Xcode 8 on OS X 11.6 (defaults 10.11 deployment settings). There is no error, right from the start the m2 icon is showing that the app won’t be executed.

    Because this isn’t an isolated case and otherwise it would need to increase the number of accounts i need to remember even more.

    So, what about sound and 3d?

    0

  12. it would need to increase the number of accounts i need to remember even more.

    Well, we can’t have that now, can we! I guess this means I’m supposed to hunt down the particular audio thread you’re talking about? Erm, no…

    Anyway, support for additional audio formats (I’m guessing this is what you’re talking about?) is low priority right now so I don’t know when/if it will happen. It is entirely feasible for 3rd parties to write wrappers for more formats though, so perhaps if you have some spare time…?

    As for 3d, you mean something like b3d? I would like to do something like this eventually, but it’s a relatively big job and, again, there is still a bunch of other stuff to get of the way first so I have no idea when/if it’ll happen. Right now, I’m still concentrating on polishing up what’s there.

     

     

     

     

     

    0

  13. Hunting sounds a little bit extreme for a google search.

    Hmm, a big aspect of using a tool like Max/Monkey was/should be saving some time. You invest your time into building a tool which enables other people saving some of theirs, and therefore they pay you in return. And if both parts end up having some fun at the end of the day, it sounds like a good deal.

    Polishing is a very good idea but looking at certain aspects i guess i disagree with some of your priorities. I’m interested in an easy to use, focused, modern 3d engine for monkey 2 on the Mac. I don’t need Android, Raspberry … I don’t need tons of options but i also want it to look up to date via a focused feature set, like a fraction of Unity/Unreal but the fraction which matters. Why did you stop developing max3d?

    0