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: {
|
sdf: {
|
||||||
shader: `
|
shader: `
|
||||||
uniform vec2 circleCenters[CIRCLE_COUNT];
|
uniform vec2 circleCenters[CIRCLE_COUNT];
|
||||||
uniform vec2 circleRadii[CIRCLE_COUNT];
|
uniform float circleRadii[CIRCLE_COUNT];
|
||||||
|
|
||||||
void circleMinDistance(inout float minDistance, inout float color) {
|
void circleMinDistance(inout float minDistance, inout float color) {
|
||||||
float myMinDistance = maxMinDistance;
|
float myMinDistance = maxMinDistance;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ export class FragmentShaderOnlyProgram extends Program {
|
||||||
private vertexArrayExtension: any;
|
private vertexArrayExtension: any;
|
||||||
constructor(gl: UniversalRenderingContext) {
|
constructor(gl: UniversalRenderingContext) {
|
||||||
super(gl);
|
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(
|
public async initialize(
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ in vec2 uvCoordinates;
|
||||||
|
|
||||||
uniform vec3 ambientLight;
|
uniform vec3 ambientLight;
|
||||||
|
|
||||||
vec3[colorCount] colors = vec3[](
|
vec3[{colorCount}] colors = vec3[](
|
||||||
{palette}
|
{palette}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2
|
||||||
float rayLength = startingDistance;
|
float rayLength = startingDistance;
|
||||||
|
|
||||||
for (int j = 0; j < SHADOW_TRACE_COUNT; j++) {
|
for (int j = 0; j < SHADOW_TRACE_COUNT; j++) {
|
||||||
rayLength += getDistance(uvCoordinates + direction * rayLength);
|
rayLength += max(0.0, getDistance(uvCoordinates + direction * rayLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
return min(
|
return min(
|
||||||
|
|
@ -57,7 +57,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2
|
||||||
in vec2[CIRCLE_LIGHT_COUNT] circleLightDirections;
|
in vec2[CIRCLE_LIGHT_COUNT] circleLightDirections;
|
||||||
|
|
||||||
vec3 colorInPosition(int lightIndex, out float lightCenterDistance) {
|
vec3 colorInPosition(int lightIndex, out float lightCenterDistance) {
|
||||||
lightCenterDistance = distance(circleLightCenters[lightIndex], position);
|
lightCenterDistance = max(0.0, distance(circleLightCenters[lightIndex], position));
|
||||||
return circleLightColors[lightIndex] / pow(
|
return circleLightColors[lightIndex] / pow(
|
||||||
lightCenterDistance / circleLightIntensities[lightIndex] + 1.0, 2.0
|
lightCenterDistance / circleLightIntensities[lightIndex] + 1.0, 2.0
|
||||||
);
|
);
|
||||||
|
|
@ -98,7 +98,7 @@ float shadowTransparency(float startingDistance, float lightCenterDistance, vec2
|
||||||
return intensityInDirection(flashlightDirections[lightIndex], positionDirection) *
|
return intensityInDirection(flashlightDirections[lightIndex], positionDirection) *
|
||||||
flashlightColors[lightIndex] / pow(
|
flashlightColors[lightIndex] / pow(
|
||||||
lightCenterDistance / (flashlightIntensities[lightIndex] * INTENSITY_INSIDE_RATIO) + 1.0, 2.0
|
lightCenterDistance / (flashlightIntensities[lightIndex] * INTENSITY_INSIDE_RATIO) + 1.0, 2.0
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue