@@ -462,6 +462,26 @@ function parser_material_parse_vector_input(inp: ui_node_socket_t): string {
462
462
}
463
463
}
464
464
465
+ function _parser_material_cache_tex_text_node ( file : string , text : string ) {
466
+ if ( map_get ( data_cached_images , file ) == null ) {
467
+ app_notify_on_init ( function ( text : string ) {
468
+ let _text_tool_text : string = context_raw . text_tool_text ;
469
+ let _text_tool_image : image_t = context_raw . text_tool_image ;
470
+ context_raw . text_tool_text = text ;
471
+ context_raw . text_tool_image = null ;
472
+
473
+ util_render_make_text_preview ( ) ;
474
+ let file : string = "tex_text_" + text ;
475
+
476
+ // TODO: remove old cache
477
+ map_set ( data_cached_images , file , context_raw . text_tool_image ) ;
478
+
479
+ context_raw . text_tool_text = _text_tool_text ;
480
+ context_raw . text_tool_image = _text_tool_image ;
481
+ } , text ) ;
482
+ }
483
+ }
484
+
465
485
function parser_material_parse_vector ( node : ui_node_t , socket : ui_node_socket_t ) : string {
466
486
if ( node . type == "GROUP" ) {
467
487
return parser_material_parse_group ( node , socket ) ;
@@ -544,6 +564,16 @@ function parser_material_parse_vector(node: ui_node_t, socket: ui_node_socket_t)
544
564
return tex_store + ".rgb" ;
545
565
}
546
566
}
567
+ else if ( node . type == "TEX_TEXT" ) {
568
+ let tex_name : string = parser_material_node_name ( node ) ;
569
+ let text_buffer : buffer_t = node . buttons [ 0 ] . default_value ;
570
+ let text : string = sys_buffer_to_string ( text_buffer ) ;
571
+ let file : string = "tex_text_" + text ;
572
+ _parser_material_cache_tex_text_node ( file , text ) ;
573
+ let tex : bind_tex_t = parser_material_make_bind_tex ( tex_name , file ) ;
574
+ let texstore : string = parser_material_texture_store ( node , tex , tex_name , color_space_t . AUTO ) ;
575
+ return texstore + ".rrr" ;
576
+ }
547
577
else if ( node . type == "TEX_MAGIC" ) {
548
578
node_shader_add_function ( parser_material_curshader , str_tex_magic ) ;
549
579
let co : string = parser_material_get_coord ( node ) ;
@@ -1422,6 +1452,16 @@ function parser_material_parse_value(node: ui_node_t, socket: ui_node_socket_t):
1422
1452
return texstore + ".a" ;
1423
1453
}
1424
1454
}
1455
+ else if ( node . type == "TEX_TEXT" ) {
1456
+ let tex_name : string = parser_material_node_name ( node ) ;
1457
+ let text_buffer : buffer_t = node . buttons [ 0 ] . default_value ;
1458
+ let text : string = sys_buffer_to_string ( text_buffer ) ;
1459
+ let file : string = "tex_text_" + text ;
1460
+ _parser_material_cache_tex_text_node ( file , text ) ;
1461
+ let tex : bind_tex_t = parser_material_make_bind_tex ( tex_name , file ) ;
1462
+ let texstore : string = parser_material_texture_store ( node , tex , tex_name , color_space_t . AUTO ) ;
1463
+ return texstore + ".r" ;
1464
+ }
1425
1465
else if ( node . type == "TEX_MAGIC" ) {
1426
1466
node_shader_add_function ( parser_material_curshader , str_tex_magic ) ;
1427
1467
let co : string = parser_material_get_coord ( node ) ;
@@ -1980,16 +2020,10 @@ function parser_material_enum_data(s: string): string {
1980
2020
return "" ;
1981
2021
}
1982
2022
1983
- function parser_material_make_texture ( image_node : ui_node_t , tex_name : string , matname : string = null ) : bind_tex_t {
1984
- let i : i32 = image_node . buttons [ 0 ] . default_value [ 0 ] ;
1985
- let filepath : string = parser_material_enum_data ( base_enum_texts ( image_node . type ) [ i ] ) ;
1986
- if ( filepath == "" || string_index_of ( filepath , "." ) == - 1 ) {
1987
- return null ;
1988
- }
1989
-
2023
+ function parser_material_make_bind_tex ( tex_name : string , file : string ) : bind_tex_t {
1990
2024
let tex : bind_tex_t = {
1991
2025
name : tex_name ,
1992
- file : filepath
2026
+ file : file
1993
2027
} ;
1994
2028
1995
2029
if ( context_raw . texture_filter ) {
@@ -2009,6 +2043,16 @@ function parser_material_make_texture(image_node: ui_node_t, tex_name: string, m
2009
2043
return tex ;
2010
2044
}
2011
2045
2046
+ function parser_material_make_texture ( image_node : ui_node_t , tex_name : string ) : bind_tex_t {
2047
+ let i : i32 = image_node . buttons [ 0 ] . default_value [ 0 ] ;
2048
+ let filepath : string = parser_material_enum_data ( base_enum_texts ( image_node . type ) [ i ] ) ;
2049
+ if ( filepath == "" || string_index_of ( filepath , "." ) == - 1 ) {
2050
+ return null ;
2051
+ }
2052
+
2053
+ return parser_material_make_bind_tex ( tex_name , filepath ) ;
2054
+ }
2055
+
2012
2056
function parser_material_is_pow ( num : i32 ) : bool {
2013
2057
return ( ( num & ( num - 1 ) ) == 0 ) && num != 0 ;
2014
2058
}
0 commit comments