FIX:add new light for text shape

Jira: STUDIO-2623
Change-Id: I3a189154455040e8c2cb41ff8d8ac065661406ad
(cherry picked from commit 5854839c8f552b136cca6b3ff75605fa1e696fd0)
This commit is contained in:
zhou.xu 2023-08-29 16:22:14 +08:00 committed by Lane.Wei
parent c631a69c32
commit bcd8c90b4f
3 changed files with 12 additions and 3 deletions

View File

@ -14,6 +14,9 @@ const vec3 LIGHT_FRONT_DIR = vec3(0.6985074, 0.1397015, 0.6985074);
//#define LIGHT_FRONT_SPECULAR (0.0 * INTENSITY_CORRECTION)
//#define LIGHT_FRONT_SHININESS 5.0
const vec3 LIGHT_BACK_DIR = vec3(0.1397015, 0.6985074,0.6985074);
#define LIGHT_BACK_DIFFUSE (0.3 * INTENSITY_CORRECTION)
#define INTENSITY_AMBIENT 0.3
const vec3 ZERO = vec3(0.0, 0.0, 0.0);
@ -32,7 +35,7 @@ uniform SlopeDetection slope;
uniform vec2 z_range;
// Clipping plane - general orientation. Used by the SLA gizmo.
uniform vec4 clipping_plane;
uniform bool is_text_shape;
// x = diffuse, y = specular;
varying vec2 intensity;
@ -59,7 +62,11 @@ void main()
// Perform the same lighting calculation for the 2nd light source (no specular applied).
NdotL = max(dot(eye_normal, LIGHT_FRONT_DIR), 0.0);
intensity.x += NdotL * LIGHT_FRONT_DIFFUSE;
if(is_text_shape){
NdotL = max(dot(eye_normal, LIGHT_BACK_DIR), 0.0);
intensity.x += NdotL * LIGHT_BACK_DIFFUSE;
}
model_pos = gl_Vertex;
// Point in homogenous coordinates.
world_pos = volume_world_matrix * gl_Vertex;

View File

@ -1083,6 +1083,7 @@ int GLVolumeCollection::load_object_volume(
GLVolume& v = *this->volumes.back();
v.set_color(color_from_model_volume(*model_volume));
v.name = model_volume->name;
v.is_text_shape = model_volume->get_text_info().m_text.empty();
#if ENABLE_SMOOTH_NORMALS
v.indexed_vertex_array.load_mesh(mesh, true);
#else
@ -1322,6 +1323,7 @@ void GLVolumeCollection::render(
glsafe(::glEnableClientState(GL_VERTEX_ARRAY));
glsafe(::glEnableClientState(GL_NORMAL_ARRAY));
shader->set_uniform("is_text_shape", volume.first->is_text_shape);
shader->set_uniform("uniform_color", volume.first->render_color);
shader->set_uniform("z_range", m_z_range, 2);
shader->set_uniform("clipping_plane", m_clipping_plane, 4);

View File

@ -260,7 +260,7 @@ private:
class GLVolume {
public:
std::string name;
bool is_text_shape{false};
static std::array<float, 4> DISABLED_COLOR;
static std::array<float, 4> SLA_SUPPORT_COLOR;
static std::array<float, 4> SLA_PAD_COLOR;