Fix rendering issues

This commit is contained in:
schmelczerandras 2020-08-16 09:15:09 +02:00
parent 56dca9fa60
commit eb39846b75
7 changed files with 25 additions and 29 deletions

View file

@ -4,8 +4,6 @@ services:
declared-frontend: declared-frontend:
init: true init: true
image: schmelczera/declared-frontend image: schmelczera/declared-frontend
ports:
- "80"
networks: networks:
- network - network
deploy: deploy:

View file

@ -6,7 +6,6 @@
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "webpack-dev-server --mode development", "start": "webpack-dev-server --mode development",
"start-unsafe": "webpack-dev-server --mode development --useLocalIp",
"build": "webpack && find dist -type f -not -name '*.html' | xargs rm" "build": "webpack && find dist -type f -not -name '*.html' | xargs rm"
}, },
"keywords": [], "keywords": [],

View file

@ -23,7 +23,6 @@ export const settings = {
shaderMacros: { shaderMacros: {
distanceScale: 64, distanceScale: 64,
distanceOffset: 0.15, distanceOffset: 0.15,
//edgeSmoothing: 0,
edgeSmoothing: 10, edgeSmoothing: 10,
}, },
shaderCombinations: { shaderCombinations: {

View file

@ -29,10 +29,10 @@ void main() {
float minDistance = maxMinDistance; float minDistance = maxMinDistance;
for (int i = 0; i < LINE_COUNT; i++) { for (int i = 0; i < LINE_COUNT; i++) {
vec2 pa = worldCoordinates - lines[i].from; vec2 targetFromDelta = worldCoordinates - lines[i].from;
vec2 ba = lines[i].toFromDelta; vec2 toFromDelta = lines[i].toFromDelta;
float h = clamp(dot(pa, ba) / dot(ba, ba), 0.0, 1.0); float h = clamp(dot(targetFromDelta, toFromDelta) / dot(toFromDelta, toFromDelta), 0.0, 1.0);
float lineDistance = distance(pa, ba * h) - mix(lines[i].fromRadius, lines[i].toRadius, h); float lineDistance = distance(targetFromDelta, toFromDelta * h) - mix(lines[i].fromRadius, lines[i].toRadius, h);
minDistance = min(minDistance, lineDistance); minDistance = min(minDistance, lineDistance);
} }
@ -42,6 +42,7 @@ void main() {
fragmentColor = vec4( fragmentColor = vec4(
mix(CAVE_COLOR, AIR_COLOR, clamp(realDistance, 0.0, 1.0)), mix(CAVE_COLOR, AIR_COLOR, clamp(realDistance, 0.0, 1.0)),
(realDistance + DISTANCE_OFFSET) / DISTANCE_SCALE - 1.0/255.0 (realDistance + DISTANCE_OFFSET) / DISTANCE_SCALE
); );
} }

View file

@ -4,7 +4,6 @@ precision mediump float;
#define INFINITY 1000.0 #define INFINITY 1000.0
#define LIGHT_DROP 500.0 #define LIGHT_DROP 500.0
#define MIN_STEP 1.0
#define AMBIENT_LIGHT vec3(0.15) #define AMBIENT_LIGHT vec3(0.15)
#define CIRCLE_LIGHT_COUNT {circleLightCount} #define CIRCLE_LIGHT_COUNT {circleLightCount}
@ -59,9 +58,6 @@ void main() {
for (int i = 0; i < CIRCLE_LIGHT_COUNT; i++) { for (int i = 0; i < CIRCLE_LIGHT_COUNT; i++) {
float lightCenterDistance = distance(circleLights[i].center, worldCoordinates); float lightCenterDistance = distance(circleLights[i].center, worldCoordinates);
/*if (lightCenterDistance < circleLights[i].radius) {
lighting = vec3(1.0, 1.0, 0.0);
}*/
vec3 lightColorAtPosition = circleLights[i].value / pow( vec3 lightColorAtPosition = circleLights[i].value / pow(
lightCenterDistance / LIGHT_DROP + 1.0, 2.0 lightCenterDistance / LIGHT_DROP + 1.0, 2.0
@ -73,19 +69,22 @@ void main() {
vec2 direction = normalize(circleLightDirections[i]) / viewBoxSize; vec2 direction = normalize(circleLightDirections[i]) / viewBoxSize;
for (int j = 0; j < 48; j++) { for (int j = 0; j < 48; j++) {
if (rayLength > lightCenterDistance) { if (rayLength > lightCenterDistance - circleLights[i].radius) {
rayLength = lightCenterDistance - circleLights[i].radius;
float minDistance = getDistance(uvCoordinates + direction * rayLength);
exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0;
q = min(q, exponentialDecayDistance / rayLength);
lighting += lightColorAtPosition * clamp( lighting += lightColorAtPosition * clamp(
q / circleLights[i].radius * (lightCenterDistance + 1.0), 0.0, 1.0 q / circleLights[i].radius * (lightCenterDistance + 1.0), 0.0, 1.0
) * step(circleLights[i].radius, getDistance( );
uvCoordinates + direction * lightCenterDistance
));
break; break;
} }
float minDistance = getDistance(uvCoordinates + direction * rayLength); float minDistance = getDistance(uvCoordinates + direction * rayLength);
exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0; exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0;
q = min(q, exponentialDecayDistance / rayLength); q = min(q, exponentialDecayDistance / rayLength);
rayLength += max(MIN_STEP, minDistance); rayLength += minDistance;
} }
} }
#endif #endif
@ -115,7 +114,7 @@ void main() {
float minDistance = getDistance(uvCoordinates + direction * rayLength); float minDistance = getDistance(uvCoordinates + direction * rayLength);
exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0; exponentialDecayDistance = (exponentialDecayDistance + minDistance) / 2.0;
q = min(q, exponentialDecayDistance); q = min(q, exponentialDecayDistance);
rayLength += max(MIN_STEP, minDistance); rayLength += minDistance;
} }
} }
#endif #endif

View file

@ -43,15 +43,15 @@ export class Character extends GameObject {
const nextPrimitive = this.primitive.clone(); const nextPrimitive = this.primitive.clone();
nextPrimitive.center = value; nextPrimitive.center = value;
if ( const intersects = this.physics
this.physics
.findIntersecting(nextPrimitive.boundingBox) .findIntersecting(nextPrimitive.boundingBox)
.filter((b) => b.value) .filter((b) => b.value)
.map( .map(
(b) => b.value.distance(nextPrimitive.center) + nextPrimitive.radius (b) => b.value.distance(nextPrimitive.center) + nextPrimitive.radius
) );
.find((d) => d < 0) !== undefined
) { console.log(intersects);
if (intersects.find((d) => d < 0) !== undefined) {
this.setPosition(value); this.setPosition(value);
} }
} }