EEVEE: Speedup: Don't request orco layer if not needed
Should speed up eevee mesh update a tiny bit in certain particular cases (deform modifier + (shader using texcoord (but not generated output) OR principled bsdf OR geometry node (except tangent output))).
This commit is contained in:
parent
ad22d3111f
commit
1c1a3198af
Notes:
blender-bot
2023-02-14 01:52:41 +01:00
Referenced by issue #70428, CYCLES: Surfaces inside volumes are Not Lit or Shadowed by the volume if the volume is not visible to Camera Rays Referenced by issue #70379, Disabling combined RGBA pass for view layer does nothing Referenced by issue #70345, viewport display not showing the correct object transform (location & scale) with the lastest nightly build Referenced by issue #70338, Memory Increased Referenced by issue #70310, Difficult to change brush size from big to small (both in Sculpting mode/texture mode)
|
@ -120,6 +120,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
|
|||
GPU_link(mat, "world_normals_get", &in[20].link);
|
||||
}
|
||||
|
||||
#if 0 /* Not used at the moment. */
|
||||
/* Tangents */
|
||||
if (!in[21].link) {
|
||||
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
|
||||
|
@ -131,6 +132,7 @@ static int node_shader_gpu_bsdf_principled(GPUMaterial *mat,
|
|||
GPU_builtin(GPU_OBJECT_MATRIX),
|
||||
&in[21].link);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool use_diffuse = socket_not_one(4) && socket_not_one(15);
|
||||
bool use_subsurf = socket_not_zero(1) && use_diffuse && node->sss_id > 0;
|
||||
|
|
|
@ -41,9 +41,11 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
|
|||
{
|
||||
/* HACK: Don't request GPU_BARYCENTRIC_TEXCO if not used because it will
|
||||
* trigger the use of geometry shader (and the performance penalty it implies). */
|
||||
float val[2] = {0.0f, 0.0f};
|
||||
float val[4] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
GPUNodeLink *bary_link = (!out[5].hasoutput) ? GPU_constant(val) :
|
||||
GPU_builtin(GPU_BARYCENTRIC_TEXCO);
|
||||
/* Opti: don't request orco if not needed. */
|
||||
GPUNodeLink *orco_link = (!out[2].hasoutput) ? GPU_constant(val) : GPU_attribute(CD_ORCO, "");
|
||||
|
||||
return GPU_stack_link(mat,
|
||||
node,
|
||||
|
@ -52,7 +54,7 @@ static int node_shader_gpu_geometry(GPUMaterial *mat,
|
|||
out,
|
||||
GPU_builtin(GPU_VIEW_POSITION),
|
||||
GPU_builtin(GPU_WORLD_NORMAL),
|
||||
GPU_attribute(CD_ORCO, ""),
|
||||
orco_link,
|
||||
GPU_builtin(GPU_OBJECT_MATRIX),
|
||||
GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
|
||||
bary_link);
|
||||
|
|
|
@ -45,14 +45,17 @@ static int node_shader_gpu_tex_coord(GPUMaterial *mat,
|
|||
GPUNodeLink *inv_obmat = (ob != NULL) ? GPU_uniform(&ob->imat[0][0]) :
|
||||
GPU_builtin(GPU_INVERSE_OBJECT_MATRIX);
|
||||
|
||||
/* TODO only request orco if needed. */
|
||||
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
|
||||
/* Opti: don't request orco if not needed. */
|
||||
GPUNodeLink *orco = (!out[0].hasoutput) ? GPU_constant((float[4]){0.0f, 0.0f, 0.0f, 0.0f}) :
|
||||
GPU_attribute(CD_ORCO, "");
|
||||
GPUNodeLink *mtface = GPU_attribute(CD_MTFACE, "");
|
||||
GPUNodeLink *viewpos = GPU_builtin(GPU_VIEW_POSITION);
|
||||
GPUNodeLink *worldnor = GPU_builtin(GPU_WORLD_NORMAL);
|
||||
GPUNodeLink *texcofacs = GPU_builtin(GPU_CAMERA_TEXCO_FACTORS);
|
||||
|
||||
GPU_link(mat, "generated_from_orco", orco, &orco);
|
||||
if (out[0].hasoutput) {
|
||||
GPU_link(mat, "generated_from_orco", orco, &orco);
|
||||
}
|
||||
|
||||
GPU_stack_link(
|
||||
mat, node, "node_tex_coord", in, out, viewpos, worldnor, inv_obmat, texcofacs, orco, mtface);
|
||||
|
|
Loading…
Reference in New Issue