Function set_tex_offset
and set_tex_scale
doesn’t work:
model->set_tex_scale(texture.texture_stage, static_cast<float>(width), static_cast<float>(height));
model->set_tex_offset(texture.texture_stage, static_cast<float>(x), static_cast<float>(y));
Basically size is being changed but the offset isn’t being changed, the texture is still being applied on model completely.
Texture:
Result:
Perhaps the problem is that the texture is superimposed in repeat mode.
I have untitled.gltf model with that smile texture, and after i’m applying that texture to model (that one with squares and other things), and after i’m changing size, and offset, how can I superimpose texture in repeat mode?
I wanted to say the opposite, you don’t need to apply a texture in repeat mode if you want to move beyond the boundaries of the geometry. This mode is set via Texture
.
https://docs.panda3d.org/1.10/cpp/programming/texturing/texture-wrap-modes
So I should use WM_border_color
, but what if I want to border color be transparent?
I think there’s nothing stopping you from using texture modes in this case.
https://docs.panda3d.org/1.10/cpp/programming/texturing/texture-modes
1 Like
Oh, M_decal
+ WM_border_color
. Thank you!
By the way, I found something strange in setting wraps for texture.
// error
this->wtexture->set_wrap_u(Texture::WM_border_color);
this->wtexture->set_wrap_v(Texture::WM_border_color);
// no error
this->wtexture->set_wrap_u(Texture::WM_border_color);
this->wtexture->set_wrap_v(SamplerState::WrapMode::WM_border_color);
it says that set_wrap_v
requires SamplerState::WrapMode
and set_wrap_u
requires Texture::DeprecatedWrapMode
is this engine issue?
nevermind, just an another IDE issue
In this case, it is better to refer to the source code.
https://docs.panda3d.org/1.10/cpp/reference/panda3d.core.Texture#_CPPv4N7Texture18DeprecatedWrapModeE
FT_linear_mipmap_nearest = SamplerState::FT_linear_mipmap_nearest,
FT_nearest_mipmap_linear = SamplerState::FT_nearest_mipmap_linear,
FT_linear_mipmap_linear = SamplerState::FT_linear_mipmap_linear,
FT_shadow = SamplerState::FT_shadow,
FT_default = SamplerState::FT_default,
FT_invalid = SamplerState::FT_invalid
};
typedef SamplerState::FilterType FilterType;
// Deprecated. See SamplerState.WrapMode.
enum DeprecatedWrapMode {
WM_clamp = SamplerState::WM_clamp,
WM_repeat = SamplerState::WM_repeat,
WM_mirror = SamplerState::WM_mirror,
WM_mirror_once = SamplerState::WM_mirror_once,
WM_border_color = SamplerState::WM_border_color,
WM_invalid = SamplerState::WM_invalid
};
typedef SamplerState::WrapMode WrapMode;
enum CompressionMode {
1 Like
this problem is solved, but i have another question, is it possible to place texture only on one face?
A custom shader could do that, or perhaps some cunning use of Texture Combine Modes.
Or, of course, modelling the face in question as a separate object.
If the texture coordinates of this face are in the range 0-1, then yes. I think this can be done in a 3D editor, for example by deploying UV mapping appropriately for one face.
But I suspect your question is related to decals on the corners of walls, for example, when the bullet hole moves to a neighboring face, which has an angle of 90 degrees.
This is usually done in additional ways that cannot be summarized in this post.
2 Likes