Playing with shaders

About Monkey 2 Forums Monkey 2 Development Playing with shaders

This topic contains 26 replies, has 8 voices, and was last updated by  peterigz 2 years, 2 months ago.

Viewing 12 posts - 16 through 27 (of 27 total)
  • Author
    Posts
  • #6583

    peterigz
    Participant

    Agree with codifiles there, gameplay definitely king! A lot of my interest lies in performance boosts. I’ve wondered if I can upload the data of a particle effect into a texture and render/process the whole effect on the card. Definitely something I want to investigate more at some point.

    #6587

    codifies
    Participant

    You can if you want render everything in a shader, (it has been done) but good look getting it working on laptops and phones, as well as performance you should keep an eye towards compatibility… (not everyone has the latest hardware)

    #6650

    shinkiro1
    Participant

    I think shaders are a cheap way to stylize your game and make it unique. Cheap in the sense that your whole game benefits from it and you have to put in very little work. I disagree that they are not important to gameplay. Conveying information clearly to the player is sometimes best done by an effect (glitching screen, blur, color-toning to convey mood, etc.).

    The way I have done Fullscreen effects in my game (mx1) is to use 2 textures (lets call them A and B):
    As suggested, you render your whole game to a texture first (in our case on texture A).

    Then we start applying effects (fragment shader only):
    1. Pass A to your shader
    2. Set B as render target
    3. Render/Flush
    4. Switch A and B
    5. Go to next shader

    My current shaders include: blackwhite, color-toning (rgb), glitch-effect, water-ripples, invert, reduce-colors & melt.

    Like this: http://giphy.com/gifs/shaders-condorra-monkey-x-l0ExouG6baYE95SEg

    #6661

    codifies
    Participant

    I didn’t say they were unimportant, just not as important (by a way!) everything is a balance, but gameplay and balanced (game) rules should be the primary importance, yes presentation is important, but be honest how many so called AAA games have you seen that look gorgeous, yet have really boring gameplay…

    #6662

    AdamStrange
    Participant

    @shinkiro how are you doing the shaders with a monkey2 app?

    #6702

    shinkiro1
    Participant

    @adamstrange

    It’s an mx1 app. I am currently not using mx2, but couldn’t you guys port over the mojo2 system? I mean the source is available if you have mx1 pro.

    #6827

    AdamStrange
    Participant

    @peterigz Very interesting way of accessing shaders. I’ve now got it added to my code and it works flawlessly 😉

    You can see it working in the background in the screenshot

     

    <span style=”color: #eecc00; font-size: 14px; text-align: center; background-color: #334455;”> </span>

    #6830

    peterigz
    Participant

    Looks great 🙂

    Ideally, as shinkiro mentions, we can get this mojo working the same as monkey-x mojo2, I was browsing that code yesterday and the shaders look much more accessible and less messy. It looks like the scalars/uniforms are implemented in the materials. I wonder how easy it’d be to replicate that functionality? Copy and paste the code and fix all the errors until it works maybe? That’d be my brute force approach lol 😉

    #6831

    shinkiro1
    Participant

    To be honest, I don’t like how the shader system works in mojo2.

    First of all, it’s not very flexible in that you can only access fragment shaders. Now even though you can’t do much, it’s so cumbersome to use, that I wrote a whole library around it to make it somewhat manageable. Compare this to the really simple API of löve2d: https://love2d.org/wiki/love.graphics.setShader

    I think they got the design right. It’s not flexible, but very simple.
    If you want it to be more advanced (like access to vertex shader, etc.), a more complex api is to be expected.

    #6832

    peterigz
    Participant

    I see, I also liked the look of how three.js does it as well from what I’ve seen of that.

    #6835

    AdamStrange
    Participant

    yep. it’s sorta similar to how Apple did it with their access to shaders as well.

     

    I suppose it would be possible to rewrite the graphics part off mojo2 to support this way of doing things in that:

    you have a 2d shader variable that is not set. when it is set – use that shader for any drawing, etc.

     

    Looking into the canvas.graphics part it would be very simple to implement, but would need some recoding of all the base graphics stuff which I don’t think Mark would really like anyone to touch – unless you were happy doing it that way?

    #6838

    peterigz
    Participant

    I was thinking of just creating a separate mod just to have a play around but my opengl/sdl is a bit limited, fun to learn though 🙂

Viewing 12 posts - 16 through 27 (of 27 total)

You must be logged in to reply to this topic.