mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-28 18:41:14 +00:00
filter/blur: Don't pass bool as TEXCOORD1
Using a 'bool' as TEXCOORD1 is undefined behavior, so we should not abuse the intermediate shading storage like this. Fixes #559
This commit is contained in:
parent
cda430ccad
commit
1fcd141f10
2 changed files with 5 additions and 8 deletions
|
@ -65,20 +65,19 @@ struct VertDataIn {
|
|||
struct VertDataOut {
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
bool is_odd : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertDataOut VSDefault(VertDataIn vtx) {
|
||||
VertDataOut vert_out;
|
||||
vert_out.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj);
|
||||
vert_out.uv = vtx.uv;
|
||||
vert_out.is_odd = ((int(round(pSize)) % 2) == 1);
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
// Blur 1 Dimensional
|
||||
float4 PSBlur1D(VertDataOut vtx) : TARGET {
|
||||
float4 final = pImage.Sample(linearSampler, vtx.uv);
|
||||
bool is_odd = ((int(round(pSize)) % 2) == 1);
|
||||
|
||||
// y = yes, s = skip, b = break
|
||||
// Size-> | 1| 2| 3| 4| 5| 6| 7|
|
||||
|
@ -104,7 +103,7 @@ float4 PSBlur1D(VertDataOut vtx) : TARGET {
|
|||
final += pImage.Sample(linearSampler, vtx.uv + nstep) * 2.;
|
||||
final += pImage.Sample(linearSampler, vtx.uv - nstep) * 2.;
|
||||
}
|
||||
if (vtx.is_odd) {
|
||||
if (is_odd) {
|
||||
float2 nstep = (pImageTexel * pStepScale) * pSize;
|
||||
final += pImage.Sample(linearSampler, vtx.uv + nstep);
|
||||
final += pImage.Sample(linearSampler, vtx.uv - nstep);
|
||||
|
|
|
@ -71,14 +71,12 @@ struct VertDataIn {
|
|||
struct VertDataOut {
|
||||
float4 pos : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
bool is_odd : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertDataOut VSDefault(VertDataIn vtx) {
|
||||
VertDataOut vert_out;
|
||||
vert_out.pos = mul(float4(vtx.pos.xyz, 1.0), ViewProj);
|
||||
vert_out.uv = vtx.uv;
|
||||
vert_out.is_odd = ((int(round(pSize)) % 2) == 1);
|
||||
return vert_out;
|
||||
}
|
||||
|
||||
|
@ -89,8 +87,8 @@ float GetKernelAt(int i) {
|
|||
|
||||
// Blur 1 Dimensional
|
||||
float4 PSBlur1D(VertDataOut vtx) : TARGET {
|
||||
float4 final = pImage.Sample(linearSampler, vtx.uv)
|
||||
* GetKernelAt(0);
|
||||
float4 final = pImage.Sample(linearSampler, vtx.uv) * GetKernelAt(0);
|
||||
bool is_odd = ((int(round(pSize)) % 2) == 1);
|
||||
|
||||
// y = yes, s = skip, b = break
|
||||
// Size-> | 1| 2| 3| 4| 5| 6| 7|
|
||||
|
@ -118,7 +116,7 @@ float4 PSBlur1D(VertDataOut vtx) : TARGET {
|
|||
final += pImage.Sample(linearSampler, vtx.uv + nstep) * kernel;
|
||||
final += pImage.Sample(linearSampler, vtx.uv - nstep) * kernel;
|
||||
}
|
||||
if (vtx.is_odd) {
|
||||
if (is_odd) {
|
||||
float kernel = GetKernelAt(pSize);
|
||||
float2 nstep = (pImageTexel * pStepScale) * pSize;
|
||||
final += pImage.Sample(linearSampler, vtx.uv + nstep) * kernel;
|
||||
|
|
Loading…
Reference in a new issue