Fix bugs
This commit is contained in:
parent
1d4980ae28
commit
e8cd979f53
3 changed files with 8 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -7,8 +7,10 @@ export class FragmentShaderOnlyProgram extends Program {
|
|||
private vertexArrayExtension: any;
|
||||
constructor(gl: UniversalRenderingContext) {
|
||||
super(gl);
|
||||
if (!gl.isWebGL2) {
|
||||
this.vertexArrayExtension = enableExtension(this.gl, 'OES_vertex_array_object');
|
||||
}
|
||||
}
|
||||
|
||||
public async initialize(
|
||||
sources: [string, string],
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue