Fix inverted bug
This commit is contained in:
parent
d1dd360d83
commit
5723b91b32
3 changed files with 11 additions and 18 deletions
|
|
@ -24,8 +24,8 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
||||||
public async initialize(
|
public async initialize(
|
||||||
shaderSources: [string, string],
|
shaderSources: [string, string],
|
||||||
descriptors: Array<DrawableDescriptor>,
|
descriptors: Array<DrawableDescriptor>,
|
||||||
substitutions: { [name: string]: any },
|
compiler: ParallelCompiler,
|
||||||
compiler: ParallelCompiler
|
substitutions: { [name: string]: any } = {}
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
this.descriptors = descriptors;
|
this.descriptors = descriptors;
|
||||||
|
|
||||||
|
|
@ -118,7 +118,7 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
||||||
};
|
};
|
||||||
|
|
||||||
const program = new FragmentShaderOnlyProgram(this.gl);
|
const program = new FragmentShaderOnlyProgram(this.gl);
|
||||||
await program.initialize(shaderSources, processedSubstitutions, compiler);
|
await program.initialize(shaderSources, compiler, processedSubstitutions);
|
||||||
|
|
||||||
this.programs.push({
|
this.programs.push({
|
||||||
program,
|
program,
|
||||||
|
|
@ -161,10 +161,6 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
||||||
}
|
}
|
||||||
|
|
||||||
return `
|
return `
|
||||||
#ifndef NOT_EMPTY
|
|
||||||
#define NOT_EMPTY
|
|
||||||
#endif
|
|
||||||
|
|
||||||
objectMinDistance = ${
|
objectMinDistance = ${
|
||||||
descriptors[i].sdf!.distanceFunctionName
|
descriptors[i].sdf!.distanceFunctionName
|
||||||
}(position, objectColor);
|
}(position, objectColor);
|
||||||
|
|
@ -179,7 +175,12 @@ export class UniformArrayAutoScalingProgram implements IProgram {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
minDistance = min(minDistance, objectMinDistance);
|
${
|
||||||
|
descriptors[i].sdf?.isInverted
|
||||||
|
? 'minDistance = max(minDistance, objectMinDistance);'
|
||||||
|
: 'minDistance = min(minDistance, objectMinDistance);'
|
||||||
|
}
|
||||||
|
|
||||||
`;
|
`;
|
||||||
})
|
})
|
||||||
.join('\n');
|
.join('\n');
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,12 @@ varying vec2 position;
|
||||||
{declarations}
|
{declarations}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float minDistance = abs(maxMinDistance);
|
float minDistance = maxMinDistance;
|
||||||
float color = 0.0;
|
float color = 0.0;
|
||||||
|
|
||||||
float objectMinDistance, objectColor;
|
float objectMinDistance, objectColor;
|
||||||
|
|
||||||
{functionCalls}
|
{functionCalls}
|
||||||
|
|
||||||
#ifndef NOT_EMPTY
|
|
||||||
minDistance = maxMinDistance;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gl_FragColor = vec4(minDistance * 8.0, color, 0.0, 1.0);
|
gl_FragColor = vec4(minDistance * 8.0, color, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,16 +13,12 @@ in vec2 position;
|
||||||
out vec2 fragmentColor;
|
out vec2 fragmentColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
float minDistance = abs(maxMinDistance);
|
float minDistance = maxMinDistance;
|
||||||
float color = 0.0;
|
float color = 0.0;
|
||||||
|
|
||||||
float objectMinDistance, objectColor;
|
float objectMinDistance, objectColor;
|
||||||
|
|
||||||
{functionCalls}
|
{functionCalls}
|
||||||
|
|
||||||
#ifndef NOT_EMPTY
|
|
||||||
minDistance = maxMinDistance;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fragmentColor = vec2(minDistance, color);
|
fragmentColor = vec2(minDistance, color);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue