Differential D11487 Diff 40301 source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/shaders/edit_mesh_normal_vert.glsl
| uniform float normalSize; | uniform float normalSize; | ||||
| uniform float normalScreenSize; | |||||
| uniform bool isConstantScreenSizeNormals; | |||||
| uniform sampler2D depthTex; | uniform sampler2D depthTex; | ||||
| uniform float alpha = 1.0; | uniform float alpha = 1.0; | ||||
| in vec3 pos; | in vec3 pos; | ||||
| in vec4 lnor; | in vec4 lnor; | ||||
| in vec4 vnor; | in vec4 vnor; | ||||
| in vec4 norAndFlag; | in vec4 norAndFlag; | ||||
| Show All 33 Lines | else { | ||||
| nor = norAndFlag.xyz; | nor = norAndFlag.xyz; | ||||
| if (all(equal(nor, vec3(0)))) { | if (all(equal(nor, vec3(0)))) { | ||||
| return; | return; | ||||
| } | } | ||||
| finalColor = colorNormal; | finalColor = colorNormal; | ||||
| } | } | ||||
| vec3 n = normalize(normal_object_to_world(nor)); | vec3 n = normalize(normal_object_to_world(nor)); | ||||
| vec3 world_pos = point_object_to_world(pos); | vec3 world_pos = point_object_to_world(pos); | ||||
| if (gl_VertexID == 0) { | if (gl_VertexID == 0) { | ||||
| if (isConstantScreenSizeNormals) { | |||||
| bool is_persp = (ProjectionMatrix[3][3] == 0.0); | |||||
| if (is_persp) | |||||
fclem: Instead of this, I would create a new value for the screen space scale and make it a… | |||||
Not Done Inline ActionsDo not put comment this ways. bool is_persp = (ProjectionMatrix[3][3] == 0.0);
if (is_persp) {fclem: Do not put comment this ways.
Either put it in the matching branch or do the following (widely… | |||||
| { | |||||
| float dist_fac = length(cameraPos - world_pos); | |||||
| float cos_fac = dot(cameraForward, cameraVec(world_pos)); | |||||
| world_pos += n * normalScreenSize * dist_fac * cos_fac * pixelFac * sizePixel; | |||||
| } | |||||
| else { | |||||
| float frustrum_fac = mul_project_m4_v3_zfac(n) * sizePixel; | |||||
| world_pos += n * normalScreenSize * frustrum_fac; | |||||
| } | |||||
| } | |||||
| else { | |||||
| world_pos += n * normalSize; | world_pos += n * normalSize; | ||||
| } | } | ||||
| } | |||||
| gl_Position = point_world_to_ndc(world_pos); | gl_Position = point_world_to_ndc(world_pos); | ||||
| finalColor.a *= (test_occlusion()) ? alpha : 1.0; | finalColor.a *= (test_occlusion()) ? alpha : 1.0; | ||||
| #ifdef USE_WORLD_CLIP_PLANES | #ifdef USE_WORLD_CLIP_PLANES | ||||
| world_clip_planes_calc_clip_distance(world_pos); | world_clip_planes_calc_clip_distance(world_pos); | ||||
| #endif | #endif | ||||
| } | } | ||||
Instead of this, I would create a new value for the screen space scale and make it a PROP_PIXEL value in DNA.
This way toggling between both does not become anoying.