staticskizzles
Member
Hello,
GMS 2.3.1
I'm using this depth sorting system:
I am trying ot make it work with this asset (which utilizes vertex buffers):
I'll be honest I don't know much about vertex buffers so I apolagies if I say anything incorrectly in regards to vertex buffers.
If I try and use this asset with the depth sorter, it always remains infront of eveything, no depth when trying ot move obj_player behind the grass. The asset works like a charm with my game when I avoid this depth system, and revert to the usual depth=-y;, however I am inclined to carry on using this depth sorting system in order to avoid any issues in the future such as flickering (which I assume happens when two sprites are on the same y value).
This is the code for the depth sorter incase anyone wants a closer look at it.:
Specifically the Draw event of the object "depthsorter".
I've tried using debug code that came with the asset such as gpu_set_ztestenable(true), as well as doing the obvious: making obj_vertexgrass a child of par_depthobject.
I'm unsure how to add vertex buffers / grass from the asset to to the sorter. I can only assume that they appear in the room layer "Instances" because how else would depth=-y work.
However (correct me if I'm wrong) these "vertex buffers" or "grass" clearly don't have par_depthobject as a parent since they're not being ordered, they must be being created without a parent, so unless I can set the parent of each grass vertex in the shader, I may need to find a way to make the depth sorter sort everything in the Instance layer, and not be restricted to children of the par_depthobject. The easy way out is to not use the depth sorter and just simply stick to depth=-y; but I feel like thats also the worst way to do it.
I apolagies if this one is a head scratcher, I've tried to break it down as much as possible. Help would be very much appreciated.
GMS 2.3.1
I'm using this depth sorting system:
Depth Sorting for GMS2 (Alternative to "depth = -y")
GM Version: GameMaker Studio 2 Download: Example File Links: Asset on Marketplace Summary: In GMS1, "depth = -y" served as a simple, fast, dependable way to sort depth dynamically, especially for beginners. In GMS2, with the introduction of layers, it's easy to run into some trouble with this...
forum.yoyogames.com
Depth-Based Grass with Wind by Gurpreet Singh Matharoo | GameMaker: Marketplace
marketplace.yoyogames.com
If I try and use this asset with the depth sorter, it always remains infront of eveything, no depth when trying ot move obj_player behind the grass. The asset works like a charm with my game when I avoid this depth system, and revert to the usual depth=-y;, however I am inclined to carry on using this depth sorting system in order to avoid any issues in the future such as flickering (which I assume happens when two sprites are on the same y value).
This is the code for the depth sorter incase anyone wants a closer look at it.:
Specifically the Draw event of the object "depthsorter".
Code:
// MAKE SURE TO UNTICK VISIBLE FOR ALL OBJECTS BEING SORTED (CHILDREN OF THIS)
var inst_num = instance_number(par_depthobject);
var dgrid = ds_depthgrid;
if ds_grid_height(dgrid) != inst_num {
ds_grid_resize(dgrid, 2, inst_num);
}
// add instances to grid
var yy = 0; with (par_depthobject) {
dgrid[# 0, yy] = id;
dgrid[# 1, yy]= y
yy += 1;
}
// Sort grid in acsending order
ds_grid_sort(dgrid, 1, true);
// loop through grid and draw instances
var inst; yy = 0; repeat(inst_num) {
// pull current id
inst = dgrid[# 0, yy];
// draw
with (inst) {
event_perform(ev_draw, 0);
}
yy += 1;
}
I'm unsure how to add vertex buffers / grass from the asset to to the sorter. I can only assume that they appear in the room layer "Instances" because how else would depth=-y work.
However (correct me if I'm wrong) these "vertex buffers" or "grass" clearly don't have par_depthobject as a parent since they're not being ordered, they must be being created without a parent, so unless I can set the parent of each grass vertex in the shader, I may need to find a way to make the depth sorter sort everything in the Instance layer, and not be restricted to children of the par_depthobject. The easy way out is to not use the depth sorter and just simply stick to depth=-y; but I feel like thats also the worst way to do it.
I apolagies if this one is a head scratcher, I've tried to break it down as much as possible. Help would be very much appreciated.