Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/shaders/gpu_shader_material.glsl
| Show First 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | void vec_math_dot(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | ||||
| outvec = vec3(0, 0, 0); | outvec = vec3(0, 0, 0); | ||||
| outval = dot(v1, v2); | outval = dot(v1, v2); | ||||
| } | } | ||||
| void vec_math_cross(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | void vec_math_cross(vec3 v1, vec3 v2, out vec3 outvec, out float outval) | ||||
| { | { | ||||
| outvec = cross(v1, v2); | outvec = cross(v1, v2); | ||||
| outval = length(outvec); | outval = length(outvec); | ||||
| outvec = normalize(outvec); | |||||
sergey: Why not to divide by `outval`? Would save calculating vector length second time. | |||||
Not Done Inline ActionsSounds fair, will do. kevindietrich: Sounds fair, will do. | |||||
| } | } | ||||
| void vec_math_normalize(vec3 v, out vec3 outvec, out float outval) | void vec_math_normalize(vec3 v, out vec3 outvec, out float outval) | ||||
| { | { | ||||
| outval = length(v); | outval = length(v); | ||||
| outvec = normalize(v); | outvec = normalize(v); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 2,249 Lines • Show Last 20 Lines | |||||
Why not to divide by outval? Would save calculating vector length second time.