• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 draw surface pos

zendraw

Member
i noticed there is no draw_surface_pos function? so my question is can i somehow make that happen? basicly i want to draw a surface with the top end squished in creating the illusion of 3d. there is the option of making the surface a sprite, but i will be drawing on the surface every frame, so dont think that is an option.
 

CMAllen

Member
i noticed there is no draw_surface_pos function? so my question is can i somehow make that happen? basicly i want to draw a surface with the top end squished in creating the illusion of 3d. there is the option of making the surface a sprite, but i will be drawing on the surface every frame, so dont think that is an option.
It should be noted this will not have the effect you're hoping. That's because of the way the texture will be drawn and stretched across the two triangles. There will be a visible seam where the two tris are joined to form the polygon where you can see the differences in their respective stretching. I know this isn't intuitive, but the way the actual hardware handles the math isn't as straightforward. Here is an image to help you understand.

SkewSeams.jpg

As long as the two separate sides of the polygon are both of the same length (height-height and width-width) it'll map uniformly across the surface. But as soon as either part of the sets aren't the same size, the image texture will no longer uniformly map across the surface. The greater the difference between them, the more pronounced the distortion will get.
 

CMAllen

Member
i havent yet tryed, are you certain this is absolutely true? if it is i wont even bother...
Unfortunately, this is how *all* 3d engines work. Each triangle is effectively 1/2 of a rectangle (or, in 3d terms, a quad). When two pairs of sides aren't parallel (image on the right, previous post) they are mapping across two differently sized rectangles. The top-most triangle is mapped to a narrow rectangle skewed to the right, while the lower triangle is mapped to a wider rectangle skewed to the left. Two differently formed shapes are stuck together along a parallel angle, with no interpolation between those two different shapes. Which presents as a very visible seam.

There are ways around this, but none of them are simple or straightforward, and all of them will require taking more direct and low-level control over the drawing pipeline to utilize.
 

mikix

Member
Use vertex for this and some math. There is also a nice vertex extension on the marketplace, that already has the math. From there on, you can maybe twist it to your liking, add some stuff and so on. That's what I did for my painting software which can draw fake 3D to the surface.
 
Top