Fix T103615: OSL image box mapping has flipped textures
This breaks backwards compatibility some in that 3 sides will be mapped differently now, but difficult to avoid and can be considered a bugfix. Similar to rBdd8016f7081f. Maniphest Tasks: T103615 Differential Revision: https://developer.blender.org/D16910
This commit is contained in:
parent
cdc10a9283
commit
bb194e6b84
Notes:
blender-bot
2023-02-14 04:40:22 +01:00
Referenced by issue #88449: Blender LTS: Maintenance Task 2.93 Referenced by issue #88449, Blender LTS: Maintenance Task 2.93 Referenced by issue #103615, Different texture direction for box projection mode in OSL
|
@ -135,6 +135,7 @@ shader node_image_texture(int use_mapping = 0,
|
|||
vector Nob = transform("world", "object", N);
|
||||
|
||||
/* project from direction vector to barycentric coordinates in triangles */
|
||||
vector signed_Nob = Nob;
|
||||
Nob = vector(fabs(Nob[0]), fabs(Nob[1]), fabs(Nob[2]));
|
||||
Nob /= (Nob[0] + Nob[1] + Nob[2]);
|
||||
|
||||
|
@ -197,9 +198,10 @@ shader node_image_texture(int use_mapping = 0,
|
|||
float tmp_alpha;
|
||||
|
||||
if (weight[0] > 0.0) {
|
||||
point UV = point((signed_Nob[0] < 0.0) ? 1.0 - p[1] : p[1], p[2], 0.0);
|
||||
Color += weight[0] * image_texture_lookup(filename,
|
||||
p[1],
|
||||
p[2],
|
||||
UV[0],
|
||||
UV[1],
|
||||
tmp_alpha,
|
||||
compress_as_srgb,
|
||||
ignore_alpha,
|
||||
|
@ -211,9 +213,10 @@ shader node_image_texture(int use_mapping = 0,
|
|||
Alpha += weight[0] * tmp_alpha;
|
||||
}
|
||||
if (weight[1] > 0.0) {
|
||||
point UV = point((signed_Nob[1] > 0.0) ? 1.0 - p[0] : p[0], p[2], 0.0);
|
||||
Color += weight[1] * image_texture_lookup(filename,
|
||||
p[0],
|
||||
p[2],
|
||||
UV[0],
|
||||
UV[1],
|
||||
tmp_alpha,
|
||||
compress_as_srgb,
|
||||
ignore_alpha,
|
||||
|
@ -225,9 +228,10 @@ shader node_image_texture(int use_mapping = 0,
|
|||
Alpha += weight[1] * tmp_alpha;
|
||||
}
|
||||
if (weight[2] > 0.0) {
|
||||
point UV = point((signed_Nob[2] > 0.0) ? 1.0 - p[1] : p[1], p[0], 0.0);
|
||||
Color += weight[2] * image_texture_lookup(filename,
|
||||
p[1],
|
||||
p[0],
|
||||
UV[0],
|
||||
UV[1],
|
||||
tmp_alpha,
|
||||
compress_as_srgb,
|
||||
ignore_alpha,
|
||||
|
|
Loading…
Reference in New Issue