# DX11 DX11 - Troubles with weighting

This topic is 2099 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys  ,

so I've been trying to get this weighting function right, but it isn't working as expected, the result and how I do it:

Supposed to look like: (The one on the left)

Though, I get this result:

Here's how I do it:

float2 texcoord = -input.Tex+ float2(1.0, 1.0);

// ghost vector to image centre + halo vector based from ghost
float2 ghostVec = (float2(0.5,0.5) - texcoord) * uGhostDispersal;
float2 haloVec = normalize(ghostVec) * uHaloWidth;

...

// get the weight
float weight = length(float2(0.5,0.5) - frac(texcoord + haloVec)) / length(float2(0.5,0.5));
weight = pow(1.0 - weight, 10.0f);
return float4(weight,weight,weight,1);


How it's done by the guide I'm reading: (Yeah, not HLSL)

vec2 texcoord = -vTexcoord + vec2(1.0); // flip texcoordoords

vec2 ghostVec = (vec2(0.5) - texcoord) * uDispersal;
vec2 haloVec = normalize(ghostVec) * uHaloWidth;

//	sample halo: -----HERE
float weight = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));
weight = pow(1.0 - weight, 10.0);

fResult = result;



His and my constants:

MY:
static float uGhostDispersal = 0.25; // Same as uDispersal
static float uHaloWidth = 1.0;
static float uDistortion = 1.0;

HIS:
uniform float uDispersal = 0.25;
uniform float uHaloWidth = 1.0;
uniform float uDistortion = 1.0;


So what on earth could I be doing wrong? ( Like usual  )

Thank you for your time, appreciate it.

-MIGI0027

Edited by Migi0027

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 14
• 30
• 9
• 16
• 22