Hi all,
I have a tile layer in my room that I want to use as a surface together with other layers in a shader.
In the object that sets the shader in the draw event, I have this in the create event to transfer the tile layer to a surface:
With the following scripts:
To test if the surface exists/looks correct, I have the following (among others) in the draw event of the object that sets the shader:
The surface is not shown.
I narrowed the problem down to the fact that if event_type == 0 {} is not executed in the SurfaceLayerReset function. In the SurfaceLayerSet function it is. This I don't understand.
A second thing I tried is to use if event_type == ev_draw_begin, so that the scripts are executed before the draw event with the shader.
This simply draws the tile layer in the room, but the surface still does not exist/is not drawn. This I don't understand either.
Is someone able to help me with this problem?
Many thanks in advance!
I have a tile layer in my room that I want to use as a surface together with other layers in a shader.
In the object that sets the shader in the draw event, I have this in the create event to transfer the tile layer to a surface:
GML:
SurfaceTileLayer = layer_get_id("LightingLayer");
layer_script_begin(SurfaceTileLayer, SurfaceLayerSet);
layer_script_end(SurfaceTileLayer, SurfaceLayerReset);
Code:
function SurfaceLayerSet(){
if event_type == ev_draw {
var ViewWidth = camera_get_view_width(view_camera[0])
var ViewHeight = camera_get_view_height(view_camera[0])
if (!surface_exists(global.ColDepLightSurSurface)) {
global.ColDepLightSurSurface = surface_create(ViewWidth,ViewHeight);
}
if event_number == 0 {
surface_set_target(global.ColDepLightSurSurface);
draw_clear_alpha(c_white, 0);
}
}
}
Code:
function SurfaceLayerReset(){
if event_type == ev_draw {
if event_number == 0 {
//draw_text(object0.x,object0.y,"Layer closed")
surface_reset_target();
}
}
}
Code:
draw_surface(global.ColDepLightSurSurface,viewx,viewy)
I narrowed the problem down to the fact that if event_type == 0 {} is not executed in the SurfaceLayerReset function. In the SurfaceLayerSet function it is. This I don't understand.
A second thing I tried is to use if event_type == ev_draw_begin, so that the scripts are executed before the draw event with the shader.
This simply draws the tile layer in the room, but the surface still does not exist/is not drawn. This I don't understand either.
Is someone able to help me with this problem?
Many thanks in advance!
Last edited: