mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 05:18:08 +02:00
mesa/main: fix distance attenuation calculation in ffvertex
The dist parameter to calculate_light_attenuation() is the
reciprocal of ||VP|| used in the distance attenuation formula (2.4).
So get its reciprocal first before applying it to the distance attenuation
formula.
This fixes a lighting issue in Knights of the Old Republic.
Fixes: c5b3d488f9 ("mesa/main: make ffvertex output nir")
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collaborar.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23404>
This commit is contained in:
parent
049c791a63
commit
e2927dd5e7
1 changed files with 6 additions and 0 deletions
|
|
@ -679,6 +679,12 @@ calculate_light_attenuation(struct tnl_program *p,
|
|||
STATE_ATTENUATION, 0);
|
||||
}
|
||||
|
||||
/* dist is the reciprocal of ||VP|| used in the distance
|
||||
* attenuation formula. So need to get the reciprocal of dist first
|
||||
* before applying to the formula.
|
||||
*/
|
||||
dist = nir_frcp(p->b, dist);
|
||||
|
||||
/* 1, d, d*d */
|
||||
nir_ssa_def *tmp = nir_vec3(p->b,
|
||||
nir_imm_float(p->b, 1.0f),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue