• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Applying High Res Texture - Pixel Art

G

Gaveno

Guest
I have a view resolution of 240x135 and a view port of 1920x1080. This means that the graphics are actually displayed at the higher resolution.

When I draw a texture on top of the game window with the GUI layer using a subtract blend mode, I get this nice looking effect where the graphics look like they're on paper.
The problem is when the view scrolls, or an object moves, the moving elements look transparent since the texture location is fixed across the entire view, instead of individual objects.

Is there a way I can draw a texture on top of the pixel graphics, while keeping the texture high resolution?

Thank you.
 

CMAllen

Member
Perhaps a couple images to show what you want to achieve and one of how it looks when it's not working as you want?
 
G

Gaveno

Guest
I'm not sure the best way to add photos here. It won't let me put links I guess. But I don't think photos will really show it. Basically, right now I'm drawing an image over the entire view, but what I want to do is draw the image over individual sprites instead.

I think it may be possible with shaders since they operate at the actual resolution, but to do that I think I would need access to the texture sprite inside the shader while drawing the sprite I want the effect applied to.
 
T

TypoTigress

Guest
I'm not experienced with what you are trying to do exactly, but you may want to look at setting depths for your different elements, making sure this texture overlay you are doing is a much higher number than all others, if what you feel is happening is changes are coming up above that element. (IE, default depth for all elements is 0, while a higher positive number is going further into the background, and negative numbers coming closer to the view.)
https://docs.yoyogames.com/source/d...nces/instances/instance properties/depth.html
 
G

Gaveno

Guest
I figured out a way to make it work using shaders and samplers. It was sort of a pain, but every object that should have the texture applied to it just needs to render with the shader passing its top left corner along with it. I then scale the coordinates based on the scaling of the view port and the view width.
Here's the fragment shader for those that are curious.
Code:
// Fragment Shader
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

uniform sampler2D textToSubtract;
uniform vec2 u_uv;
uniform float scalar;

void main()
{
    vec2 pos = (v_vTexcoord - u_uv) * scalar;
    vec4 scol = texture2D(textToSubtract, pos);
    vec4 col = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord);
    col.rgb -= scol.rgb;

    gl_FragColor = col;
}
 
Top