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
67e1b52568
commit
940fd87e77
Notes:
blender-bot
2023-02-14 00:06:52 +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 #100749, Blender LTS: Maintenance Task 3.3 Referenced by issue #103615, Different texture direction for box projection mode in OSL
|
@ -122,6 +122,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]);
|
||||
|
||||
|
@ -184,9 +185,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,
|
||||
|
@ -198,9 +200,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,
|
||||
|
@ -212,9 +215,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