mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-26 21:08:18 +01:00
- [FXAA] Add moer effect controls.
This commit is contained in:
parent
79b3d8b5be
commit
5aa848c087
4 changed files with 58 additions and 41 deletions
|
@ -27,7 +27,7 @@ if(winMan_isMinimized()) exit;
|
|||
break;
|
||||
|
||||
case VALUE_TYPE.curve :
|
||||
draw_tooltip_text($"[{__txt("Curve Object"}]");
|
||||
draw_tooltip_text($"[{__txt("Curve Object")}]");
|
||||
break;
|
||||
|
||||
case VALUE_TYPE.color :
|
||||
|
@ -51,12 +51,11 @@ if(winMan_isMinimized()) exit;
|
|||
break;
|
||||
|
||||
case VALUE_TYPE.rigid :
|
||||
draw_tooltip_text($"[{__txt("Rigidbody Object")} (id: {content[$ "object"]})]");
|
||||
draw_tooltip_text($"[{__txt("Rigidbody Object")} (id: {content.object})]");
|
||||
break;
|
||||
|
||||
case VALUE_TYPE.particle :
|
||||
var txt = $"[{__txt("Particle Object")} (size: {array_length(content)}) ]";
|
||||
draw_tooltip_text(txt);
|
||||
draw_tooltip_text($"[{__txt("Particle Object")} (size: {array_length(content)}) ]");
|
||||
break;
|
||||
|
||||
case VALUE_TYPE.pathnode :
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$GMObject": "",
|
||||
"%Name": "o_main",
|
||||
"eventList": [
|
||||
"$GMObject":"",
|
||||
"%Name":"o_main",
|
||||
"eventList":[
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":3,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
|
@ -19,35 +19,35 @@
|
|||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":60,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":70,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":20,"eventType":7,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"resourceVersion":"1.0","name":"","resourceType":"GMEvent","eventNum":1,"eventType":9,"isDnD":false,},
|
||||
{"resourceVersion":"1.0","name":"","resourceType":"GMEvent","eventNum":1,"eventType":10,"isDnD":false,},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":9,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":1,"eventType":10,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
|
||||
],
|
||||
"managed": true,
|
||||
"name": "o_main",
|
||||
"overriddenProperties": [],
|
||||
"parent": {
|
||||
"name": "main",
|
||||
"path": "folders/main.yy",
|
||||
"managed":true,
|
||||
"name":"o_main",
|
||||
"overriddenProperties":[],
|
||||
"parent":{
|
||||
"name":"main",
|
||||
"path":"folders/main.yy",
|
||||
},
|
||||
"parentObjectId": null,
|
||||
"persistent": true,
|
||||
"physicsAngularDamping": 0.1,
|
||||
"physicsDensity": 0.5,
|
||||
"physicsFriction": 0.2,
|
||||
"physicsGroup": 1,
|
||||
"physicsKinematic": false,
|
||||
"physicsLinearDamping": 0.1,
|
||||
"physicsObject": false,
|
||||
"physicsRestitution": 0.1,
|
||||
"physicsSensor": false,
|
||||
"physicsShape": 1,
|
||||
"physicsShapePoints": [],
|
||||
"physicsStartAwake": true,
|
||||
"properties": [],
|
||||
"resourceType": "GMObject",
|
||||
"resourceVersion": "2.0",
|
||||
"solid": false,
|
||||
"spriteId": null,
|
||||
"spriteMaskId": null,
|
||||
"visible": true,
|
||||
"parentObjectId":null,
|
||||
"persistent":true,
|
||||
"physicsAngularDamping":0.1,
|
||||
"physicsDensity":0.5,
|
||||
"physicsFriction":0.2,
|
||||
"physicsGroup":1,
|
||||
"physicsKinematic":false,
|
||||
"physicsLinearDamping":0.1,
|
||||
"physicsObject":false,
|
||||
"physicsRestitution":0.1,
|
||||
"physicsSensor":false,
|
||||
"physicsShape":1,
|
||||
"physicsShapePoints":[],
|
||||
"physicsStartAwake":true,
|
||||
"properties":[],
|
||||
"resourceType":"GMObject",
|
||||
"resourceVersion":"2.0",
|
||||
"solid":false,
|
||||
"spriteId":null,
|
||||
"spriteMaskId":null,
|
||||
"visible":true,
|
||||
}
|
|
@ -5,10 +5,17 @@ function Node_FXAA(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
|
||||
inputs[| 1] = nodeValue("Active", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, true);
|
||||
|
||||
inputs[| 2] = nodeValue("Distance", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 0.5)
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
inputs[| 3] = nodeValue("Mix", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, 1)
|
||||
.setDisplay(VALUE_DISPLAY.slider);
|
||||
|
||||
active_index = 1;
|
||||
|
||||
input_display_list = [
|
||||
1, 0,
|
||||
["Effect", false], 2, 3,
|
||||
]
|
||||
|
||||
outputs[| 0] = nodeValue("Surface out", self, JUNCTION_CONNECT.output, VALUE_TYPE.surface, noone);
|
||||
|
@ -19,6 +26,9 @@ function Node_FXAA(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
surface_set_shader(_outSurf, sh_FXAA);
|
||||
gpu_set_tex_filter(true);
|
||||
shader_set_f("dimension", surface_get_width_safe(_data[0]), surface_get_height_safe(_data[0]));
|
||||
shader_set_f("cornerDis", _data[2]);
|
||||
shader_set_f("mixAmo", _data[3]);
|
||||
|
||||
draw_surface_safe(_data[0], 0, 0);
|
||||
gpu_set_tex_filter(false);
|
||||
surface_reset_shader();
|
||||
|
|
|
@ -6,6 +6,8 @@ varying vec4 v_vColour;
|
|||
|
||||
//Texel size (1/resolution)
|
||||
uniform vec2 dimension;
|
||||
uniform float cornerDis;
|
||||
uniform float mixAmo;
|
||||
|
||||
#define SPAN_MAX (8.0) //Maximum texel span
|
||||
//These are more technnical and probably don't need changing:
|
||||
|
@ -16,10 +18,10 @@ vec4 textureFXAA(sampler2D tex, vec2 uv) {
|
|||
vec2 u_texel = 1. / dimension;
|
||||
//Sample center and 4 corners
|
||||
vec3 rgbCC = texture2D(tex, uv).rgb;
|
||||
vec3 rgb00 = texture2D(tex, uv + vec2( -0.5, -0.5) * u_texel).rgb;
|
||||
vec3 rgb10 = texture2D(tex, uv + vec2( +0.5, -0.5) * u_texel).rgb;
|
||||
vec3 rgb01 = texture2D(tex, uv + vec2( -0.5, +0.5) * u_texel).rgb;
|
||||
vec3 rgb11 = texture2D(tex, uv + vec2( +0.5, +0.5) * u_texel).rgb;
|
||||
vec3 rgb00 = texture2D(tex, uv + vec2( -cornerDis, -cornerDis) * u_texel).rgb;
|
||||
vec3 rgb10 = texture2D(tex, uv + vec2( +cornerDis, -cornerDis) * u_texel).rgb;
|
||||
vec3 rgb01 = texture2D(tex, uv + vec2( -cornerDis, +cornerDis) * u_texel).rgb;
|
||||
vec3 rgb11 = texture2D(tex, uv + vec2( +cornerDis, +cornerDis) * u_texel).rgb;
|
||||
|
||||
//Luma coefficients
|
||||
const vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
|
@ -32,13 +34,18 @@ vec4 textureFXAA(sampler2D tex, vec2 uv) {
|
|||
|
||||
//Compute gradient from luma values
|
||||
vec2 dir = vec2((luma01 + luma11) - (luma00 + luma10), (luma00 + luma01) - (luma10 + luma11));
|
||||
|
||||
//Diminish dir length based on total luma
|
||||
float dirReduce = max((luma00 + luma10 + luma01 + luma11) * REDUCE_MUL, REDUCE_MIN);
|
||||
|
||||
//Divide dir by the distance to nearest edge plus dirReduce
|
||||
float rcpDir = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
|
||||
//Multiply by reciprocal and limit to pixel span
|
||||
dir = clamp(dir * rcpDir, -SPAN_MAX, SPAN_MAX) * u_texel.xy;
|
||||
|
||||
vec4 O = texture2D(tex, uv);
|
||||
|
||||
//Average middle texels along dir line
|
||||
vec4 A = 0.5 * (
|
||||
texture2D(tex, uv - dir * (1.0 / 6.0)) +
|
||||
|
@ -56,8 +63,9 @@ vec4 textureFXAA(sampler2D tex, vec2 uv) {
|
|||
|
||||
//Get average luma
|
||||
float lumaB = dot(B.rgb, luma);
|
||||
|
||||
//If the average is outside the luma range, using the middle average
|
||||
return ((lumaB < lumaMin) || (lumaB > lumaMax)) ? A : B;
|
||||
return mix(O, ((lumaB < lumaMin) || (lumaB > lumaMax)) ? A : B, mixAmo);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
|
Loading…
Reference in a new issue