From 8879bfb77085552db4800cdf35b581397e1d256c Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 19 Dec 2024 12:09:02 +0700 Subject: [PATCH] [3D renderer] Fix normal not transformed by with material shift and scale properties. --- objects/o_dialog_add_node/Draw_64.gml | 2 +- scripts/d3d_material/d3d_material.gml | 7 +++++-- scripts/d3d_object/d3d_object.gml | 5 ++++- scripts/node_registry/node_registry.gml | 2 +- shaders/sh_d3d_geometry/sh_d3d_geometry.fsh | 14 +++++++++----- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/objects/o_dialog_add_node/Draw_64.gml b/objects/o_dialog_add_node/Draw_64.gml index af423b2d7..675397ad0 100644 --- a/objects/o_dialog_add_node/Draw_64.gml +++ b/objects/o_dialog_add_node/Draw_64.gml @@ -18,7 +18,7 @@ if !ready exit; if(search_string == "") { catagory_pane.setFocusHover(sFOCUS, sHOVER); - catagory_pane.draw(dialog_x + ui(8), sy); + catagory_pane.draw(dialog_x + ui(12), sy); var _x = dialog_x + category_width + ui(16); draw_sprite_stretched(THEME.ui_panel_bg, 1, _x, sy, dialog_w - category_width - ui(30), dialog_h - ui(66)); diff --git a/scripts/d3d_material/d3d_material.gml b/scripts/d3d_material/d3d_material.gml index d3f9eae71..1582a620f 100644 --- a/scripts/d3d_material/d3d_material.gml +++ b/scripts/d3d_material/d3d_material.gml @@ -21,8 +21,11 @@ function __d3dMaterial(surface = noone) constructor { static submitGeometry = function() { shader_set_i("use_normal", is_surface(normal)); - shader_set_surface("normal_map", normal); - shader_set_f("normal_strength", normalStr); + + shader_set_surface("normal_map", normal ); + shader_set_f("normal_strength", normalStr ); + shader_set_f("mat_texScale", texScale ); + shader_set_f("mat_texShift", texShift ); } static submitShader = function() { diff --git a/scripts/d3d_object/d3d_object.gml b/scripts/d3d_object/d3d_object.gml index 1c064c3b5..0df8c697c 100644 --- a/scripts/d3d_object/d3d_object.gml +++ b/scripts/d3d_object/d3d_object.gml @@ -205,7 +205,10 @@ function __3dObject() constructor { } else if(_shader == sh_d3d_geometry) { if(_useMat) _mat.submitGeometry(); - else shader_set_i("use_normal", 0); + else { + shader_set_i("use_normal", 0); + shader_set_f("mat_texScale", [ 1, 1 ] ); + } } diff --git a/scripts/node_registry/node_registry.gml b/scripts/node_registry/node_registry.gml index 2b5aeb61f..f88d1252d 100644 --- a/scripts/node_registry/node_registry.gml +++ b/scripts/node_registry/node_registry.gml @@ -823,7 +823,7 @@ function __initNodes() { addNodeObject(generator, "Repeat", s_node_repeat, "Node_Repeat", [0, Node_create_Repeat], global.node_repeat_keys, "Repeat image multiple times linearly, or in grid pattern.").setVersion(1100); addNodeObject(generator, "Scatter", s_node_scatter, "Node_Scatter", [1, Node_Scatter],, "Scatter image randomly multiple times."); addNodeObject(generator, "Repeat Texture", s_node_repeat_texture, "Node_Repeat_Texture", [1, Node_Repeat_Texture],, "Repeat texture over larger surface without repeating patterns."); - + ds_list_add(generator, "Simulation"); addNodeObject(generator, "Particle", s_node_particle, "Node_Particle", [1, Node_Particle],, "Generate particle effect."); addNodeObject(generator, "VFX", s_node_vfx, "Node_VFX_Group_Inline", [1, Node_VFX_Group_Inline],, "Create VFX group, which generate particles that can be manipulated using different force nodes."); diff --git a/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh b/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh index e320167bc..a50cd4c2b 100644 --- a/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh +++ b/shaders/sh_d3d_geometry/sh_d3d_geometry.fsh @@ -3,15 +3,19 @@ varying vec4 v_worldPosition; varying vec3 v_viewPosition; varying vec3 v_vNormal; -uniform int mat_flip; -uniform int use_normal; -uniform int use_8bit; -uniform float normal_strength; -uniform sampler2D normal_map; +uniform int mat_flip; +uniform int use_normal; +uniform int use_8bit; +uniform float normal_strength; +uniform sampler2D normal_map; +uniform vec2 mat_texScale; +uniform vec2 mat_texShift; void main() { vec2 uv_coord = v_vTexcoord; if(mat_flip == 1) uv_coord.y = -uv_coord.y; + uv_coord = fract(uv_coord * mat_texScale + mat_texShift); + vec4 mat_baseColor = texture2D( gm_BaseTexture, uv_coord ); if(mat_baseColor.a < 0.1) discard;