Fix uncleared uniforms bug

This commit is contained in:
schmelczerandras 2020-10-02 11:23:33 +02:00
parent 374796f398
commit 81eb0220d2
5 changed files with 20 additions and 2 deletions

View file

@ -52,6 +52,8 @@ export interface DrawableDescriptor {
*
* For each step, a shader will be generated. And at runtime the closes matching
* shader will be used to render a given part of the scene.
*
* Must contain 0 as a value.
*/
shaderCombinationSteps: Array<number>;

View file

@ -33,6 +33,7 @@ export abstract class Drawable {
*/
protected abstract getObjectToSerialize(transform2d: mat2d, transform1d: number): any;
/** @internal */
public serializeToUniforms(
uniforms: any,
transform2d: mat2d,

View file

@ -31,6 +31,8 @@ export class UniformArrayAutoScalingProgram implements IProgram {
const promises: Array<Promise<void>> = [];
this.checkDescriptorValidity(descriptors);
for (const combination of getCombinations(
descriptors.map((o) => o.shaderCombinationSteps)
)) {
@ -48,6 +50,19 @@ export class UniformArrayAutoScalingProgram implements IProgram {
await Promise.all(promises);
}
private checkDescriptorValidity(descriptors: Array<DrawableDescriptor>) {
const descriptorsWithoutZero = descriptors.filter(
(d) => !d.shaderCombinationSteps.includes(0)
);
if (descriptorsWithoutZero.length > 0) {
throw new Error(
`Descriptors must contain a '0' step. Count macros for the offending descriptors: ${descriptorsWithoutZero.map(
(d) => d.uniformCountMacroName
)}`
);
}
}
public setDrawingRectangleUV(bottomLeft: vec2, size: vec2) {
this.drawingRectangleBottomLeft = bottomLeft;
this.drawingRectangleSize = size;

View file

@ -5,7 +5,7 @@ import { RuntimeSettings } from './runtime-settings';
* Contains the default values used for [[RuntimeSettings]].
*/
export const defaultRuntimeSettings: RuntimeSettings = {
enableHighDpiRendering: true,
enableHighDpiRendering: false,
tileMultiplier: 8,
isWorldInverted: false,
lightCutoffDistance: 400,

View file

@ -7,5 +7,5 @@ export const defaultStartupSettings: StartupSettings = {
shadowTraceCount: 16,
paletteSize: 256,
ignoreWebGL2: false,
enableStopwatch: true,
enableStopwatch: false,
};