[Normal light] improvement
@ -1620,6 +1620,7 @@
|
||||
{"name":"sh_noise_strand","order":10,"path":"shaders/sh_noise_strand/sh_noise_strand.yy",},
|
||||
{"name":"sh_noise_wavelet","order":11,"path":"shaders/sh_noise_wavelet/sh_noise_wavelet.yy",},
|
||||
{"name":"sh_noise","order":1,"path":"shaders/sh_noise/sh_noise.yy",},
|
||||
{"name":"sh_normal_light_apply","order":5,"path":"shaders/sh_normal_light_apply/sh_normal_light_apply.yy",},
|
||||
{"name":"sh_normal_light","order":1,"path":"shaders/sh_normal_light/sh_normal_light.yy",},
|
||||
{"name":"sh_normalize","order":23,"path":"shaders/sh_normalize/sh_normalize.yy",},
|
||||
{"name":"sh_offset","order":12,"path":"shaders/sh_offset/sh_offset.yy",},
|
||||
@ -2297,6 +2298,7 @@
|
||||
{"name":"s_node_noise_perlin","order":11,"path":"sprites/s_node_noise_perlin/s_node_noise_perlin.yy",},
|
||||
{"name":"s_node_noise_simplex","order":20,"path":"sprites/s_node_noise_simplex/s_node_noise_simplex.yy",},
|
||||
{"name":"s_node_noise","order":8,"path":"sprites/s_node_noise/s_node_noise.yy",},
|
||||
{"name":"s_node_normal_light_type","order":29,"path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},
|
||||
{"name":"s_node_normal_light","order":37,"path":"sprites/s_node_normal_light/s_node_normal_light.yy",},
|
||||
{"name":"s_node_normal","order":36,"path":"sprites/s_node_normal/s_node_normal.yy",},
|
||||
{"name":"s_node_normalize","order":62,"path":"sprites/s_node_normalize/s_node_normalize.yy",},
|
||||
|
@ -2302,6 +2302,7 @@
|
||||
{"id":{"name":"sh_noise_strand","path":"shaders/sh_noise_strand/sh_noise_strand.yy",},},
|
||||
{"id":{"name":"sh_noise_wavelet","path":"shaders/sh_noise_wavelet/sh_noise_wavelet.yy",},},
|
||||
{"id":{"name":"sh_noise","path":"shaders/sh_noise/sh_noise.yy",},},
|
||||
{"id":{"name":"sh_normal_light_apply","path":"shaders/sh_normal_light_apply/sh_normal_light_apply.yy",},},
|
||||
{"id":{"name":"sh_normal_light","path":"shaders/sh_normal_light/sh_normal_light.yy",},},
|
||||
{"id":{"name":"sh_normal","path":"shaders/sh_normal/sh_normal.yy",},},
|
||||
{"id":{"name":"sh_normalize","path":"shaders/sh_normalize/sh_normalize.yy",},},
|
||||
@ -3035,6 +3036,7 @@
|
||||
{"id":{"name":"s_node_noise_perlin","path":"sprites/s_node_noise_perlin/s_node_noise_perlin.yy",},},
|
||||
{"id":{"name":"s_node_noise_simplex","path":"sprites/s_node_noise_simplex/s_node_noise_simplex.yy",},},
|
||||
{"id":{"name":"s_node_noise","path":"sprites/s_node_noise/s_node_noise.yy",},},
|
||||
{"id":{"name":"s_node_normal_light_type","path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},},
|
||||
{"id":{"name":"s_node_normal_light","path":"sprites/s_node_normal_light/s_node_normal_light.yy",},},
|
||||
{"id":{"name":"s_node_normal","path":"sprites/s_node_normal/s_node_normal.yy",},},
|
||||
{"id":{"name":"s_node_normalize","path":"sprites/s_node_normalize/s_node_normalize.yy",},},
|
||||
|
@ -113,3 +113,13 @@ function draw_anchor_line(_index, _x, _y, _r, _a, _type = 0) {
|
||||
draw_sprite_stretched(s_fx_pixel, 0, _x - _r, _y - _r, _r * 2, _r * 2);
|
||||
shader_reset();
|
||||
}
|
||||
|
||||
function draw_empty() {
|
||||
var _s = surface_get_target();
|
||||
if(_s == -1) return;
|
||||
|
||||
var _w = surface_get_width(_s);
|
||||
var _h = surface_get_height(_s);
|
||||
|
||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _w, _h);
|
||||
}
|
@ -40,10 +40,10 @@
|
||||
globalvar HOTKEYS, HOTKEY_CONTEXT;
|
||||
|
||||
LATEST_VERSION = 1_18_00;
|
||||
VERSION = 1_18_00_0;
|
||||
VERSION = 1_18_01_0;
|
||||
SAVE_VERSION = 1_18_00_0;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.1.002";
|
||||
BUILD_NUMBER = 1_18_00_1;
|
||||
VERSION_STRING = MAC? "1.18.003m" : "1.18.1.004";
|
||||
BUILD_NUMBER = 1_18_00_4;
|
||||
|
||||
HOTKEYS = ds_map_create();
|
||||
HOTKEY_CONTEXT = ds_list_create();
|
||||
|
@ -122,7 +122,8 @@ function Node_2D_light(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
|
||||
var _ind = input_fix_len + i * data_length;
|
||||
var _typ = current_data[_ind + 0];
|
||||
var cc = i == dynamic_input_inspecting? COLORS._main_text_accent : COLORS._main_icon;
|
||||
var _col = current_data[_ind + 4];
|
||||
|
||||
var tc = i == dynamic_input_inspecting? COLORS._main_text_accent : COLORS._main_icon;
|
||||
var hov = _hover && point_in_rectangle(_m[0], _m[1], _x0, _yy - lh / 2, _x1, _yy + lh / 2 - 1);
|
||||
|
||||
@ -135,7 +136,7 @@ function Node_2D_light(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
}
|
||||
}
|
||||
|
||||
draw_sprite_ext(s_node_2d_light_shape, _typ, _x0 + ui(8), _yy, 1, 1, 0, cc);
|
||||
draw_sprite_ext(s_node_2d_light_shape, _typ, _x0 + ui(8), _yy, 1, 1, 0, _col, .5 + .5 * (i == dynamic_input_inspecting));
|
||||
|
||||
draw_set_text(f_p2, fa_left, fa_center, tc);
|
||||
draw_text_add(_x0 + ui(28), _yy, typeListStr[_typ]);
|
||||
@ -163,12 +164,12 @@ function Node_2D_light(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||
|
||||
input_display_list = [ 0, lights_renderer ];
|
||||
|
||||
attribute_surface_depth();
|
||||
temp_surface = [ 0, 0, 0 ];
|
||||
|
||||
setDynamicInput(22, false);
|
||||
if(!LOADING && !APPENDING) createNewInput();
|
||||
|
||||
attribute_surface_depth();
|
||||
temp_surface = [ 0, 0, 0 ];
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
PROCESSOR_OVERLAY_CHECK
|
||||
|
||||
|
@ -5,77 +5,236 @@ function Node_Normal_Light(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||
|
||||
newInput(1, nodeValue_Surface("Normal map", self));
|
||||
|
||||
newInput(2, nodeValue_Float("Normal intensity", self, 1));
|
||||
newInput(2, nodeValue_Float("Height", self, 1));
|
||||
|
||||
newInput(3, nodeValue_Color("Ambient", self, c_black));
|
||||
|
||||
newInput(4, nodeValue_Vec2("Light position", self, [ 0, 0 ]))
|
||||
.setUnitRef(function(index) { return getDimension(index); });
|
||||
newInput(4, nodeValue_Surface("Height map", self));
|
||||
|
||||
newInput(5, nodeValue_Float("Light range", self, 16));
|
||||
typeList = [
|
||||
new scrollItem("Point", s_node_normal_light_type, 0),
|
||||
new scrollItem("Sun", s_node_normal_light_type, 1),
|
||||
new scrollItem("Line", s_node_normal_light_type, 2),
|
||||
new scrollItem("Spot", s_node_normal_light_type, 3),
|
||||
];
|
||||
typeListStr = array_create_ext(array_length(typeList), function(i) /*=>*/ {return typeList[i].name});
|
||||
|
||||
newInput(6, nodeValue_Float("Light intensity", self, 32));
|
||||
static createNewInput = function() {
|
||||
var _index = array_length(inputs);
|
||||
dynamic_input_inspecting = getInputAmount();
|
||||
|
||||
newInput(7, nodeValue_Color("Light color", self, c_white));
|
||||
newInput(_index + 0, nodeValue_Enum_Scroll("Type", self, 0, typeList));
|
||||
|
||||
newInput(8, nodeValue_Enum_Button("Light type", self, 0, ["Point", "Sun"]));
|
||||
newInput(_index + 1, nodeValue_Vec3("Position", self, [ 0, 0, 1 ]))
|
||||
.setUnitRef(function(index) /*=>*/ {return getDimension(index)});
|
||||
|
||||
newInput(9, nodeValue_Bool("Active", self, true));
|
||||
active_index = 9;
|
||||
newInput(_index + 2, nodeValue_Float("Range", self, 16));
|
||||
inputs[_index + 2].overlay_text_valign = fa_bottom;
|
||||
|
||||
newInput(10, nodeValue_Float("Light height", self, 1));
|
||||
newInput(_index + 3, nodeValue_Float("Intensity", self, 4));
|
||||
|
||||
input_display_list = [ 9, 0,
|
||||
["Normal", false], 1, 2,
|
||||
["Light", false], 3, 8, 4, 10, 5, 6, 7
|
||||
newInput(_index + 4, nodeValue_Color("Color", self, c_white));
|
||||
|
||||
newInput(_index + 5, nodeValue_Vec3("End Position", self, [ 0, 0, 1 ]))
|
||||
.setUnitRef(function(index) /*=>*/ {return getDimension(index)});
|
||||
|
||||
newInput(_index + 6, nodeValue_Color("End Color", self, c_white));
|
||||
|
||||
refreshDynamicDisplay();
|
||||
return inputs[_index];
|
||||
}
|
||||
|
||||
lights_renderer = new Inspector_Custom_Renderer(function(_x, _y, _w, _m, _hover, _focus) {
|
||||
|
||||
var bs = ui(24);
|
||||
var bx = _x + ui(20);
|
||||
var by = _y;
|
||||
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, _m, _focus, _hover, "", THEME.add_16, 0, COLORS._main_value_positive) == 2) {
|
||||
createNewInput();
|
||||
triggerRender();
|
||||
}
|
||||
|
||||
var amo = getInputAmount();
|
||||
var lh = ui(28);
|
||||
var _h = ui(12) + lh * amo;
|
||||
var yy = _y + bs + ui(4);
|
||||
|
||||
var del_light = -1;
|
||||
draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, yy, _w, _h, COLORS.node_composite_bg_blend, 1);
|
||||
|
||||
for(var i = 0; i < amo; i++) {
|
||||
var _x0 = _x + ui(24);
|
||||
var _x1 = _x + _w - ui(16);
|
||||
var _yy = ui(6) + yy + i * lh + lh / 2;
|
||||
|
||||
var _ind = input_fix_len + i * data_length;
|
||||
var _typ = current_data[_ind + 0];
|
||||
var _col = current_data[_ind + 4];
|
||||
|
||||
var tc = i == dynamic_input_inspecting? COLORS._main_text_accent : COLORS._main_icon;
|
||||
var hov = _hover && point_in_rectangle(_m[0], _m[1], _x0, _yy - lh / 2, _x1, _yy + lh / 2 - 1);
|
||||
|
||||
if(hov && _m[0] < _x1 - ui(32)) {
|
||||
tc = COLORS._main_text;
|
||||
|
||||
if(mouse_press(mb_left, _focus)) {
|
||||
dynamic_input_inspecting = i;
|
||||
refreshDynamicDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
draw_sprite_ext(s_node_normal_light_type, _typ, _x0 + ui(8), _yy, 1, 1, 0, _col, .5 + .5 * (i == dynamic_input_inspecting));
|
||||
|
||||
draw_set_text(f_p2, fa_left, fa_center, tc);
|
||||
draw_text_add(_x0 + ui(28), _yy, typeListStr[_typ]);
|
||||
|
||||
if(amo > 1) {
|
||||
var bs = ui(24);
|
||||
var bx = _x1 - bs;
|
||||
var by = _yy - bs / 2;
|
||||
if(buttonInstant(THEME.button_hide, bx, by, bs, bs, _m, _focus, _hover, "", THEME.minus_16, 0, hov? COLORS._main_value_negative : COLORS._main_icon) == 2)
|
||||
del_light = i;
|
||||
}
|
||||
}
|
||||
|
||||
if(del_light > -1)
|
||||
deleteDynamicInput(del_light);
|
||||
|
||||
return ui(32) + _h;
|
||||
});
|
||||
|
||||
input_display_dynamic = [ // 14,
|
||||
0, 1, 5, 2,
|
||||
3, 4, 6,
|
||||
];
|
||||
|
||||
input_display_list = [
|
||||
["Input", false], 0, 1, 3,
|
||||
new Inspector_Spacer(8, true),
|
||||
new Inspector_Spacer(2, false, false),
|
||||
lights_renderer,
|
||||
["Lights", false],
|
||||
];
|
||||
|
||||
setDynamicInput(7, false);
|
||||
if(!LOADING && !APPENDING) createNewInput();
|
||||
|
||||
newOutput(0, nodeValue_Output("Surface out", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
newOutput(1, nodeValue_Output("Light only", self, VALUE_TYPE.surface, noone));
|
||||
|
||||
attribute_surface_depth();
|
||||
|
||||
static drawOverlay = function(hover, active, _x, _y, _s, _mx, _my, _snx, _sny) {
|
||||
PROCESSOR_OVERLAY_CHECK
|
||||
|
||||
var pos = current_data[4];
|
||||
if(getInputAmount() == 0) return;
|
||||
|
||||
dynamic_input_inspecting = clamp(dynamic_input_inspecting, 0, getInputAmount() - 1);
|
||||
var _ind = input_fix_len + dynamic_input_inspecting * data_length;
|
||||
|
||||
var typ = current_data[_ind + 0];
|
||||
var pos = current_data[_ind + 1];
|
||||
var rad = current_data[_ind + 2];
|
||||
var px = _x + pos[0] * _s;
|
||||
var py = _y + pos[1] * _s;
|
||||
var _hov = false;
|
||||
|
||||
var hv = inputs[4].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv;
|
||||
var hv = inputs[5].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); _hov |= hv;
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_set_alpha(0.5);
|
||||
draw_circle_dash(px, py, rad * _s, 1, 8);
|
||||
draw_set_alpha(1);
|
||||
|
||||
if(typ == 2 || typ == 3) {
|
||||
if(typ == 2) {
|
||||
var p2 = current_data[_ind + 5];
|
||||
var px2 = _x + p2[0] * _s;
|
||||
var py2 = _y + p2[1] * _s;
|
||||
|
||||
draw_set_color(COLORS._main_accent);
|
||||
draw_line(px, py, px2, py2);
|
||||
}
|
||||
|
||||
var hv = inputs[_ind + 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; hover &= !hv;
|
||||
var hv = inputs[_ind + 2].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); _hov |= hv; hover &= !hv;
|
||||
var hv = inputs[_ind + 5].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; hover &= !hv;
|
||||
|
||||
} else {
|
||||
var hv = inputs[_ind + 1].drawOverlay(hover, active, _x, _y, _s, _mx, _my, _snx, _sny); _hov |= hv; hover &= !hv;
|
||||
var hv = inputs[_ind + 2].drawOverlay(hover, active, px, py, _s, _mx, _my, _snx, _sny); _hov |= hv; hover &= !hv;
|
||||
}
|
||||
|
||||
return _hov;
|
||||
}
|
||||
|
||||
static processData = function(_outSurf, _data, _output_index, _array_index) {
|
||||
static applyLight = function(_data, _dim, _ind, _ligSurf) {
|
||||
var _map = _data[1];
|
||||
var _hei = _data[2];
|
||||
var _amb = _data[3];
|
||||
var _hmap = _data[4];
|
||||
|
||||
var _light_pos = _data[ 4];
|
||||
var _light_ran = _data[ 5];
|
||||
var _light_int = _data[ 6];
|
||||
var _light_col = _data[ 7];
|
||||
var _light_typ = _data[ 8];
|
||||
var _light_hei = _data[10];
|
||||
var _light_typ = _data[_ind + 0];
|
||||
var _light_pos = _data[_ind + 1];
|
||||
var _light_ran = _data[_ind + 2];
|
||||
var _light_int = _data[_ind + 3];
|
||||
var _light_col = _data[_ind + 4];
|
||||
var _light_ps2 = _data[_ind + 5];
|
||||
var _light_cl2 = _data[_ind + 6];
|
||||
|
||||
var _dim = surface_get_dimension(_data[0]);
|
||||
|
||||
surface_set_shader(_outSurf, sh_normal_light);
|
||||
surface_set_shader(_ligSurf, sh_normal_light, false, BLEND.add);
|
||||
shader_set_surface("normalMap", _map);
|
||||
shader_set_surface("heightMap", _hmap);
|
||||
shader_set_i("useHeightMap", is_surface(_hmap));
|
||||
shader_set_f("normalHeight", _hei);
|
||||
shader_set_f("dimension", _dim);
|
||||
shader_set_color("ambiance", _amb);
|
||||
|
||||
shader_set_f("lightPosition", _light_pos[0], _light_pos[1], -_light_hei / 100, _light_ran );
|
||||
shader_set_color("lightColor", _light_col);
|
||||
shader_set_f("lightIntensity", _light_int);
|
||||
shader_set_i("lightType", _light_typ);
|
||||
shader_set_f("lightPosition", _light_pos[0], _light_pos[1], -_light_pos[2] / 100, _light_ran );
|
||||
shader_set_f("lightPosition2", _light_ps2[0], _light_ps2[1], -_light_ps2[2] / 100, _light_ran );
|
||||
|
||||
draw_surface_safe(_data[0]);
|
||||
shader_set_f("lightIntensity", _light_int);
|
||||
shader_set_color("lightColor", _light_col);
|
||||
shader_set_color("lightColor2", _light_cl2);
|
||||
|
||||
draw_empty();
|
||||
surface_reset_shader();
|
||||
|
||||
return _outSurf;
|
||||
}
|
||||
|
||||
static processData = function(_outData, _data, _output_index, _array_index) {
|
||||
var _surf = _data[0];
|
||||
var _amb = _data[3];
|
||||
var _dim = surface_get_dimension(_surf);
|
||||
|
||||
if(getInputAmount()) {
|
||||
dynamic_input_inspecting = clamp(dynamic_input_inspecting, 0, getInputAmount() - 1);
|
||||
var _ind = input_fix_len + dynamic_input_inspecting * data_length;
|
||||
|
||||
var _ltype = _data[_ind + 0];
|
||||
|
||||
inputs[_ind + 5].setVisible(_ltype == 2 || _ltype == 3);
|
||||
inputs[_ind + 6].setVisible(_ltype == 2);
|
||||
}
|
||||
|
||||
var _outSurf = surface_verify(_outData[0], _dim[0], _dim[1]);
|
||||
var _ligSurf = surface_verify(_outData[1], _dim[0], _dim[1]);
|
||||
|
||||
surface_set_target(_ligSurf);
|
||||
draw_clear(c_black);
|
||||
surface_reset_target();
|
||||
|
||||
for( var i = 0; i < getInputAmount(); i++ ) {
|
||||
var _ind = input_fix_len + i * data_length;
|
||||
applyLight(_data, _dim, _ind, _ligSurf);
|
||||
}
|
||||
|
||||
surface_set_shader(_outSurf, sh_normal_light_apply);
|
||||
shader_set_surface("baseSurface", _surf);
|
||||
shader_set_surface("lightSurface", _ligSurf);
|
||||
shader_set_color("ambient", _amb);
|
||||
|
||||
draw_empty();
|
||||
surface_reset_shader();
|
||||
|
||||
return [ _outSurf, _ligSurf ];
|
||||
}
|
||||
}
|
@ -569,19 +569,27 @@ function nodeValueUnit(_nodeValue) constructor {
|
||||
];
|
||||
}
|
||||
|
||||
var _len = array_length(value);
|
||||
|
||||
switch(disp) {
|
||||
case VALUE_DISPLAY.padding :
|
||||
case VALUE_DISPLAY.vector :
|
||||
case VALUE_DISPLAY.vector_range :
|
||||
var _val = array_create(array_length(value));
|
||||
var _val = array_clone(_len, 1);
|
||||
|
||||
for( var i = 0, n = array_length(value); i < n; i++ )
|
||||
if(_len % 2 == 0) {
|
||||
for( var i = 0, n = _len; i < n; i++ )
|
||||
_val[i] = is_real(value[i])? value[i] * base[i % 2] : value[i];
|
||||
|
||||
} else if(_len > 2) {
|
||||
_val[0] = is_real(value[0])? value[0] * base[0] : value[0];
|
||||
_val[1] = is_real(value[1])? value[1] * base[1] : value[1];
|
||||
}
|
||||
|
||||
return _val;
|
||||
|
||||
case VALUE_DISPLAY.area :
|
||||
var _val = array_create(array_length(value));
|
||||
var _val = array_create(_len);
|
||||
|
||||
for( var i = 0; i < 4; i++ )
|
||||
_val[i] = is_real(value[i])? value[i] * base[i % 2] : value[i];
|
||||
|
@ -1,49 +1,79 @@
|
||||
//
|
||||
// Simple passthrough fragment shader
|
||||
//
|
||||
#define TAU 6.28318530718
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
#define pi1 3.14159
|
||||
#define pi2 1.57079
|
||||
|
||||
uniform vec2 dimension;
|
||||
|
||||
uniform sampler2D normalMap;
|
||||
uniform sampler2D heightMap;
|
||||
uniform int useHeightMap;
|
||||
uniform float normalHeight;
|
||||
|
||||
uniform vec4 ambiance;
|
||||
uniform int lightType;
|
||||
uniform vec4 lightPosition;
|
||||
uniform vec4 lightColor;
|
||||
uniform vec4 lightPosition2;
|
||||
|
||||
uniform float lightIntensity;
|
||||
uniform vec4 lightColor;
|
||||
uniform vec4 lightColor2;
|
||||
|
||||
uniform float spotRadius;
|
||||
|
||||
vec3 closestPointOnLine(vec3 P, vec3 A, vec3 B, out float t) {
|
||||
vec3 AP = P - A;
|
||||
vec3 AB = B - A;
|
||||
t = dot(AP, AB) / dot(AB, AB);
|
||||
t = clamp(t, 0.0, 1.0);
|
||||
return A + t * AB;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 base_color = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
vec3 normal = normalize(texture2D( normalMap, v_vTexcoord ).rgb * -2.0 + 1.0) * normalHeight;
|
||||
float aspect = dimension.x / dimension.y;
|
||||
vec3 normal = texture2D( normalMap, v_vTexcoord ).rgb * -2.0 + 1.0;
|
||||
normal = normalize(normal);
|
||||
|
||||
vec3 result = ambiance.rgb * base_color.rgb;
|
||||
vec3 hsamp = texture2D( heightMap, v_vTexcoord ).rgb;
|
||||
float h = useHeightMap == 1? (hsamp.r + hsamp.g + hsamp.b) / 3. * normalHeight : 0.;
|
||||
|
||||
vec3 lightPos = vec3(lightPosition.x / dimension.x, lightPosition.y / dimension.y, lightPosition.z);
|
||||
float attenuation = lightIntensity;
|
||||
|
||||
float range = lightPosition.a / max(dimension.x, dimension.y);
|
||||
vec3 curr = vec3(v_vTexcoord.x, v_vTexcoord.y, h);
|
||||
vec3 lightDir;
|
||||
vec3 diffuse;
|
||||
vec4 lightClr = lightColor;
|
||||
|
||||
if(lightType == 0) {
|
||||
attenuation *= max(1. - sqrt( pow(v_vTexcoord.x - lightPos.x, 2.) + pow((v_vTexcoord.y - lightPos.y) / aspect, 2.)) / range, 0.);
|
||||
lightDir = normalize(lightPos - vec3(v_vTexcoord.x, v_vTexcoord.y, 0.));
|
||||
} else {
|
||||
vec3 lig = lightPos - curr;
|
||||
lightDir = normalize(lig);
|
||||
attenuation *= 1. - length(lig) / range;
|
||||
|
||||
} else if(lightType == 1) {
|
||||
lightDir = normalize(lightPos - vec3(0.5, 0.5, 0.));
|
||||
|
||||
} else if(lightType == 2) {
|
||||
float t = 0.;
|
||||
vec3 lightPos2 = vec3(lightPosition2.x / dimension.x, lightPosition2.y / dimension.y, lightPosition2.z);
|
||||
vec3 lightPosC = closestPointOnLine(curr, lightPos, lightPos2, t);
|
||||
|
||||
vec3 lig = lightPosC - curr;
|
||||
lightDir = normalize(lig);
|
||||
attenuation *= 1. - length(lig) / range;
|
||||
lightClr = mix(lightColor, lightColor2, t);
|
||||
|
||||
} else if(lightType == 3) {
|
||||
vec3 lightPos2 = vec3(lightPosition2.x / dimension.x, lightPosition2.y / dimension.y, lightPosition2.z);
|
||||
vec3 spotDir = normalize(lightPos - lightPos2);
|
||||
vec3 lig = lightPos - curr;
|
||||
|
||||
lightDir = normalize(lig);
|
||||
attenuation *= 1. - acos(dot(spotDir, lightDir)) / range;
|
||||
}
|
||||
|
||||
float d = max(dot(normal, lightDir), 0.0);
|
||||
vec3 diffuse = d * lightColor.rgb * lightColor.a * base_color.rgb * attenuation;
|
||||
result += diffuse;
|
||||
result.r = min(result.r, base_color.r);
|
||||
result.g = min(result.g, base_color.g);
|
||||
result.b = min(result.b, base_color.b);
|
||||
|
||||
gl_FragColor = vec4(result, base_color.a);
|
||||
diffuse = d * lightClr.rgb * lightClr.a * attenuation;
|
||||
gl_FragColor = vec4(diffuse, 1.);
|
||||
}
|
||||
|
11
shaders/sh_normal_light_apply/sh_bw.yy
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "shader",
|
||||
"path": "folders/shader.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_bw",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
11
shaders/sh_normal_light_apply/sh_color_adjust.yy
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "shader",
|
||||
"path": "folders/shader.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_color_adjust",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
11
shaders/sh_normal_light_apply/sh_color_replace.yy
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "shader",
|
||||
"path": "folders/shader.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_color_replace",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
11
shaders/sh_normal_light_apply/sh_greyscale.yy
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"type": 1,
|
||||
"parent": {
|
||||
"name": "shader",
|
||||
"path": "folders/shader.yy",
|
||||
},
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_greyscale",
|
||||
"tags": [],
|
||||
"resourceType": "GMShader",
|
||||
}
|
14
shaders/sh_normal_light_apply/sh_normal_light_apply.fsh
Normal file
@ -0,0 +1,14 @@
|
||||
varying vec2 v_vTexcoord;
|
||||
varying vec4 v_vColour;
|
||||
|
||||
uniform sampler2D baseSurface;
|
||||
uniform sampler2D lightSurface;
|
||||
uniform vec4 ambient;
|
||||
|
||||
void main() {
|
||||
vec4 baseColor = texture2D( baseSurface, v_vTexcoord );
|
||||
vec4 lighColor = texture2D( lightSurface, v_vTexcoord );
|
||||
|
||||
vec4 res = baseColor * ambient + lighColor;
|
||||
gl_FragColor = res;
|
||||
}
|
18
shaders/sh_normal_light_apply/sh_normal_light_apply.vsh
Normal file
@ -0,0 +1,18 @@
|
||||
//
|
||||
// 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;
|
||||
}
|
12
shaders/sh_normal_light_apply/sh_normal_light_apply.yy
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"$GMShader":"",
|
||||
"%Name":"sh_normal_light_apply",
|
||||
"name":"sh_normal_light_apply",
|
||||
"parent":{
|
||||
"name":"2d effect",
|
||||
"path":"folders/shader/3d/2d effect.yy",
|
||||
},
|
||||
"resourceType":"GMShader",
|
||||
"resourceVersion":"2.0",
|
||||
"type":1,
|
||||
}
|
After Width: | Height: | Size: 347 B |
After Width: | Height: | Size: 650 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 347 B |
After Width: | Height: | Size: 650 B |
After Width: | Height: | Size: 531 B |
After Width: | Height: | Size: 559 B |
107
sprites/s_node_normal_light_type/s_node_normal_light_type.yy
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"$GMSprite":"",
|
||||
"%Name":"s_node_normal_light_type",
|
||||
"bboxMode":0,
|
||||
"bbox_bottom":21,
|
||||
"bbox_left":0,
|
||||
"bbox_right":22,
|
||||
"bbox_top":0,
|
||||
"collisionKind":1,
|
||||
"collisionTolerance":0,
|
||||
"ConfigValues":{
|
||||
"Steam":{
|
||||
"textureGroupId":"{ \"name\":\"Default\", \"path\":\"texturegroups/Default\" }",
|
||||
},
|
||||
},
|
||||
"DynamicTexturePage":false,
|
||||
"edgeFiltering":false,
|
||||
"For3D":false,
|
||||
"frames":[
|
||||
{"$GMSpriteFrame":"","%Name":"8eeba671-1e0c-4784-aee5-d2ba5a939abc","name":"8eeba671-1e0c-4784-aee5-d2ba5a939abc","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"ec86a74a-6ffe-42f5-ae93-d0d9987c648a","name":"ec86a74a-6ffe-42f5-ae93-d0d9987c648a","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"7bb75978-c213-4d25-bea3-0e87b31fe941","name":"7bb75978-c213-4d25-bea3-0e87b31fe941","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
{"$GMSpriteFrame":"","%Name":"802a0b23-160b-4c57-8816-8a04999630c9","name":"802a0b23-160b-4c57-8816-8a04999630c9","resourceType":"GMSpriteFrame","resourceVersion":"2.0",},
|
||||
],
|
||||
"gridX":0,
|
||||
"gridY":0,
|
||||
"height":24,
|
||||
"HTile":false,
|
||||
"layers":[
|
||||
{"$GMImageLayer":"","%Name":"da039720-b10e-4f3e-a236-4f2b7fd5c6cc","blendMode":0,"displayName":"default","isLocked":false,"name":"da039720-b10e-4f3e-a236-4f2b7fd5c6cc","opacity":100.0,"resourceType":"GMImageLayer","resourceVersion":"2.0","visible":true,},
|
||||
],
|
||||
"name":"s_node_normal_light_type",
|
||||
"nineSlice":null,
|
||||
"origin":4,
|
||||
"parent":{
|
||||
"name":"nodes",
|
||||
"path":"folders/sprites/nodes.yy",
|
||||
},
|
||||
"preMultiplyAlpha":false,
|
||||
"resourceType":"GMSprite",
|
||||
"resourceVersion":"2.0",
|
||||
"sequence":{
|
||||
"$GMSequence":"",
|
||||
"%Name":"s_node_normal_light_type",
|
||||
"autoRecord":true,
|
||||
"backdropHeight":768,
|
||||
"backdropImageOpacity":0.5,
|
||||
"backdropImagePath":"",
|
||||
"backdropWidth":1366,
|
||||
"backdropXOffset":0.0,
|
||||
"backdropYOffset":0.0,
|
||||
"events":{
|
||||
"$KeyframeStore<MessageEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MessageEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"eventStubScript":null,
|
||||
"eventToFunction":{},
|
||||
"length":4.0,
|
||||
"lockOrigin":false,
|
||||
"moments":{
|
||||
"$KeyframeStore<MomentsEventKeyframe>":"",
|
||||
"Keyframes":[],
|
||||
"resourceType":"KeyframeStore<MomentsEventKeyframe>",
|
||||
"resourceVersion":"2.0",
|
||||
},
|
||||
"name":"s_node_normal_light_type",
|
||||
"playback":1,
|
||||
"playbackSpeed":30.0,
|
||||
"playbackSpeedType":0,
|
||||
"resourceType":"GMSequence",
|
||||
"resourceVersion":"2.0",
|
||||
"showBackdrop":true,
|
||||
"showBackdropImage":false,
|
||||
"timeUnits":1,
|
||||
"tracks":[
|
||||
{"$GMSpriteFramesTrack":"","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"$KeyframeStore<SpriteFrameKeyframe>":"","Keyframes":[
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"8eeba671-1e0c-4784-aee5-d2ba5a939abc","path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"321d1771-047b-45ac-96f8-fcd8dcf771d7","IsCreationKey":false,"Key":0.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"ec86a74a-6ffe-42f5-ae93-d0d9987c648a","path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"fab4aad8-ec80-47bd-b0d2-3cc2dc70e7d1","IsCreationKey":false,"Key":1.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"7bb75978-c213-4d25-bea3-0e87b31fe941","path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"c9e919e1-db42-4300-ada7-9b3afad894ad","IsCreationKey":false,"Key":2.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
{"$Keyframe<SpriteFrameKeyframe>":"","Channels":{
|
||||
"0":{"$SpriteFrameKeyframe":"","Id":{"name":"802a0b23-160b-4c57-8816-8a04999630c9","path":"sprites/s_node_normal_light_type/s_node_normal_light_type.yy",},"resourceType":"SpriteFrameKeyframe","resourceVersion":"2.0",},
|
||||
},"Disabled":false,"id":"0d69897c-d9c2-42c7-b9ce-382f31701120","IsCreationKey":false,"Key":3.0,"Length":1.0,"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"2.0","Stretch":false,},
|
||||
],"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"2.0",},"modifiers":[],"name":"frames","resourceType":"GMSpriteFramesTrack","resourceVersion":"2.0","spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
|
||||
],
|
||||
"visibleRange":null,
|
||||
"volume":1.0,
|
||||
"xorigin":12,
|
||||
"yorigin":12,
|
||||
},
|
||||
"swatchColours":null,
|
||||
"swfPrecision":2.525,
|
||||
"textureGroupId":{
|
||||
"name":"Default",
|
||||
"path":"texturegroups/Default",
|
||||
},
|
||||
"type":0,
|
||||
"VTile":false,
|
||||
"width":24,
|
||||
}
|