-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Description
OBJMC item models that have received transformations in-game on the roll colour channel become out of sync with the entity rotation (yaw and pitch). As demonstrated below in code, the main include shader for OBJMC could theoretically recalculate normals using the rotation vector as a scalar of reference for the roll.
Reproduction
- Summon an item display with a tinted OBJMC item model exported with roll colour behaviour (during my test, blue channel was used)
/summon item_display ~ ~ ~ {item:{id:"stick",components:{item_model:"example_objmc_model",custom_model_data:{colors:[I;0]}}}}- Face the entity directly at the player using a repeating command block:
/tp [entity] ^ ^ ^ facing entity @p eyes- Set the roll colour value of the model used so that it is flipped on Z axis (e.g. 0.5 = 180°).
/data modify entity [entity] item.components."minecraft:custom_model_data".colors[0] set value [[0.0,0.0,0.5]]Environment:
- Windows 10
- Minecraft 1.21.4 (vanilla)
- i5-7200U, Intel Graphics 620
Additional context
GLSL code from objmc_main.glsl that fixes the issue :
- Rotations are inverted based on roll colour behaviour (works best at every right angle)
if (any(greaterThan(autorotate,vec2(0)))) {
//normal estimated rotation calculation from The Der Discohund
float yaw = -atan(Normal.x, Normal.z);
float pitch = -atan(Normal.y, length(Normal.xz));
// recalculate normal rotation based on roll
float roll = max(0.0, min(rotation.z, 1.0));
yaw = yaw * (1 - roll) - yaw * roll;
pitch = pitch * (1 - roll) - pitch * roll;
posoffset = rotate(vec3(vec2(pitch,yaw)*autorotate,0) + rotation) * posoffset;
}Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
