Use sub-pixel differentials for bump mapping helps with reducing artifacts when objects are moving or when textures have high frequency details. Currently we scale it by 0.1 because it seems to work good in practice, we can adjust the value in the future if it turns out to be impractical. Ref: #122892 Pull Request: https://projects.blender.org/blender/blender/pulls/133991
33 lines
690 B
Plaintext
33 lines
690 B
Plaintext
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
#include "stdcycles.h"
|
|
|
|
shader node_uv_map(int from_dupli = 0,
|
|
string attribute = "",
|
|
string bump_offset = "center",
|
|
output point UV = point(0.0, 0.0, 0.0))
|
|
{
|
|
if (from_dupli) {
|
|
getattribute("geom:dupli_uv", UV);
|
|
}
|
|
else {
|
|
if (attribute == "")
|
|
getattribute("geom:uv", UV);
|
|
else
|
|
getattribute(attribute, UV);
|
|
}
|
|
|
|
if (bump_offset == "dx") {
|
|
if (!from_dupli) {
|
|
UV += Dx(UV) * BUMP_DX;
|
|
}
|
|
}
|
|
else if (bump_offset == "dy") {
|
|
if (!from_dupli) {
|
|
UV += Dy(UV) * BUMP_DY;
|
|
}
|
|
}
|
|
}
|