• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

GMS 2 Getting texture data in vertex shader?


I recently purchased GM:S 2 with plans to make a 2d-3d hybrid game for Windows. For the 3d portion I would need high-performance 3D dynamic height maps as I'd like to maximize rendering speed.
Rendering a static heightmap is no issue for me, but I want it dynamic.

I experimented with shaders and they seemed very promising for the job. I managed to alter vertices' z-values with random values and have virtually no FPS hit.
The issue is that I can't figure out how to pass the actual heightmap values into the Vertex Shader.
One solution would have been to pass the heightmap texture or 2d array into the Vertex Shader. It seemed this is not possible in GM:S 2?

I found no working examples online. I noticed some old threads that mentioned that a .dll is needed to get texture data in the vertex shader. For example here is a Similar issue
Note that I am new to shaders. Did I just miss something, or is there a .dll or some extension I can use? Anyone have experience in this?


Joe Ellis

It's called vertex texture fetching, I have a dll that can do this, it basically loads the texture from a png in a different format to how it usually does and then uses another "set" function to pass it to the vertex shader.
This might seem like the perfect solution, but you can't edit the texture dynamically, you can only offset the uvs or do something with uniforms to make it read the texture differently, but the pixels on the texture can't be changed. So that ruins the whole thing you want to do.
Are you trying to do a similar thing to Populous 3? Cus that is definitely possible by splitting the terrain into smaller pieces, then you can rebuild small vertex buffers with only 12 quads or so without any lag

Joe Ellis

Yeah I'll send it you if you want. It is good for what it does.. You'll have to wait a day or two, it's buried somewhere