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.
- 
		AuthorPosts
 - 
		
			
				
January 17, 2017 at 2:45 pm #6583
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.
January 17, 2017 at 5:30 pm #6587You 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)
January 20, 2017 at 12:16 am #6650I 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 shaderMy 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
January 20, 2017 at 9:39 am #6661I 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…
January 20, 2017 at 10:41 am #6662@shinkiro how are you doing the shaders with a monkey2 app?
January 21, 2017 at 3:32 pm #6702It’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.
January 27, 2017 at 10:23 am #6827@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>
Attachments:
January 27, 2017 at 11:28 am #6830Looks 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
January 27, 2017 at 11:40 am #6831To 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.January 27, 2017 at 12:10 pm #6832I see, I also liked the look of how three.js does it as well from what I’ve seen of that.
January 27, 2017 at 12:54 pm #6835yep. 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?
January 27, 2017 at 6:59 pm #6838I 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
 - 
		AuthorPosts
 
You must be logged in to reply to this topic.
