mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2025-01-12 07:16:49 +01:00
GLSL node now use HLSL
This commit is contained in:
parent
29d85de951
commit
4668cde2fd
10 changed files with 64 additions and 98 deletions
|
@ -171,7 +171,6 @@
|
|||
{"name":"color picker","order":56,"path":"folders/shader/color picker.yy",},
|
||||
{"name":"color selector","order":51,"path":"folders/shader/color selector.yy",},
|
||||
{"name":"draw","order":39,"path":"folders/shader/draw.yy",},
|
||||
{"name":"dummy","order":57,"path":"folders/shader/dummy.yy",},
|
||||
{"name":"filter","order":30,"path":"folders/shader/filter.yy",},
|
||||
{"name":"color","order":53,"path":"folders/shader/filter/color.yy",},
|
||||
{"name":"shadow caster","order":46,"path":"folders/shader/filter/shadow caster.yy",},
|
||||
|
|
|
@ -205,7 +205,6 @@
|
|||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"color picker","folderPath":"folders/shader/color picker.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"color selector","folderPath":"folders/shader/color selector.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"draw","folderPath":"folders/shader/draw.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"dummy","folderPath":"folders/shader/dummy.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"filter","folderPath":"folders/shader/filter.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"color","folderPath":"folders/shader/filter/color.yy",},
|
||||
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"shadow caster","folderPath":"folders/shader/filter/shadow caster.yy",},
|
||||
|
@ -1127,7 +1126,6 @@
|
|||
{"id":{"name":"s_node_pack_sprite","path":"sprites/s_node_pack_sprite/s_node_pack_sprite.yy",},},
|
||||
{"id":{"name":"surface_valid","path":"scripts/surface_valid/surface_valid.yy",},},
|
||||
{"id":{"name":"steam_ugc_collection","path":"scripts/steam_ugc_collection/steam_ugc_collection.yy",},},
|
||||
{"id":{"name":"sh_dummy_0","path":"shaders/sh_dummy_0/sh_dummy_0.yy",},},
|
||||
{"id":{"name":"sh_blur_zoom","path":"shaders/sh_blur_zoom/sh_blur_zoom.yy",},},
|
||||
{"id":{"name":"node_VFX_renderer","path":"scripts/node_VFX_renderer/node_VFX_renderer.yy",},},
|
||||
{"id":{"name":"s_node_pb_fx_stack","path":"sprites/s_node_pb_fx_stack/s_node_pb_fx_stack.yy",},},
|
||||
|
|
|
@ -82,6 +82,7 @@ function __3dObject() constructor {
|
|||
}
|
||||
}
|
||||
vertex_end(_buffer);
|
||||
vertex_freeze(_buffer);
|
||||
|
||||
return _buffer;
|
||||
} #endregion
|
||||
|
|
|
@ -6,17 +6,18 @@ var reserved = ["and", "break", "do", "else", "elseif", "end", "false",
|
|||
for( var i = 0, n = array_length(reserved); i < n; i++ )
|
||||
global.lua_reserved[? reserved[i]] = 1;
|
||||
|
||||
global.CODE_BREAK_TOKEN = [" ", "(", ")", "[", "]", "{", "}", ",", ";", "+", "-", "*", "/", "^", "="];
|
||||
|
||||
function token_splice(str) {
|
||||
var st = [];
|
||||
var ss = str;
|
||||
var sp;
|
||||
var cc;
|
||||
var tk = [" ", "(", ")", "[", "]", "{", "}", ",", ";", "+", "-", "*", "/", "^", "="];
|
||||
|
||||
do {
|
||||
sp = 999999;
|
||||
for( var i = 0, n = array_length(tk); i < n; i++ ) {
|
||||
var _pos = string_pos(tk[i], ss);
|
||||
for( var i = 0, n = array_length(global.CODE_BREAK_TOKEN); i < n; i++ ) {
|
||||
var _pos = string_pos(global.CODE_BREAK_TOKEN[i], ss);
|
||||
if(_pos != 0) sp = min(sp, _pos);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#region vb
|
||||
vertex_format_begin();
|
||||
vertex_format_add_position();
|
||||
vertex_format_add_color();
|
||||
vertex_format_add_texcoord();
|
||||
global.HLSL_VB_FORMAT = vertex_format_end();
|
||||
|
||||
global.HLSL_VB = vertex_create_buffer();
|
||||
vertex_begin(global.HLSL_VB, global.HLSL_VB_FORMAT);
|
||||
vertex_position(global.HLSL_VB, 0, 0);
|
||||
vertex_color(global.HLSL_VB, c_white, 1);
|
||||
vertex_texcoord(global.HLSL_VB, 0, 0);
|
||||
|
||||
vertex_position(global.HLSL_VB, 0, 1);
|
||||
vertex_color(global.HLSL_VB, c_white, 1);
|
||||
vertex_texcoord(global.HLSL_VB, 0, 1);
|
||||
|
||||
vertex_position(global.HLSL_VB, 1, 0);
|
||||
vertex_color(global.HLSL_VB, c_white, 1);
|
||||
vertex_texcoord(global.HLSL_VB, 1, 0);
|
||||
|
||||
vertex_position(global.HLSL_VB, 1, 1);
|
||||
vertex_color(global.HLSL_VB, c_white, 1);
|
||||
vertex_texcoord(global.HLSL_VB, 1, 1);
|
||||
vertex_end(global.HLSL_VB);
|
||||
#endregion
|
||||
|
||||
function Node_HLSL(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) constructor {
|
||||
name = "HLSL";
|
||||
shader = { vs: -1, fs: -1 };
|
||||
|
@ -7,8 +34,8 @@ function Node_HLSL(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
|
|||
.rejectArray();
|
||||
|
||||
inputs[| 1] = nodeValue("Fragment", self, JUNCTION_CONNECT.input, VALUE_TYPE.text,
|
||||
@"float4 combinedColour = gm_BaseTextureObject.Sample(gm_BaseTexture, input.uv);
|
||||
return combinedColour;")
|
||||
@"float4 surfaceColor = gm_BaseTextureObject.Sample(gm_BaseTexture, input.uv);
|
||||
output.color = surfaceColor;")
|
||||
.setDisplay(VALUE_DISPLAY.codeHLSL)
|
||||
.rejectArray();
|
||||
|
||||
|
@ -61,7 +88,7 @@ cbuffer Matrices : register(b0) {
|
|||
|
||||
struct VertexShaderInput {
|
||||
float3 pos : POSITION;
|
||||
float4 color : COLOR0;
|
||||
float3 color : COLOR0;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
@ -70,13 +97,9 @@ struct VertexShaderOutput {
|
|||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
VertexShaderOutput main(VertexShaderInput input) {
|
||||
VertexShaderOutput output;
|
||||
|
||||
void main(in VertexShaderInput input, out VertexShaderOutput output) {
|
||||
output.pos = mul(gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION], float4(input.pos, 1.0f));
|
||||
output.uv = input.uv;
|
||||
|
||||
return output;
|
||||
}";
|
||||
file_text_write_all(_dir + "vout.shader", vs);
|
||||
|
||||
|
@ -84,10 +107,14 @@ VertexShaderOutput main(VertexShaderInput input) {
|
|||
Texture2D gm_BaseTextureObject : register(t0);
|
||||
SamplerState gm_BaseTexture : register(s0);
|
||||
|
||||
struct PixelShaderInput {
|
||||
struct VertexShaderOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct PixelShaderOutput {
|
||||
float4 color : SV_Target0;
|
||||
};
|
||||
"
|
||||
var fs_param = "";
|
||||
var sampler_slot = 1;
|
||||
|
@ -111,18 +138,18 @@ struct PixelShaderInput {
|
|||
}
|
||||
}
|
||||
|
||||
var fs_pos = "float4 main(PixelShaderInput input) : SV_TARGET {" + fs + "}";
|
||||
var fs_pos = "\nvoid main(in VertexShaderOutput input, out PixelShaderOutput output) {\n" + fs + "\n}";
|
||||
|
||||
fs = fs_pre + fs_param + fs_pos;
|
||||
file_text_write_all(_dir + "fout.shader", fs);
|
||||
|
||||
shader.vs = d3d11_shader_compile_vs(_dir + "vout.shader", "main", "vs_4_0");
|
||||
if (!d3d11_shader_exists(shader.vs))
|
||||
print(d3d11_get_error_string());
|
||||
noti_warning(d3d11_get_error_string());
|
||||
|
||||
shader.fs = d3d11_shader_compile_ps(_dir + "fout.shader", "main", "ps_4_0");
|
||||
if (!d3d11_shader_exists(shader.fs))
|
||||
print(d3d11_get_error_string());
|
||||
noti_warning(d3d11_get_error_string());
|
||||
}
|
||||
|
||||
static onValueUpdate = function(index) {
|
||||
|
@ -132,6 +159,7 @@ struct PixelShaderInput {
|
|||
|
||||
static processData = function(_output, _data, _output_index, _array_index = 0) {
|
||||
var _surf = _data[2];
|
||||
if(!is_surface(_surf)) return;
|
||||
_output = surface_verify(_output, surface_get_width(_surf), surface_get_height(_surf));
|
||||
|
||||
surface_set_target(_output);
|
||||
|
@ -158,7 +186,9 @@ struct PixelShaderInput {
|
|||
}
|
||||
}
|
||||
|
||||
draw_surface_safe(_surf);
|
||||
matrix_set(matrix_world, matrix_build(0, 0, 0, 0, 0, 0, surface_get_width(_surf), surface_get_height(_surf), 1));
|
||||
vertex_submit(global.HLSL_VB, pr_trianglestrip, surface_get_texture(_surf));
|
||||
matrix_set(matrix_world, matrix_build_identity());
|
||||
|
||||
d3d11_shader_override_vs(-1);
|
||||
d3d11_shader_override_ps(-1);
|
||||
|
@ -167,7 +197,5 @@ struct PixelShaderInput {
|
|||
return _output;
|
||||
}
|
||||
|
||||
static postConnect = function() {
|
||||
refreshShader();
|
||||
}
|
||||
static postConnect = function() { refreshShader(); }
|
||||
}
|
|
@ -143,6 +143,16 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
}
|
||||
} #endregion
|
||||
|
||||
static breakCharacter = function(ch) { #region
|
||||
switch(format) {
|
||||
case TEXT_AREA_FORMAT.codeHLSL :
|
||||
case TEXT_AREA_FORMAT.codeLUA :
|
||||
return ch == "\n" || array_exists(global.CODE_BREAK_TOKEN, ch);
|
||||
default :
|
||||
return ch == " " || ch == "\n";
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static onKey = function(key) { #region
|
||||
if(key == vk_left) {
|
||||
if(key_mod_press(SHIFT)) {
|
||||
|
@ -155,7 +165,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
if(key_mod_press(CTRL)) {
|
||||
while(cursor > 0) {
|
||||
var ch = string_char_at(_input_text, cursor);
|
||||
if(ch == " " || ch == "\n") break;
|
||||
if(breakCharacter(ch)) break;
|
||||
cursor--;
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +181,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
if(key_mod_press(CTRL)) {
|
||||
while(cursor < string_length(_input_text)) {
|
||||
var ch = string_char_at(_input_text, cursor);
|
||||
if(ch == " " || ch == "\n") break;
|
||||
if(breakCharacter(ch)) break;
|
||||
cursor++;
|
||||
}
|
||||
}
|
||||
|
@ -585,6 +595,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
if(target != -999) {
|
||||
if(mouse_press(mb_left, active) || click_block == 1) {
|
||||
cursor_select = target;
|
||||
cursor = target;
|
||||
click_block = 0;
|
||||
} else if(mouse_click(mb_left, active) && cursor != target)
|
||||
cursor = target;
|
||||
|
|
|
@ -273,7 +273,8 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
if(target != -999) {
|
||||
if(mouse_press(mb_left, active) || click_block == 1) {
|
||||
cursor_select = target;
|
||||
click_block = 0;
|
||||
cursor = target;
|
||||
click_block = 0;
|
||||
} else if(mouse_click(mb_left, active) && cursor != target)
|
||||
cursor = target;
|
||||
}
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
varying vec2 v_vTexcoord;
|
||||
|
||||
uniform float u_float_0, u_float_1, u_float_2, u_float_3, u_float_4, u_float_5, u_float_6, u_float_7;
|
||||
uniform float u_float_8, u_float_9, u_float_10, u_float_11, u_float_12, u_float_13, u_float_14, u_float_15;
|
||||
|
||||
uniform int u_int_0, u_int_1, u_int_2, u_int_3, u_int_4, u_int_5, u_int_6, u_int_7;
|
||||
uniform int u_int_8, u_int_9, u_int_10, u_int_11, u_int_12, u_int_13, u_int_14, u_int_15;
|
||||
|
||||
uniform vec2 u_vec2_0, u_vec2_1, u_vec2_2, u_vec2_3, u_vec2_4, u_vec2_5, u_vec2_6, u_vec2_7;
|
||||
uniform vec2 u_vec2_8, u_vec2_9, u_vec2_10, u_vec2_11, u_vec2_12, u_vec2_13, u_vec2_14, u_vec2_15;
|
||||
|
||||
uniform vec3 u_vec3_0, u_vec3_1, u_vec3_2, u_vec3_3, u_vec3_4, u_vec3_5, u_vec3_6, u_vec3_7;
|
||||
uniform vec3 u_vec3_8, u_vec3_9, u_vec3_10, u_vec3_11, u_vec3_12, u_vec3_13, u_vec3_14, u_vec3_15;
|
||||
|
||||
uniform vec4 u_vec4_0, u_vec4_1, u_vec4_2, u_vec4_3, u_vec4_4, u_vec4_5, u_vec4_6, u_vec4_7;
|
||||
uniform vec4 u_vec4_8, u_vec4_9, u_vec4_10, u_vec4_11, u_vec4_12, u_vec4_13, u_vec4_14, u_vec4_15;
|
||||
|
||||
uniform mat3 u_mat3_0, u_mat3_1, u_mat3_2, u_mat3_3, u_mat3_4, u_mat3_5, u_mat3_6, u_mat3_7;
|
||||
uniform mat3 u_mat3_8, u_mat3_9, u_mat3_10, u_mat3_11, u_mat3_12, u_mat3_13, u_mat3_14, u_mat3_15;
|
||||
|
||||
uniform mat4 u_mat4_0, u_mat4_1, u_mat4_2, u_mat4_3, u_mat4_4, u_mat4_5, u_mat4_6, u_mat4_7;
|
||||
uniform mat4 u_mat4_8, u_mat4_9, u_mat4_10, u_mat4_11, u_mat4_12, u_mat4_13, u_mat4_14, u_mat4_15;
|
||||
|
||||
uniform sampler2D u_sampler2D_0, u_sampler2D_1, u_sampler2D_2, u_sampler2D_3, u_sampler2D_4, u_sampler2D_5, u_sampler2D_6;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = texture2D( gm_BaseTexture, v_vTexcoord );
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
attribute vec3 in_Position;
|
||||
attribute vec4 in_Colour;
|
||||
attribute vec2 in_TextureCoord;
|
||||
|
||||
varying vec2 v_vTexcoord;
|
||||
|
||||
uniform float u_float_0, u_float_1, u_float_2, u_float_3, u_float_4, u_float_5, u_float_6, u_float_7;
|
||||
uniform float u_float_8, u_float_9, u_float_10, u_float_11, u_float_12, u_float_13, u_float_14, u_float_15;
|
||||
|
||||
uniform int u_int_0, u_int_1, u_int_2, u_int_3, u_int_4, u_int_5, u_int_6, u_int_7;
|
||||
uniform int u_int_8, u_int_9, u_int_10, u_int_11, u_int_12, u_int_13, u_int_14, u_int_15;
|
||||
|
||||
uniform vec2 u_vec2_0, u_vec2_1, u_vec2_2, u_vec2_3, u_vec2_4, u_vec2_5, u_vec2_6, u_vec2_7;
|
||||
uniform vec2 u_vec2_8, u_vec2_9, u_vec2_10, u_vec2_11, u_vec2_12, u_vec2_13, u_vec2_14, u_vec2_15;
|
||||
|
||||
uniform vec3 u_vec3_0, u_vec3_1, u_vec3_2, u_vec3_3, u_vec3_4, u_vec3_5, u_vec3_6, u_vec3_7;
|
||||
uniform vec3 u_vec3_8, u_vec3_9, u_vec3_10, u_vec3_11, u_vec3_12, u_vec3_13, u_vec3_14, u_vec3_15;
|
||||
|
||||
uniform vec4 u_vec4_0, u_vec4_1, u_vec4_2, u_vec4_3, u_vec4_4, u_vec4_5, u_vec4_6, u_vec4_7;
|
||||
uniform vec4 u_vec4_8, u_vec4_9, u_vec4_10, u_vec4_11, u_vec4_12, u_vec4_13, u_vec4_14, u_vec4_15;
|
||||
|
||||
uniform mat3 u_mat3_0, u_mat3_1, u_mat3_2, u_mat3_3, u_mat3_4, u_mat3_5, u_mat3_6, u_mat3_7;
|
||||
uniform mat3 u_mat3_8, u_mat3_9, u_mat3_10, u_mat3_11, u_mat3_12, u_mat3_13, u_mat3_14, u_mat3_15;
|
||||
|
||||
uniform mat4 u_mat4_0, u_mat4_1, u_mat4_2, u_mat4_3, u_mat4_4, u_mat4_5, u_mat4_6, u_mat4_7;
|
||||
uniform mat4 u_mat4_8, u_mat4_9, u_mat4_10, u_mat4_11, u_mat4_12, u_mat4_13, u_mat4_14, u_mat4_15;
|
||||
|
||||
uniform sampler2D u_sampler2D_0, u_sampler2D_1, u_sampler2D_2, u_sampler2D_3, u_sampler2D_4, u_sampler2D_5, u_sampler2D_6;
|
||||
|
||||
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_vTexcoord = in_TextureCoord;
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"resourceType": "GMShader",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "sh_dummy_0",
|
||||
"parent": {
|
||||
"name": "dummy",
|
||||
"path": "folders/shader/dummy.yy",
|
||||
},
|
||||
"type": 1,
|
||||
}
|
Loading…
Reference in a new issue