Differential D6975 Diff 22822 source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl
| Context not available. | |||||
| #define METALLIC_BITS 3u /* Metallic channel is less important. */ | #define METALLIC_BITS 3u /* Metallic channel is less important. */ | ||||
| #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) | #define ROUGHNESS_BITS (TARGET_BITCOUNT - METALLIC_BITS) | ||||
| vec2 matcap_uv_compute(vec3 I, vec3 N, bool flipped) | |||||
| { | |||||
| /* Quick creation of an orthonormal basis */ | |||||
| float a = 1.0 / (1.0 + I.z); | |||||
| float b = -I.x * I.y * a; | |||||
| vec3 b1 = vec3(1.0 - I.x * I.x * a, b, -I.x); | |||||
| vec3 b2 = vec3(b, 1.0 - I.y * I.y * a, -I.y); | |||||
| vec2 matcap_uv = vec2(dot(b1, N), dot(b2, N)); | |||||
| if (flipped) { | |||||
| matcap_uv.x = -matcap_uv.x; | |||||
| } | |||||
| return matcap_uv * 0.496 + 0.5; | |||||
| } | |||||
| /* Encode 2 float into 1 with the desired precision. */ | /* Encode 2 float into 1 with the desired precision. */ | ||||
| float workbench_float_pair_encode(float v1, float v2) | float workbench_float_pair_encode(float v1, float v2) | ||||
| { | { | ||||
| Context not available. | |||||