Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_normal_map.c
| Context not available. | |||||
| for (int j = 0; j < 3; j++) | for (int j = 0; j < 3; j++) | ||||
| out[0]->vec[j] = vecIn[0] * T[j] + vecIn[1] * B[j] + vecIn[2] * N[j]; | out[0]->vec[j] = vecIn[0] * T[j] + vecIn[1] * B[j] + vecIn[2] * N[j]; | ||||
| interp_v3_v3v3(out[0]->vec, N, out[0]->vec, strength); | interp_v3_v3v3(out[0]->vec, N, out[0]->vec, strength); | ||||
| if (shi->use_world_space_light_params) | |||||
| mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEWINV_MATRIX), out[0]->vec); | |||||
| break; | break; | ||||
| case SHD_NORMAL_MAP_OBJECT: | case SHD_NORMAL_MAP_OBJECT: | ||||
| case SHD_NORMAL_MAP_BLENDER_OBJECT: | case SHD_NORMAL_MAP_BLENDER_OBJECT: | ||||
| mul_mat3_m4_v3((float (*)[4])RE_object_instance_get_matrix(shi->obi, RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW), vecIn); | if (shi->use_world_space_light_params) | ||||
| mul_mat3_m4_v3((float (*)[4])RE_object_instance_get_matrix(shi->obi, RE_OBJECT_INSTANCE_MATRIX_OB), vecIn); | |||||
| else | |||||
| mul_mat3_m4_v3((float (*)[4])RE_object_instance_get_matrix(shi->obi, RE_OBJECT_INSTANCE_MATRIX_LOCALTOVIEW), vecIn); | |||||
| interp_v3_v3v3(out[0]->vec, N, vecIn, strength); | interp_v3_v3v3(out[0]->vec, N, vecIn, strength); | ||||
| break; | break; | ||||
| case SHD_NORMAL_MAP_WORLD: | case SHD_NORMAL_MAP_WORLD: | ||||
| case SHD_NORMAL_MAP_BLENDER_WORLD: | case SHD_NORMAL_MAP_BLENDER_WORLD: | ||||
| mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), vecIn); | if (!shi->use_world_space_light_params) | ||||
| mul_mat3_m4_v3((float (*)[4])RE_render_current_get_matrix(RE_VIEW_MATRIX), vecIn); | |||||
| interp_v3_v3v3(out[0]->vec, N, vecIn, strength); | interp_v3_v3v3(out[0]->vec, N, vecIn, strength); | ||||
| break; | break; | ||||
| } | } | ||||
brecht: Not sure why this checks for `GPU_material_use_new_shading_nodes`.
The purpose of this feature… | |||||
Not Done Inline ActionsI agree. If necessary, this can be done in another patch. a.romanov: I agree. If necessary, this can be done in another patch. | |||||
| Context not available. | |||||
| switch (nm->space) { | switch (nm->space) { | ||||
| case SHD_NORMAL_MAP_TANGENT: | case SHD_NORMAL_MAP_TANGENT: | ||||
Not Done Inline ActionsOf cource a.romanov: Of cource | |||||
| GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm); | GPU_link(mat, "node_normal_map", GPU_attribute(CD_TANGENT, nm->uv_map), negnorm, realnorm, &realnorm); | ||||
| if (GPU_material_use_world_space_light_params(mat)) { | |||||
| GPU_link(mat, "vec_math_mix", strength, realnorm, negnorm, &out[0].link); | |||||
| /* for uniform scale this is sufficient to match Cycles */ | |||||
| GPU_link(mat, "direction_transform_m4v3", out[0].link, GPU_builtin(GPU_INVERSE_VIEW_MATRIX), &out[0].link); | |||||
| GPU_link(mat, "vect_normalize", out[0].link, &out[0].link); | |||||
| return true; | |||||
| } | |||||
| break; | break; | ||||
| case SHD_NORMAL_MAP_OBJECT: | case SHD_NORMAL_MAP_OBJECT: | ||||
| case SHD_NORMAL_MAP_BLENDER_OBJECT: | case SHD_NORMAL_MAP_BLENDER_OBJECT: | ||||
| GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_LOC_TO_VIEW_MATRIX), &realnorm); | if (GPU_material_use_world_space_light_params(mat)) | ||||
Done Inline ActionsThis code should have been removed I think? brecht: This code should have been removed I think? | |||||
| GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_OBJECT_MATRIX), &realnorm); | |||||
| else | |||||
| GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_LOC_TO_VIEW_MATRIX), &realnorm); | |||||
| break; | break; | ||||
| case SHD_NORMAL_MAP_WORLD: | case SHD_NORMAL_MAP_WORLD: | ||||
| case SHD_NORMAL_MAP_BLENDER_WORLD: | case SHD_NORMAL_MAP_BLENDER_WORLD: | ||||
| GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_VIEW_MATRIX), &realnorm); | if (!GPU_material_use_world_space_light_params(mat)) | ||||
| GPU_link(mat, "direction_transform_m4v3", realnorm, GPU_builtin(GPU_VIEW_MATRIX), &realnorm); | |||||
brechtUnsubmitted Not Done Inline ActionsCan this be implemented as: if (GPU_material_use_new_shading_nodes || GPU_material_use_world_space_light_params) {
.. world space ..
}
else {
.. camera space ..
}Or is there a good reason for Cycles and Blender Internal to behave differently besides the camera/world space difference? brecht: Can this be implemented as:
```
if (GPU_material_use_new_shading_nodes ||… | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
Not sure why this checks for GPU_material_use_new_shading_nodes.
The purpose of this feature was to support Blender-style normal map encoding and a more standard normal map encoding. I think that feature is useful for both Blender Internal and Cycles?
Though I guess that's not really an issue with this world space stuff specifically and doesn't need to be solved here.