Skip to content

Commit 096f7b8

Browse files
committed
Add camera texture node
1 parent fd482ac commit 096f7b8

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
function camera_texture_node_init() {
3+
array_push(nodes_material_texture, camera_texture_node_def);
4+
map_set(parser_material_node_vectors, "TEX_CAMERA", camera_texture_node_vector);
5+
}
6+
7+
function camera_texture_node_vector(node: ui_node_t, socket: ui_node_socket_t): string {
8+
let tex_name: string = "texcamera_" + parser_material_node_name(node);
9+
node_shader_add_texture(parser_material_kong, "" + tex_name, "_camera_texture");
10+
let store: string = parser_material_store_var_name(node);
11+
parser_material_write(parser_material_kong, "var " + store + "_res: float3 = sample(" + tex_name + ", sampler_linear, tex_coord).rgb;");
12+
return store + "_res";
13+
}
14+
15+
let camera_texture_node_def: ui_node_t = {
16+
id : 0,
17+
name : _tr("Camera Texture"),
18+
type : "TEX_CAMERA", // extension
19+
x : 0,
20+
y : 0,
21+
color : 0xff4982a0,
22+
inputs : [],
23+
outputs : [ {
24+
id : 0,
25+
node_id : 0,
26+
name : _tr("Color"),
27+
type : "RGBA",
28+
color : 0xffc7c729,
29+
default_value : f32_array_create_xyzw(0.8, 0.8, 0.8, 1.0),
30+
min : 0.0,
31+
max : 1.0,
32+
precision : 100,
33+
display : 0
34+
} ],
35+
buttons : [],
36+
width : 0,
37+
flags : 0
38+
};

paint/sources/nodes_material.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function nodes_material_init() {
3838

3939
nodes_material_texture = [];
4040
brick_texture_node_init();
41+
camera_texture_node_init();
4142
checker_texture_node_init();
4243
curvature_bake_node_init();
4344
gradient_texture_node_init();

paint/sources/uniforms_ext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,10 @@ function uniforms_ext_tex_link(object: object_t, mat: material_data_t, link: str
425425
return rt._image;
426426
}
427427
}
428+
if (link == "_camera_texture") {
429+
let rt: render_target_t = map_get(render_path_render_targets, "last");
430+
return rt._image;
431+
}
428432

429433
return null;
430434
}

0 commit comments

Comments
 (0)