[3D renderer] Fix normal not transformed by with material shift and scale properties.

This commit is contained in:
Tanasart 2024-12-19 12:09:02 +07:00
parent db9a16ddb4
commit 8879bfb770
5 changed files with 20 additions and 10 deletions

View file

@ -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));

View file

@ -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() {

View file

@ -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 ] );
}
}

View file

@ -8,10 +8,14 @@ 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;