diff --git a/src/drawables/shapes/circle.ts b/src/drawables/shapes/circle.ts index ea352bf..9d27426 100644 --- a/src/drawables/shapes/circle.ts +++ b/src/drawables/shapes/circle.ts @@ -7,7 +7,7 @@ export class Circle extends Drawable { sdf: { shader: ` uniform vec2 circleCenters[CIRCLE_COUNT]; - uniform vec2 circleRadii[CIRCLE_COUNT]; + uniform float circleRadii[CIRCLE_COUNT]; void circleMinDistance(inout float minDistance, inout float color) { float myMinDistance = maxMinDistance; diff --git a/src/graphics/graphics-library/program/fragment-shader-only-program.ts b/src/graphics/graphics-library/program/fragment-shader-only-program.ts index 3647083..a08a7b6 100644 --- a/src/graphics/graphics-library/program/fragment-shader-only-program.ts +++ b/src/graphics/graphics-library/program/fragment-shader-only-program.ts @@ -7,7 +7,9 @@ export class FragmentShaderOnlyProgram extends Program { private vertexArrayExtension: any; constructor(gl: UniversalRenderingContext) { super(gl); - this.vertexArrayExtension = enableExtension(this.gl, 'OES_vertex_array_object'); + if (!gl.isWebGL2) { + this.vertexArrayExtension = enableExtension(this.gl, 'OES_vertex_array_object'); + } } public async initialize( diff --git a/src/graphics/rendering/shaders/shading-fs.glsl b/src/graphics/rendering/shaders/shading-fs.glsl index c519ead..f54aa70 100644 --- a/src/graphics/rendering/shaders/shading-fs.glsl +++ b/src/graphics/rendering/shaders/shading-fs.glsl @@ -18,7 +18,7 @@ in vec2 uvCoordinates; uniform vec3 ambientLight; -vec3[colorCount] colors = vec3[]( +vec3[{colorCount}] colors = vec3[]( {palette} ); @@ -36,7 +36,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2 float rayLength = startingDistance; for (int j = 0; j < SHADOW_TRACE_COUNT; j++) { - rayLength += getDistance(uvCoordinates + direction * rayLength); + rayLength += max(0.0, getDistance(uvCoordinates + direction * rayLength)); } return min( @@ -57,7 +57,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2 in vec2[CIRCLE_LIGHT_COUNT] circleLightDirections; vec3 colorInPosition(int lightIndex, out float lightCenterDistance) { - lightCenterDistance = distance(circleLightCenters[lightIndex], position); + lightCenterDistance = max(0.0, distance(circleLightCenters[lightIndex], position)); return circleLightColors[lightIndex] / pow( lightCenterDistance / circleLightIntensities[lightIndex] + 1.0, 2.0 ); @@ -98,7 +98,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2 return intensityInDirection(flashlightDirections[lightIndex], positionDirection) * flashlightColors[lightIndex] / pow( lightCenterDistance / (flashlightIntensities[lightIndex] * INTENSITY_INSIDE_RATIO) + 1.0, 2.0 - ); + )); } #endif #endif