mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-25 14:36:13 +01:00
1.17.2
This commit is contained in:
parent
1dace22a61
commit
b911c4da50
4 changed files with 155 additions and 57 deletions
|
@ -36,10 +36,10 @@
|
||||||
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
|
globalvar VERSION, SAVE_VERSION, VERSION_STRING, BUILD_NUMBER, LATEST_VERSION;
|
||||||
|
|
||||||
LATEST_VERSION = 11700;
|
LATEST_VERSION = 11700;
|
||||||
VERSION = 11712;
|
VERSION = 11720;
|
||||||
SAVE_VERSION = 11690;
|
SAVE_VERSION = 11690;
|
||||||
VERSION_STRING = "1.17.1.2";
|
VERSION_STRING = "1.17.2.0";
|
||||||
BUILD_NUMBER = 11712;
|
BUILD_NUMBER = 11720;
|
||||||
|
|
||||||
globalvar HOTKEYS, HOTKEY_CONTEXT;
|
globalvar HOTKEYS, HOTKEY_CONTEXT;
|
||||||
HOTKEYS = ds_map_create();
|
HOTKEYS = ds_map_create();
|
||||||
|
|
|
@ -3,7 +3,10 @@ function Node_Normalize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
inputs[| 0] = nodeValue("Surface in", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 0 ];
|
inputs[| 1] = nodeValue("Mode", self, JUNCTION_CONNECT.input, VALUE_TYPE.integer, 0)
|
||||||
|
.setDisplay(VALUE_DISPLAY.enum_button, [ "BW", "RGB" ]);
|
||||||
|
|
||||||
|
input_display_list = [ 0, 1 ];
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
|
@ -17,6 +20,7 @@ function Node_Normalize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
|
|
||||||
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
static processData = function(_outSurf, _data, _output_index, _array_index) { #region
|
||||||
var _surf = _data[0];
|
var _surf = _data[0];
|
||||||
|
var _mode = _data[1];
|
||||||
|
|
||||||
var _sw = surface_get_width(_surf);
|
var _sw = surface_get_width(_surf);
|
||||||
var _sh = surface_get_height(_surf);
|
var _sh = surface_get_height(_surf);
|
||||||
|
@ -88,6 +92,14 @@ function Node_Normalize(_x, _y, _group = noone) : Node_Processor(_x, _y, _group)
|
||||||
buffer_delete(_bMin);
|
buffer_delete(_bMin);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
if(_mode == 0) {
|
||||||
|
var _bmax = (_max[0] + _max[1] + _max[2]) / 2;
|
||||||
|
var _bmin = (_min[0] + _min[1] + _min[2]) / 2;
|
||||||
|
|
||||||
|
_max = [ _bmax, _bmax, _bmax ];
|
||||||
|
_min = [ _bmin, _bmin, _bmin ];
|
||||||
|
}
|
||||||
|
|
||||||
surface_set_shader(_outSurf, sh_normalize);
|
surface_set_shader(_outSurf, sh_normalize);
|
||||||
shader_set_f("cMax", _max);
|
shader_set_f("cMax", _max);
|
||||||
shader_set_f("cMin", _min);
|
shader_set_f("cMin", _min);
|
||||||
|
|
|
@ -29,7 +29,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
inputs[| 2] = nodeValue("Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
|
||||||
inputs[| 3] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
inputs[| 3] = nodeValue("Rotation", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 30, 45, 0 ])
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
|
||||||
inputs[| 4] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
inputs[| 4] = nodeValue("Scale", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
||||||
|
@ -47,9 +47,9 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
inputs[| 8] = nodeValue("Light Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -.5, -.5, 1 ])
|
inputs[| 8] = nodeValue("Light Position", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ -.5, -.5, 1 ])
|
||||||
.setDisplay(VALUE_DISPLAY.vector);
|
.setDisplay(VALUE_DISPLAY.vector);
|
||||||
|
|
||||||
inputs[| 9] = nodeValue("Ambient", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
inputs[| 9] = nodeValue("Base Color", self, JUNCTION_CONNECT.input, VALUE_TYPE.color, c_white);
|
||||||
|
|
||||||
inputs[| 10] = nodeValue("Ambient Intensity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
|
inputs[| 10] = nodeValue("Ambient Level", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.2)
|
||||||
.setDisplay(VALUE_DISPLAY.slider);
|
.setDisplay(VALUE_DISPLAY.slider);
|
||||||
|
|
||||||
inputs[| 11] = nodeValue("Elongate", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
inputs[| 11] = nodeValue("Elongate", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 0, 0 ])
|
||||||
|
@ -117,6 +117,18 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
inputs[| 31] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
inputs[| 31] = nodeValue("Draw BG", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inputs[| 32] = nodeValue("Volumetric", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false);
|
||||||
|
|
||||||
|
inputs[| 33] = nodeValue("Density", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.1)
|
||||||
|
.setDisplay(VALUE_DISPLAY.slider);
|
||||||
|
|
||||||
|
inputs[| 34] = nodeValue("Environment", self, JUNCTION_CONNECT.input, VALUE_TYPE.surface, false);
|
||||||
|
|
||||||
|
inputs[| 35] = nodeValue("Reflective", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.)
|
||||||
|
.setDisplay(VALUE_DISPLAY.slider);
|
||||||
|
|
||||||
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
outputs[| 0] = nodeValue("Surface Out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||||
|
|
||||||
input_display_list = [ 0,
|
input_display_list = [ 0,
|
||||||
|
@ -124,9 +136,11 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
["Modify", false], 12, 11,
|
["Modify", false], 12, 11,
|
||||||
["Deform", true], 15, 16, 17, 18, 19,
|
["Deform", true], 15, 16, 17, 18, 19,
|
||||||
["Transform", false], 2, 3, 4,
|
["Transform", false], 2, 3, 4,
|
||||||
|
["Material", false], 9, 35,
|
||||||
["Camera", false], 13, 14, 5, 6,
|
["Camera", false], 13, 14, 5, 6,
|
||||||
["Render", false], 31, 30, 7, 9, 10, 8,
|
["Render", false], 31, 30, 34, 10, 7, 8,
|
||||||
["Tile", false], 20, 29,
|
["Tile", false], 20, 29,
|
||||||
|
["Volumetric", true, 32], 33,
|
||||||
];
|
];
|
||||||
|
|
||||||
temp_surface = [ 0, 0, 0, 0 ];
|
temp_surface = [ 0, 0, 0, 0 ];
|
||||||
|
@ -264,6 +278,11 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
var _bgc = _data[30];
|
var _bgc = _data[30];
|
||||||
var _bgd = _data[31];
|
var _bgd = _data[31];
|
||||||
|
|
||||||
|
var _vol = _data[32];
|
||||||
|
var _vden = _data[33];
|
||||||
|
var bgEnv = _data[34];
|
||||||
|
var _refl = _data[35];
|
||||||
|
|
||||||
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
_outSurf = surface_verify(_outSurf, _dim[0], _dim[1]);
|
||||||
|
|
||||||
for (var i = 0, n = array_length(temp_surface); i < n; i++)
|
for (var i = 0, n = array_length(temp_surface); i < n; i++)
|
||||||
|
@ -271,7 +290,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
var tx = 1024;
|
var tx = 1024;
|
||||||
surface_set_shader(temp_surface[0]);
|
surface_set_shader(temp_surface[0]);
|
||||||
|
draw_surface_stretched_safe(bgEnv, tx * 0, tx * 0, tx, tx);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
gpu_set_texfilter(true);
|
gpu_set_texfilter(true);
|
||||||
|
@ -289,7 +308,7 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
case "Sphere" : _shpI = 200; break;
|
case "Sphere" : _shpI = 200; break;
|
||||||
case "Ellipse" : _shpI = 201; break;
|
case "Ellipse" : _shpI = 201; break;
|
||||||
case "Cut Sphere" : _shpI = 202; break;
|
case "Cut Sphere" : _shpI = 202; break;
|
||||||
case "Cut Hollow Sphere" : _shpI = 203; break;
|
case "Cut Hollow Sphere" : _shpI = 203; _crop = _crop / pi * 2.15; break;
|
||||||
case "Torus" : _shpI = 204; break;
|
case "Torus" : _shpI = 204; break;
|
||||||
case "Capped Torus" : _shpI = 205; break;
|
case "Capped Torus" : _shpI = 205; break;
|
||||||
|
|
||||||
|
@ -342,10 +361,17 @@ function Node_RM_Primitive(_x, _y, _group = noone) : Node_Processor(_x, _y, _gro
|
||||||
|
|
||||||
shader_set_i("drawBg", _bgd);
|
shader_set_i("drawBg", _bgd);
|
||||||
shader_set_color("background", _bgc);
|
shader_set_color("background", _bgc);
|
||||||
shader_set_color("ambient", _amb);
|
|
||||||
shader_set_f("ambientIntns", _ambI);
|
shader_set_f("ambientIntns", _ambI);
|
||||||
shader_set_f("lightPosition", _lPos);
|
shader_set_f("lightPosition", _lPos);
|
||||||
|
|
||||||
|
shader_set_color("ambient", _amb);
|
||||||
|
shader_set_f("reflective", _refl);
|
||||||
|
|
||||||
|
shader_set_i("volumetric", _vol);
|
||||||
|
shader_set_f("volumeDensity", _vden);
|
||||||
|
|
||||||
|
shader_set_i("useEnv", is_surface(bgEnv));
|
||||||
|
|
||||||
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
draw_sprite_stretched(s_fx_pixel, 0, 0, 0, _dim[0], _dim[1]);
|
||||||
surface_reset_shader();
|
surface_reset_shader();
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,17 @@ uniform vec3 tileAmount;
|
||||||
|
|
||||||
uniform int drawBg;
|
uniform int drawBg;
|
||||||
uniform vec4 background;
|
uniform vec4 background;
|
||||||
uniform vec4 ambient;
|
|
||||||
uniform float ambientIntns;
|
uniform float ambientIntns;
|
||||||
uniform vec3 lightPosition;
|
uniform vec3 lightPosition;
|
||||||
|
|
||||||
|
uniform vec4 ambient;
|
||||||
|
uniform float reflective;
|
||||||
|
|
||||||
|
uniform int useEnv;
|
||||||
|
|
||||||
|
uniform int volumetric;
|
||||||
|
uniform float volumeDensity;
|
||||||
|
|
||||||
mat3 rotMatrix, irotMatrix;
|
mat3 rotMatrix, irotMatrix;
|
||||||
|
|
||||||
#region ////========== Transform ============
|
#region ////========== Transform ============
|
||||||
|
@ -134,6 +141,12 @@ mat3 rotMatrix, irotMatrix;
|
||||||
|
|
||||||
return texture2D(texture0, sm);
|
return texture2D(texture0, sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec2 equirectangularUv(vec3 dir) {
|
||||||
|
vec3 n = normalize(dir);
|
||||||
|
return vec2((atan(n.x, n.z) / (PI * 2.)) + 0.5, 1. - acos(n.y) / PI);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ////========== Primitives ===========
|
#region ////========== Primitives ===========
|
||||||
|
@ -368,10 +381,6 @@ mat3 rotMatrix, irotMatrix;
|
||||||
float sceneSDF(vec3 p) {
|
float sceneSDF(vec3 p) {
|
||||||
float d;
|
float d;
|
||||||
|
|
||||||
p = irotMatrix * p;
|
|
||||||
p /= objectScale;
|
|
||||||
p -= position;
|
|
||||||
|
|
||||||
p = wave(p);
|
p = wave(p);
|
||||||
|
|
||||||
if(tileSize != vec3(0.))
|
if(tileSize != vec3(0.))
|
||||||
|
@ -441,8 +450,25 @@ float march(vec3 camera, vec3 direction) {
|
||||||
return viewRange.y;
|
return viewRange.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float marchDensity(vec3 camera, vec3 direction) {
|
||||||
|
float st = 1. / float(MAX_MARCHING_STEPS);
|
||||||
|
float dens = 0.;
|
||||||
|
float stp = volumeDensity == 0. ? 0. : pow(2., 10. * volumeDensity * 0.5 - 10.);
|
||||||
|
|
||||||
|
for (int i = 0; i <= MAX_MARCHING_STEPS; i++) {
|
||||||
|
float depth = mix(viewRange.x, viewRange.y, float(i) * st);
|
||||||
|
vec3 pos = camera + depth * direction;
|
||||||
|
float hit = sceneSDF(pos);
|
||||||
|
float inst = (pos.y + objectScale) / (objectScale * 2.);
|
||||||
|
inst = inst <= 0.? 0. : pow(2., 10. * inst - 10.) * 10.;
|
||||||
|
|
||||||
|
if (hit <= 0.) dens += stp * inst;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dens;
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_FragColor = drawBg == 1? background : vec4(0.);
|
|
||||||
|
|
||||||
mat3 rx = rotateX(rotation.x);
|
mat3 rx = rotateX(rotation.x);
|
||||||
mat3 ry = rotateY(rotation.y);
|
mat3 ry = rotateY(rotation.y);
|
||||||
|
@ -450,16 +476,32 @@ void main() {
|
||||||
rotMatrix = rx * ry * rz;
|
rotMatrix = rx * ry * rz;
|
||||||
irotMatrix = inverse(rotMatrix);
|
irotMatrix = inverse(rotMatrix);
|
||||||
|
|
||||||
vec3 eye, dir;
|
float dz = 1. / tan(radians(fov) / 2.);
|
||||||
|
vec3 dir = normalize(vec3((v_vTexcoord - .5) * 2., -dz));
|
||||||
|
vec3 eye = vec3(0., 0., 5.);
|
||||||
|
|
||||||
if(ortho == 1) {
|
dir = normalize(irotMatrix * dir) / objectScale;
|
||||||
dir = vec3(0., 0., 1.);
|
eye = irotMatrix * eye;
|
||||||
eye = vec3((v_vTexcoord - .5) * 2. * orthoScale, viewRange.x);
|
eye /= objectScale;
|
||||||
|
eye -= position;
|
||||||
|
|
||||||
} else {
|
vec4 bg = background;
|
||||||
float z = 1. / tan(radians(fov) / 2.);
|
if(useEnv == 1) {
|
||||||
dir = normalize(vec3((v_vTexcoord - .5) * 2., -z));
|
float edz = 1. / tan(radians(fov * 2.) / 2.);
|
||||||
eye = vec3(0., 0., 5.);
|
vec3 edir = normalize(vec3((v_vTexcoord - .5) * 2., -edz));
|
||||||
|
edir = normalize(irotMatrix * edir) / objectScale;
|
||||||
|
|
||||||
|
vec2 envUV = equirectangularUv(edir);
|
||||||
|
vec4 endC = sampleTexture(0, envUV);
|
||||||
|
bg = endC;
|
||||||
|
}
|
||||||
|
|
||||||
|
gl_FragColor = drawBg == 1? bg : vec4(0.);
|
||||||
|
|
||||||
|
if(volumetric == 1) {
|
||||||
|
float _dens = clamp(marchDensity(eye, dir), 0., 1.);
|
||||||
|
gl_FragColor = mix(background, ambient, _dens);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dist = march(eye, dir);
|
float dist = march(eye, dir);
|
||||||
|
@ -472,17 +514,35 @@ void main() {
|
||||||
vec3 c = ambient.rgb;
|
vec3 c = ambient.rgb;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
float distNorm = (dist - viewRange.x) / (viewRange.y - viewRange.x);
|
float distNorm = (dist - viewRange.x) / (viewRange.y - viewRange.x);
|
||||||
distNorm = 1. - distNorm;
|
distNorm = 1. - distNorm;
|
||||||
distNorm = smoothstep(.0, .3, distNorm);
|
distNorm = smoothstep(.0, .3, distNorm);
|
||||||
c = mix(background.rgb, c, mix(1., distNorm, depthInt));
|
c = mix(background.rgb, c, mix(1., distNorm, depthInt));
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
vec3 norm = normal(coll);
|
vec3 norm = normal(coll);
|
||||||
|
vec3 ref = reflect(dir, norm);
|
||||||
|
|
||||||
|
if(useEnv == 1) {
|
||||||
|
vec4 refC = sampleTexture(0, equirectangularUv(ref))
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3( 0.01, 0., 0.))) * 0.5
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3(-0.01, 0., 0.))) * 0.5
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3(0., 0.01, 0.))) * 0.5
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3(0., -0.01, 0.))) * 0.5
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3(0., 0., 0.01))) * 0.5
|
||||||
|
+ sampleTexture(0, equirectangularUv(ref + vec3(0., 0., -0.01))) * 0.5;
|
||||||
|
refC /= 4.;
|
||||||
|
|
||||||
|
c = mix(c, c * refC.rgb, reflective);
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
vec3 light = normalize(lightPosition);
|
vec3 light = normalize(lightPosition);
|
||||||
float lamo = dot(norm, light) + ambientIntns;
|
float lamo = min(1., max(0., dot(norm, light)) + ambientIntns);
|
||||||
|
|
||||||
c = mix(background.rgb, c, lamo);
|
c = mix(background.rgb, c, lamo);
|
||||||
// c *= lamo;
|
|
||||||
|
|
||||||
gl_FragColor = vec4(c, 1.);
|
gl_FragColor = vec4(c, 1.);
|
||||||
}
|
}
|
Loading…
Reference in a new issue