GameMaker Old School Raster/Copper Bar on/over text effect possible?

Paul Green

Member
I've scoured the forums, I've scoured google, and I'm coming to the conclusion that shaders (which I don't know how to make) are how I'll have to go.

I'm looking to have some text on the screen, with each pixel line of text being a colour, and being able to cycle through them, like the old school demos a lot of us saw back in the day. (I'd specify the colours, to give me the copper bar effect, I believe Amiga's called it copper and C64's called it raster)

I've tried various commands with the draw_text_ext, colour, transformed and all those commands from the help files, tried even putting two objects on top of each other, and I was going to use the gpu_set_blendmode and put it on subtract, write the text to the object on the top 'thinking' it would have cut out the text, and I could have drawn lines of colour of the object below and see it through the text cut out, it was wishful thinking.

Are there any shaders already out in the wild that I can copy, obtain, use, to help me get this effect I desire. I'm in the process of 'cloning' an old game from the 80s and part of the game has that effect as you are entering your name on the high score, so I'd like to get it as close as possible.

Oh, if anybody is interested in the game I'm cloning, it's view-able/downloadable at

https://pjg-developments.com/?page_id=923
 

NightFrost

Member
So you want to simulate the Amiga copper processor's ability to manipulate color on every raster line? Then a shader is what you can use. For illustrative purposes, here is a simple fragment shader that will draw a gradient across the room space (gl_fragCoord). Set the roomHeight float appropriately and use it on a draw_rectangle that covers the room:
Code:
vec3 color1 = vec3(0.0, 0.0, 0.0);
vec3 color2 = vec3(1.0, 0.5, 0.25);
float roomHeight = 768.0;

void main(){
    float mixRatio = (gl_FragCoord.y / roomHeight);
    vec3 colorLine = mix(color1, color2, mixRatio);
    gl_FragColor = vec4(colorLine, 1.0);
}
To change color over time, you'd send the color information in as uniforms after manipulating their values in GML side, and also have the shader take the alpha from the sprite being drawn instead of just setting it to one.

EDIT: for more complex effects you'd use more math besides just a mix, but the fragCoord will tell you the current vertical position that can be used as base for that math.
 

nesrocks

Member
You can also draw it to a surface (using white), then create a sprite out of that surface, then draw sections of the sprite (1 px high) with a different color. Shader is way faster though.
 

Paul Green

Member
So you want to simulate the Amiga copper processor's ability to manipulate color on every raster line? Then a shader is what you can use. For illustrative purposes, here is a simple fragment shader that will draw a gradient across the room space (gl_fragCoord). Set the roomHeight float appropriately and use it on a draw_rectangle that covers the room:
Code:
vec3 color1 = vec3(0.0, 0.0, 0.0);
vec3 color2 = vec3(1.0, 0.5, 0.25);
float roomHeight = 768.0;

void main(){
    float mixRatio = (gl_FragCoord.y / roomHeight);
    vec3 colorLine = mix(color1, color2, mixRatio);
    gl_FragColor = vec4(colorLine, 1.0);
}
To change color over time, you'd send the color information in as uniforms after manipulating their values in GML side, and also have the shader take the alpha from the sprite being drawn instead of just setting it to one.

EDIT: for more complex effects you'd use more math besides just a mix, but the fragCoord will tell you the current vertical position that can be used as base for that math.
Yup, I'm guessing this is the way I want to go, I want each line of the text to have it's own colour, and then to be able to cycle through the colours, just like the post @HayManMarc put up above, as that is literally the thing I'm trying to copy, the high score entry from the old C64 Parallax, so it's commodore all the way, wether it's C64 or Amiga. :)

Guess I'm gonna have to do some research on shaders and how to use them, I'm don't feel I'm that advanced yet, but I'll try.
 

Paul Green

Member
So, I've scanned over the video tutorials, and after I scooped my brain back into my head, I'm thinking they are going to be too hard to learn for just one effect I need in the entire game, it looks like I'm going to need to use the co'ords and the in_position to get the y position of the pixel when I'm trying to draw the text, even then I don't think it would work on text, as it only seems to apply to sprites? (unless I'm mis-reading)

As I'm currently using @Pixelated_Pope Retro Pallette Swapper, I think the easiest solution is to draw the text that I need to cycle through the colours, recolour it by hand, and generate a cycle pallette, and use a pallette swap that way, and then just use a draw_text_transformed_colour on the 5 letters when you enter your name. [probably won't be noticable]

But I thank you all for the help/links and support and I'll will come back to shaders, I just don't need the learning curve slowing down my already long hobby time programming task at the minute. :)
 
Top