- [Map Path] Now use default surface when no texture is provided.

This commit is contained in:
Tanasart 2024-07-10 14:30:29 +07:00
parent 759bbd7197
commit 82b45b8a50
6 changed files with 54 additions and 3 deletions

View file

@ -1382,6 +1382,7 @@
{"name":"sh_combine_rgb","order":11,"path":"shaders/sh_combine_rgb/sh_combine_rgb.yy",},
{"name":"sh_content_sampler","order":1,"path":"shaders/sh_content_sampler/sh_content_sampler.yy",},
{"name":"sh_convolution","order":23,"path":"shaders/sh_convolution/sh_convolution.yy",},
{"name":"sh_coord","order":30,"path":"shaders/sh_coord/sh_coord.yy",},
{"name":"sh_corner_erode","order":1,"path":"shaders/sh_corner_erode/sh_corner_erode.yy",},
{"name":"sh_corner_iterate","order":2,"path":"shaders/sh_corner_iterate/sh_corner_iterate.yy",},
{"name":"sh_cross_histogram","order":26,"path":"shaders/sh_cross_histogram/sh_cross_histogram.yy",},

View file

@ -1852,6 +1852,7 @@
{"id":{"name":"sh_combine_rgb","path":"shaders/sh_combine_rgb/sh_combine_rgb.yy",},},
{"id":{"name":"sh_content_sampler","path":"shaders/sh_content_sampler/sh_content_sampler.yy",},},
{"id":{"name":"sh_convolution","path":"shaders/sh_convolution/sh_convolution.yy",},},
{"id":{"name":"sh_coord","path":"shaders/sh_coord/sh_coord.yy",},},
{"id":{"name":"sh_corner_erode","path":"shaders/sh_corner_erode/sh_corner_erode.yy",},},
{"id":{"name":"sh_corner_iterate","path":"shaders/sh_corner_iterate/sh_corner_iterate.yy",},},
{"id":{"name":"sh_corner","path":"shaders/sh_corner/sh_corner.yy",},},

View file

@ -11,7 +11,7 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
inputs[| 2] = nodeValue("Texture", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
inputs[| 3] = nodeValue("Subdivision", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 16)
.setValidator(VV_min(1))
.setValidator(VV_min(2))
.rejectArray();
outputs[| 0] = nodeValue("Rendered", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
@ -20,6 +20,8 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
["Mapping", false], 1, 2, 3,
]
temp_surface = [ 0 ];
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
var _path = getInputData(0);
if(_path && struct_has(_path, "drawOverlay")) _path.drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny);
@ -35,10 +37,20 @@ function Node_Path_Map(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var _amo = _path.getLineCount();
if(!is_surface(_surf) || _amo < 2) return;
if(_amo < 2) return;
if(!is_surface(_surf)) {
temp_surface[0] = surface_verify(temp_surface[0], _dim[0], _dim[1]);
surface_set_shader(temp_surface[0], sh_coord);
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
surface_reset_shader()
_surf = temp_surface[0];
}
var _pnt = array_create(_amo + 1);
var _isb = 1 / _sub;
var _isb = 1 / (_sub - 1);
var _pp = new __vec2();
for( var i = 0; i < _amo; i++ ) {

View file

@ -0,0 +1,6 @@
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main() {
gl_FragColor = vec4( v_vTexcoord, 0., 1. );
}

View file

@ -0,0 +1,19 @@
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
v_vColour = in_Colour;
v_vTexcoord = in_TextureCoord;
}

View file

@ -0,0 +1,12 @@
{
"$GMShader":"",
"%Name":"sh_coord",
"name":"sh_coord",
"parent":{
"name":"generator",
"path":"folders/shader/generator.yy",
},
"resourceType":"GMShader",
"resourceVersion":"2.0",
"type":1,
}