Cleanup: Grease Pencil: Remove uneeded push-constants
All of these push-constants were either redundant or not used anymore. Pull Request: https://projects.blender.org/blender/blender/pulls/135561
This commit is contained in:
committed by
Clément Foucault
parent
15758ab854
commit
e36cc4dcf7
@@ -50,7 +50,6 @@ GPENCIL_tObject *gpencil_object_cache_add(GPENCIL_Instance *inst,
|
||||
tgp_ob->vfx.first = tgp_ob->vfx.last = nullptr;
|
||||
tgp_ob->camera_z = dot_v3v3(inst->camera_z_axis, ob->object_to_world().location());
|
||||
tgp_ob->is_drawmode3d = is_stroke_order_3d;
|
||||
tgp_ob->object_scale = mat4_to_scale(ob->object_to_world().ptr());
|
||||
|
||||
/* Check if any material with holdout flag enabled. */
|
||||
tgp_ob->do_mat_holdout = false;
|
||||
@@ -317,9 +316,6 @@ GPENCIL_tLayer *grease_pencil_layer_cache_add(GPENCIL_Instance *inst,
|
||||
const float vert_col_opacity = (override_vertcol) ?
|
||||
(is_vert_col_mode ? inst->vertex_paint_opacity : 0.0f) :
|
||||
(inst->is_render ? 1.0f : inst->vertex_paint_opacity);
|
||||
/* Negate thickness sign to tag that strokes are in screen space (this is no longer used in
|
||||
* GPv3). Convert to world units (by default, 1 meter = 1000 pixels). */
|
||||
const float thickness_scale = blender::bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR;
|
||||
/* If the layer is used as a mask (but is otherwise not visible in the render), render it with a
|
||||
* opacity of 0 so that it can still mask other layers. */
|
||||
const float layer_opacity = !is_used_as_mask ? grease_pencil_layer_final_opacity_get(
|
||||
@@ -454,10 +450,6 @@ GPENCIL_tLayer *grease_pencil_layer_cache_add(GPENCIL_Instance *inst,
|
||||
pass.bind_texture("gpMaskTexture", mask_tex);
|
||||
pass.push_constant("gpNormal", tgp_ob->plane_normal);
|
||||
pass.push_constant("gpStrokeOrder3d", tgp_ob->is_drawmode3d);
|
||||
pass.push_constant("gpThicknessScale", tgp_ob->object_scale);
|
||||
/* Replaced by a modifier in GPv3. */
|
||||
pass.push_constant("gpThicknessOffset", 0.0f);
|
||||
pass.push_constant("gpThicknessWorldScale", thickness_scale);
|
||||
pass.push_constant("gpVertexColorOpacity", vert_col_opacity);
|
||||
|
||||
pass.bind_texture("gpFillTexture", inst->dummy_tx);
|
||||
|
||||
@@ -136,8 +136,6 @@ typedef struct GPENCIL_tObject {
|
||||
|
||||
/* Distance to camera. Used for sorting. */
|
||||
float camera_z;
|
||||
/* Used for stroke thickness scaling. */
|
||||
float object_scale;
|
||||
/* Normal used for shading. Based on view angle. */
|
||||
float3 plane_normal;
|
||||
/* Used for drawing depth merge pass. */
|
||||
|
||||
@@ -310,16 +310,10 @@ class GreasePencil : Overlay {
|
||||
const Vector<DrawingInfo> drawings = retrieve_visible_drawings(*scene, grease_pencil, true);
|
||||
for (const DrawingInfo info : drawings) {
|
||||
|
||||
const float object_scale = mat4_to_scale(ob->object_to_world().ptr());
|
||||
const float thickness_scale = bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR;
|
||||
|
||||
gpu::VertBuf *position_tx = draw::DRW_cache_grease_pencil_position_buffer_get(scene, ob);
|
||||
gpu::VertBuf *color_tx = draw::DRW_cache_grease_pencil_color_buffer_get(scene, ob);
|
||||
|
||||
pass.push_constant("gpStrokeOrder3d", is_stroke_order_3d);
|
||||
pass.push_constant("gpThicknessScale", object_scale);
|
||||
pass.push_constant("gpThicknessOffset", 0.0f);
|
||||
pass.push_constant("gpThicknessWorldScale", thickness_scale);
|
||||
pass.bind_texture("gp_pos_tx", position_tx);
|
||||
pass.bind_texture("gp_col_tx", color_tx);
|
||||
|
||||
|
||||
@@ -1212,9 +1212,6 @@ static void grease_pencil_geom_batch_ensure(Object &object,
|
||||
* use negative values as a special 'flag' to get rounded caps. */
|
||||
s_vert.radius = math::max(radii[point_i], 0.0f) *
|
||||
((end_cap == GP_STROKE_CAP_TYPE_ROUND) ? 1.0f : -1.0f);
|
||||
/* Convert to legacy "pixel" space. We divide here, because the shader expects the values to
|
||||
* be in the `px` space rather than world space. Otherwise the values will get clamped. */
|
||||
s_vert.radius /= bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR;
|
||||
s_vert.opacity = opacities[point_i] *
|
||||
((start_cap == GP_STROKE_CAP_TYPE_ROUND) ? 1.0f : -1.0f);
|
||||
s_vert.point_id = verts_range[idx];
|
||||
|
||||
@@ -75,18 +75,20 @@ vec2 gpencil_project_to_screenspace(vec4 v, vec4 viewport_size)
|
||||
|
||||
float gpencil_stroke_thickness_modulate(float thickness, vec4 ndc_pos, vec4 viewport_size)
|
||||
{
|
||||
/* Modify stroke thickness by object and layer factors. */
|
||||
thickness = max(1.0, thickness * gpThicknessScale + gpThicknessOffset);
|
||||
/* Modify stroke thickness by object scale. */
|
||||
thickness = length(to_float3x3(drw_modelmat()) * vec3(thickness * M_SQRT1_3));
|
||||
|
||||
/* For compatibility, thickness has to be clamped after being multiplied by this factor.
|
||||
* This clamping was introduced to reduce aliasing issue by instead fading the lines alpha at
|
||||
* smaller radii. This can be removed in major release if compatibility is not a concern. */
|
||||
const float legacy_radius_conversion_factor = 2000.0;
|
||||
thickness *= legacy_radius_conversion_factor;
|
||||
thickness = max(1.0, thickness);
|
||||
thickness /= legacy_radius_conversion_factor;
|
||||
|
||||
/* World space point size. */
|
||||
thickness *= drw_view().winmat[1][1] * viewport_size.y;
|
||||
|
||||
if (gpThicknessIsScreenSpace) {
|
||||
/* Multiply offset by view Z so that offset is constant in screen-space.
|
||||
* (e.i: does not change with the distance to camera) */
|
||||
thickness *= ndc_pos.w;
|
||||
}
|
||||
else {
|
||||
/* World space point size. */
|
||||
thickness *= gpThicknessWorldScale * drw_view().winmat[1][1] * viewport_size.y;
|
||||
}
|
||||
return thickness;
|
||||
}
|
||||
|
||||
|
||||
@@ -103,12 +103,6 @@ TYPEDEF_SOURCE("gpencil_shader_shared.h")
|
||||
DEFINE("DRW_GPENCIL_INFO")
|
||||
SAMPLER(0, FLOAT_BUFFER, gp_pos_tx)
|
||||
SAMPLER(1, FLOAT_BUFFER, gp_col_tx)
|
||||
/* Per Object */
|
||||
PUSH_CONSTANT(FLOAT, gpThicknessScale) /* TODO(fclem): Replace with object info. */
|
||||
PUSH_CONSTANT(FLOAT, gpThicknessWorldScale) /* TODO(fclem): Same as above. */
|
||||
DEFINE_VALUE("gpThicknessIsScreenSpace", "(gpThicknessWorldScale < 0.0)")
|
||||
/* Per Layer */
|
||||
PUSH_CONSTANT(FLOAT, gpThicknessOffset)
|
||||
ADDITIONAL_INFO(draw_resource_id_varying)
|
||||
ADDITIONAL_INFO(draw_view)
|
||||
ADDITIONAL_INFO(draw_object_infos)
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
# define USE_WORLD_CLIP_PLANES
|
||||
|
||||
# define DRW_VIEW_LEN DRW_VIEW_MAX
|
||||
# define gpThicknessIsScreenSpace (gpThicknessWorldScale < 0.0)
|
||||
#endif
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
Reference in New Issue
Block a user