qertbuilding.blogg.se

Gamemakerr portals or screen wrap
Gamemakerr portals or screen wrap




  1. GAMEMAKERR PORTALS OR SCREEN WRAP HOW TO
  2. GAMEMAKERR PORTALS OR SCREEN WRAP CODE

You can grab any Normal Map and input it into this shader and it will work just fine, they are also much easier to find online so I'm keeping this format as close as I can to regular Normal Maps used for lighting. I've been calling these lens images Normal Maps in my mind, however they are technically not Normal Maps. How does it preform? It really doesn't have much of an impact, and while there might be a small overhead it doesn't increase much with huge numbers of simultaneous distortions. So you can see this is a really easy way to add shockwaves to your GameMaker game or just bend the screen and use warping to add more juice to your projects like cool water effects, impact ripples, glass effects, magnified glass zoom in/out. surface_distort is the name I gave to the surface that has information about where every pixel should offset where it selects it's colour from. The important part is texture_set_stage() we use this to pass the surface into the shader so it can read the information on it. You can replace spr_example_distort with as many bending images and changes as you like. Whatever you draw to the Surface will now distort the screen, you can draw as many distortions on it as you like and those can have different amounts of opacity (which would end up changing the magnitude of the warping). Surface_free(surface_distort) // always remember to remove the surface from memory Texture_set_stage(distortion_stage, surface_texture_page) Var surface_texture_page = surface_get_texture(surface_distort) Anything we draw here will distort the screenĭraw_sprite(spr_example_distort,0,500,500) Surface_distort = surface_create(room_width,room_height) name of what you want it to be called in the shaderĭistortion_stage = shader_get_sampler_index(shader_fullscreen, "distortion_texture_page") Now that we have the shader we need to apply it to something Gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord+distort_amount) If (distort_amount.x > 0.5) // wrap around

gamemakerr portals or screen wrap

normal maps have green pointing the wrong way)ĭistort_amount.x = 1.0 - distort_amount.x while you dont need to worry about it in GM more FOR NORMAL MAPS: ( either directX or OpenGL flip the green channel, Vec2 distort_amount = vec2( (v_vColour * texture2D( distortion_texture_page, v_vTexcoord)).xy) find the offset colour for this location (this is where the magic happens) Uniform sampler2D distortion_texture_page // the name of the surface in the shader

gamemakerr portals or screen wrap gamemakerr portals or screen wrap gamemakerr portals or screen wrap

This shader will look at the surface and for every pixel on the surface the colour will tell the shader where to offset when selecting what colour to draw.

GAMEMAKERR PORTALS OR SCREEN WRAP CODE

We will only be using the Fragment Shader which in GameMaker is the second tab along, this code runs on the graphics card for every pixel on the screen. This works just like a lens.įirst we are going to make a new shader with Alt+A and you will notice it comes as two files, the Vertex Shader and the Fragment Shader. The concept is very simple, we are going to pass a Surface into the shader with all the information about where each pixel should actually draw to the screen.

GAMEMAKERR PORTALS OR SCREEN WRAP HOW TO

Today I will show you how to make a shader to warp your screen and add ripples and other distortions to your games. I know shaders can seem like a scary world for some however in just a few lines of code I want to give you an easy to implement and impressive shader that will be a great starting point for learning your first shader.






Gamemakerr portals or screen wrap