3D engine that AI agents drive
Merge the uv varying declarations to keep the shader no larger (part of #388)
Nguyen Xuan An01797056a224
diff --git a/src/impostor-shader.js b/src/impostor-shader.jsindex d93012f5..7ed0caff 100644--- a/src/impostor-shader.js+++ b/src/impostor-shader.js@@ -107,12 +107,12 @@ vec2 pickCardUV() {`;function addViewBlend(source) {- if (!source.includes('in vec2 textureUV;') || !source.includes('void main() {')) return source;+ if (!source.includes('in vec2 textureUV, lightmapUV;') || !source.includes('void main() {')) return source;const gradients = 'dFdx(textureUV), dFdy(textureUV)';return source.replace('texture(baseMap, textureUV)', () => `textureGrad(baseMap, cardUV, ${gradients})`).replace(/texture\(normalMap, textureUV([^)]*)\)/, (match, transform) => `textureGrad(normalMap, cardUV${transform}, ${gradients})`)- .replace('in vec2 textureUV;', () => `in vec2 textureUV;\n${VIEW_BLEND_FRAGMENT}`)+ .replace('in vec2 textureUV, lightmapUV;', () => `in vec2 textureUV, lightmapUV;\n${VIEW_BLEND_FRAGMENT}`).replace('void main() {', () => 'void main() {\n cardUV = pickCardUV();');}diff --git a/src/shaders.js b/src/shaders.jsindex d0b8d49b..a2b5ca31 100644--- a/src/shaders.js+++ b/src/shaders.js@@ -70,13 +70,11 @@ uniform float wind;uniform float explosionProgress;uniform vec3 explosionCenter;uniform float assemblyAmount;-out vec3 worldPosition;-out vec3 worldNormal;+out vec3 worldPosition, worldNormal;flat out vec3 baseColor;flat out vec4 surface;out vec4 shadowPosition;-out vec2 textureUV;-out vec2 lightmapUV;+out vec2 textureUV, lightmapUV;out vec3 vertexTint;out float vertexSkyVisibility;flat out vec4 instanceEmission;@@ -200,13 +198,11 @@ function buildFragmentShader(featureDefines, featureCode) {return `#version 300 es${featureDefines}precision highp float;-in vec3 worldPosition;-in vec3 worldNormal;+in vec3 worldPosition, worldNormal;flat in vec3 baseColor;flat in vec4 surface;in vec4 shadowPosition;-in vec2 textureUV;-in vec2 lightmapUV;+in vec2 textureUV, lightmapUV;in vec3 vertexTint;in float vertexSkyVisibility;flat in vec4 instanceEmission;