From 68c5890568097560de1daa78ced5b3df822df58c Mon Sep 17 00:00:00 2001 From: Damien Seguin Date: Mon, 14 Jan 2019 09:14:38 +0000 Subject: [PATCH] Add shader precision handling with default setting and material specific override --- camera.js | 47 +++++++++-------- examples/postprocessing/index.js | 2 +- index.js | 52 +++++++++++++------ material.js | 1 + reflection-probe.js | 21 ++++---- shaders/error/error.frag.js | 2 - shaders/pipeline/depth-pass.frag.js | 2 - shaders/pipeline/depth-pre-pass.frag.js | 2 - shaders/pipeline/material.frag.js | 10 ++-- shaders/pipeline/overlay.frag.js | 2 - .../post-processing/bilateral-blur.frag.js | 2 - shaders/post-processing/bloom.frag.js | 2 - .../post-processing/post-processing.frag.js | 2 - shaders/post-processing/sao.frag.js | 2 - shaders/post-processing/threshold.frag.js | 2 - .../blit-to-oct-map-atlas.frag.js | 2 - .../convolve-oct-map-atlas-to-oct-map.frag.js | 2 - .../cubemap-to-octmap.frag.js | 2 - .../downsample-from-oct-map-atlas.frag.js | 2 - .../prefilter-from-oct-map-atlas.frag.js | 2 - shaders/skybox/sky-env-map.frag.js | 2 - shaders/skybox/sky-env-map.vert.js | 2 +- shaders/skybox/skybox.frag.js | 2 - skybox.js | 9 ++-- 24 files changed, 82 insertions(+), 94 deletions(-) diff --git a/camera.js b/camera.js index 48949474..e2716976 100644 --- a/camera.js +++ b/camera.js @@ -148,12 +148,13 @@ Camera.prototype.set = function (opts) { } Camera.prototype.initPostproces = function () { - var ctx = this.ctx - var fsqPositions = [[-1, -1], [1, -1], [1, 1], [-1, 1]] - var fsqFaces = [[0, 1, 2], [0, 2, 3]] + const ctx = this.ctx + const precisionStr = `precision ${ctx.capabilities.maxPrecision} float;\n` + const fsqPositions = [[-1, -1], [1, -1], [1, 1], [-1, 1]] + const fsqFaces = [[0, 1, 2], [0, 2, 3]] - var W = this.viewport[2] - var H = this.viewport[3] + const W = this.viewport[2] + const H = this.viewport[3] this._fsqMesh = { attributes: { @@ -268,8 +269,8 @@ Camera.prototype.initPostproces = function () { // clearDepth: 1 }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: SAO_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + SAO_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -288,8 +289,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BILATERAL_BLUR_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BILATERAL_BLUR_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -311,8 +312,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BILATERAL_BLUR_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BILATERAL_BLUR_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -334,8 +335,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BILATERAL_BLUR_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BILATERAL_BLUR_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -355,8 +356,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BILATERAL_BLUR_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BILATERAL_BLUR_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -376,8 +377,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 1, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: THRESHOLD_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + THRESHOLD_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -398,8 +399,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 1, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BLOOM_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BLOOM_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -419,8 +420,8 @@ Camera.prototype.initPostproces = function () { clearColor: [1, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: BLOOM_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + BLOOM_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, @@ -436,8 +437,8 @@ Camera.prototype.initPostproces = function () { this._blitCmd = { name: 'Camera.blit', pipeline: ctx.pipeline({ - vert: POSTPROCESS_VERT, - frag: POSTPROCESS_FRAG + vert: precisionStr + POSTPROCESS_VERT, + frag: precisionStr + POSTPROCESS_FRAG }), attributes: this._fsqMesh.attributes, indices: this._fsqMesh.indices, diff --git a/examples/postprocessing/index.js b/examples/postprocessing/index.js index 869357c2..80f502c5 100644 --- a/examples/postprocessing/index.js +++ b/examples/postprocessing/index.js @@ -18,7 +18,7 @@ dragon.positions = centerAndNormalize(dragon.positions).map((v) => vec3.scale(v, dragon.normals = normals(dragon.cells, dragon.positions) dragon.uvs = dragon.positions.map(() => [0, 0]) const parseHdr = require('parse-hdr') -const ctx = createContext() +const ctx = createContext({ precision: 'mediump' }) ctx.gl.getExtension('EXT_shader_texture_lod') ctx.gl.getExtension('OES_standard_derivatives') ctx.gl.getExtension('WEBGL_draw_buffers') diff --git a/index.js b/index.js index 7a20b4ef..5a1bfc16 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,7 @@ const SHADERS_CHUNKS = require('./shaders/chunks') var State = { frame: 0, + precision: 'highp', shadowQuality: 2, debug: false, profile: false, @@ -77,16 +78,16 @@ function Renderer (opts) { const gl = opts.ctx.gl gl.getExtension('OES_standard_derivatives') - this._dummyTexture2D = ctx.texture2D({ width: 4, height: 4 }) this._dummyTextureCube = ctx.textureCube({ width: 4, height: 4 }) this._debug = false this._programCacheMap = { values: [], - getValue: function (flags, vert, frag) { + getValue: function (precision, flags, vert, frag) { for (var i = 0; i < this.values.length; i++) { var v = this.values[i] + if (v.precision !== precision) break if (v.frag === frag && v.vert === vert) { if (v.flags.length === flags.length) { var found = true @@ -104,8 +105,8 @@ function Renderer (opts) { } return false }, - setValue: function (flags, vert, frag, program) { - this.values.push({ flags, vert, frag, program }) + setValue: function (precision, flags, vert, frag, program) { + this.values.push({ precision, flags, vert, frag, program }) } } @@ -127,6 +128,8 @@ function Renderer (opts) { Object.assign(State, opts) this._state = State + this.precision = opts.precision ? ctx.getMaxPrecision(State.precision) : ctx.capabilities.maxPrecision + this.shaders = { chunks: SHADERS_CHUNKS, pipeline: { @@ -193,9 +196,17 @@ Renderer.prototype.updatePointLightShadowMap = function (light, geometries) { }) } +Renderer.prototype.getPrecisionString = function (precision) { + return `precision ${precision} float; +precision ${precision} int; +` +} + Renderer.prototype.getMaterialProgramAndFlags = function (geometry, material, skin, options) { var ctx = this._ctx + const precision = material.precision || this.precision + var flags = [] if (!geometry._attributes.aNormal) { @@ -259,7 +270,8 @@ Renderer.prototype.getMaterialProgramAndFlags = function (geometry, material, sk flags.push('#define NUM_SPOT_LIGHTS ' + (0)) flags.push('#define NUM_AREA_LIGHTS ' + (0)) return { - flags: flags, + precision, + flags, vert: (material.vert || DEPTH_PASS_VERT), frag: (material.frag || DEPTH_PRE_PASS_FRAG) } @@ -274,7 +286,8 @@ Renderer.prototype.getMaterialProgramAndFlags = function (geometry, material, sk flags.push('#define NUM_SPOT_LIGHTS ' + (0)) flags.push('#define NUM_AREA_LIGHTS ' + (0)) return { - flags: flags, + precision, + flags, vert: (material.vert || DEPTH_PASS_VERT), frag: (material.frag || DEPTH_PASS_FRAG) } @@ -346,8 +359,10 @@ Renderer.prototype.getMaterialProgramAndFlags = function (geometry, material, sk if (options.useTonemapping) { flags.push('#define USE_TONEMAPPING') } + return { - flags: flags, + precision, + flags, vert: (material.vert || PBR_VERT), frag: (material.frag || PBR_FRAG) } @@ -359,21 +374,23 @@ Renderer.prototype.buildProgram = function (vertSrc, fragSrc) { try { program = ctx.program({ vert: vertSrc, frag: fragSrc }) } catch (e) { - console.error('pex-renderer glsl error', e) - program = ctx.program({ vert: ERROR_VERT, frag: ERROR_FRAG }) + console.error('pex-renderer glsl error', e, vertSrc) + const precisionStr = this.getPrecisionString(this.precision) + program = ctx.program({ vert: precisionStr + ERROR_VERT, frag: precisionStr + ERROR_FRAG }) } return program } Renderer.prototype.getMaterialProgram = function (geometry, material, skin, options) { - var { flags, vert, frag } = this.getMaterialProgramAndFlags(geometry, material, skin, options) - var flagsStr = flags.join('\n') + '\n' - var vertSrc = flagsStr + vert - var fragSrc = flagsStr + frag - var program = this._programCacheMap.getValue(flags, vert, frag) + const { precision, flags, vert, frag } = this.getMaterialProgramAndFlags(geometry, material, skin, options) + const precisionStr = this.getPrecisionString(precision) + const flagsStr = flags.join('\n') + '\n' + const vertSrc = precisionStr + flagsStr + vert + const fragSrc = precisionStr + flagsStr + frag + let program = this._programCacheMap.getValue(precision, flags, vert, frag) if (!program) { program = this.buildProgram(vertSrc, fragSrc) - this._programCacheMap.setValue(flags, vert, frag, program) + this._programCacheMap.setValue(precision, flags, vert, frag, program) } return program } @@ -438,9 +455,10 @@ Renderer.prototype.getGeometryPipeline = function (geometry, material, skin, opt Renderer.prototype.getOverlayCommand = function () { const ctx = this._ctx if (!this._drawOverlayCmd) { + const precisionStr = this.getPrecisionString(this.precision) const program = ctx.program({ - vert: OVERLAY_VERT, - frag: OVERLAY_FRAG + vert: precisionStr + OVERLAY_VERT, + frag: precisionStr + OVERLAY_FRAG }) this._drawOverlayCmd = { name: 'DrawOverlayCmd', diff --git a/material.js b/material.js index 79fabb52..e06ecbbf 100644 --- a/material.js +++ b/material.js @@ -36,6 +36,7 @@ function Material (opts) { this.blendSrcAlphaFactor = ctx.BlendFactor.One this.blendDstRGBFactor = ctx.BlendFactor.One this.blendDstAlphaFactor = ctx.BlendFactor.One + this.precision = opts.precision ? ctx.getMaxPrecision(opts.precision) : null this.castShadows = false this.receiveShadows = false this.cullFace = true diff --git a/reflection-probe.js b/reflection-probe.js index 76eafe46..8af8bb50 100644 --- a/reflection-probe.js +++ b/reflection-probe.js @@ -21,6 +21,7 @@ function ReflectionProbe (opts) { this._ctx = ctx this.dirty = true + const precisionStr = `precision ${ctx.capabilities.maxPrecision} float;\n` const CUBEMAP_SIZE = 512 const dynamicCubemap = this._dynamicCubemap = ctx.textureCube({ width: CUBEMAP_SIZE, @@ -85,8 +86,8 @@ function ReflectionProbe (opts) { color: [ octMap ] }), pipeline: ctx.pipeline({ - vert: FULLSCREEN_QUAD, - frag: CUBEMAP_TO_OCTMAP + vert: precisionStr + FULLSCREEN_QUAD, + frag: precisionStr + CUBEMAP_TO_OCTMAP }), attributes: attributes, indices: indices, @@ -103,8 +104,8 @@ function ReflectionProbe (opts) { color: [ octMap ] }), pipeline: ctx.pipeline({ - vert: FULLSCREEN_QUAD, - frag: CONVOLVE_OCT_MAP_ATLAS_TO_OCT_MAP + vert: precisionStr + FULLSCREEN_QUAD, + frag: precisionStr + CONVOLVE_OCT_MAP_ATLAS_TO_OCT_MAP }), attributes: attributes, indices: indices, @@ -133,8 +134,8 @@ function ReflectionProbe (opts) { color: [ octMapAtlas ] }), pipeline: ctx.pipeline({ - vert: FULLSCREEN_QUAD, - frag: BLIT_TO_OCT_MAP_ATLAS + vert: precisionStr + FULLSCREEN_QUAD, + frag: precisionStr + BLIT_TO_OCT_MAP_ATLAS }), uniforms: { uSource: octMap, @@ -152,8 +153,8 @@ function ReflectionProbe (opts) { clearColor: [0, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: FULLSCREEN_QUAD, - frag: DOWNSAMPLE_FROM_OCT_MAP_ATLAS + vert: precisionStr + FULLSCREEN_QUAD, + frag: precisionStr + DOWNSAMPLE_FROM_OCT_MAP_ATLAS }), uniforms: { uSource: octMapAtlas, @@ -171,8 +172,8 @@ function ReflectionProbe (opts) { clearColor: [0, 1, 0, 1] }), pipeline: ctx.pipeline({ - vert: FULLSCREEN_QUAD, - frag: PREFILTER_FROM_OCT_MAP_ATLAS + vert: precisionStr + FULLSCREEN_QUAD, + frag: precisionStr + PREFILTER_FROM_OCT_MAP_ATLAS }), uniforms: { uSource: octMapAtlas, diff --git a/shaders/error/error.frag.js b/shaders/error/error.frag.js index b618e493..069ef086 100644 --- a/shaders/error/error.frag.js +++ b/shaders/error/error.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision mediump float; - void main () { gl_FragData[0] = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/shaders/pipeline/depth-pass.frag.js b/shaders/pipeline/depth-pass.frag.js index 15f409c7..cdc07d6f 100644 --- a/shaders/pipeline/depth-pass.frag.js +++ b/shaders/pipeline/depth-pass.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - // Variables varying vec3 vNormalView; varying vec2 vTexCoord0; diff --git a/shaders/pipeline/depth-pre-pass.frag.js b/shaders/pipeline/depth-pre-pass.frag.js index c8f686ec..620dca21 100644 --- a/shaders/pipeline/depth-pre-pass.frag.js +++ b/shaders/pipeline/depth-pre-pass.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - // Variables varying vec3 vNormalView; varying vec2 vTexCoord0; diff --git a/shaders/pipeline/material.frag.js b/shaders/pipeline/material.frag.js index ecc1ea6e..7370ed80 100644 --- a/shaders/pipeline/material.frag.js +++ b/shaders/pipeline/material.frag.js @@ -6,13 +6,11 @@ module.exports = /* glsl */` #extension GL_EXT_draw_buffers : enable #endif -precision mediump float; - // Variables -uniform highp mat4 uInverseViewMatrix; -uniform highp mat4 uViewMatrix; -uniform highp mat3 uNormalMatrix; -uniform highp mat4 uModelMatrix; +uniform mat4 uInverseViewMatrix; +uniform mat4 uViewMatrix; +uniform mat3 uNormalMatrix; +uniform mat4 uModelMatrix; uniform vec3 uCameraPosition; diff --git a/shaders/pipeline/overlay.frag.js b/shaders/pipeline/overlay.frag.js index 92c8a258..65fc5ee6 100644 --- a/shaders/pipeline/overlay.frag.js +++ b/shaders/pipeline/overlay.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision highp float; - varying vec2 vTexCoord; uniform sampler2D uTexture; void main() { diff --git a/shaders/post-processing/bilateral-blur.frag.js b/shaders/post-processing/bilateral-blur.frag.js index 18ef1ba0..00e15898 100644 --- a/shaders/post-processing/bilateral-blur.frag.js +++ b/shaders/post-processing/bilateral-blur.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision highp float; - varying vec2 vTexCoord; uniform float near; diff --git a/shaders/post-processing/bloom.frag.js b/shaders/post-processing/bloom.frag.js index d03a7fe7..fe015132 100644 --- a/shaders/post-processing/bloom.frag.js +++ b/shaders/post-processing/bloom.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision highp float; - varying vec2 vTexCoord; uniform float near; diff --git a/shaders/post-processing/post-processing.frag.js b/shaders/post-processing/post-processing.frag.js index 09441bb8..8797e922 100644 --- a/shaders/post-processing/post-processing.frag.js +++ b/shaders/post-processing/post-processing.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - // Variables uniform vec2 uScreenSize; diff --git a/shaders/post-processing/sao.frag.js b/shaders/post-processing/sao.frag.js index 830e5ddb..4dd02b51 100644 --- a/shaders/post-processing/sao.frag.js +++ b/shaders/post-processing/sao.frag.js @@ -3,8 +3,6 @@ module.exports = /* glsl */` // Updated by marcin.ignac@gmail.com 2017-05-08 #extension GL_OES_standard_derivatives : enable -precision mediump float; - // total number of samples at each fragment #define NUM_SAMPLES 11 diff --git a/shaders/post-processing/threshold.frag.js b/shaders/post-processing/threshold.frag.js index 8993a06d..0682ce70 100644 --- a/shaders/post-processing/threshold.frag.js +++ b/shaders/post-processing/threshold.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision highp float; - varying vec2 vTexCoord; uniform float near; diff --git a/shaders/reflection-probe/blit-to-oct-map-atlas.frag.js b/shaders/reflection-probe/blit-to-oct-map-atlas.frag.js index cb71fc4b..8b87ee1e 100644 --- a/shaders/reflection-probe/blit-to-oct-map-atlas.frag.js +++ b/shaders/reflection-probe/blit-to-oct-map-atlas.frag.js @@ -1,6 +1,4 @@ module.exports = /* glsl */` -precision highp float; - varying vec2 vTexCoord; uniform float uLevelSize; diff --git a/shaders/reflection-probe/convolve-oct-map-atlas-to-oct-map.frag.js b/shaders/reflection-probe/convolve-oct-map-atlas-to-oct-map.frag.js index 2a5bf867..8d693cc2 100644 --- a/shaders/reflection-probe/convolve-oct-map-atlas-to-oct-map.frag.js +++ b/shaders/reflection-probe/convolve-oct-map-atlas-to-oct-map.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - ${SHADERS.octMapUvToDir} ${SHADERS.octMap} ${SHADERS.rgbm} diff --git a/shaders/reflection-probe/cubemap-to-octmap.frag.js b/shaders/reflection-probe/cubemap-to-octmap.frag.js index 4516ea0d..73b9ecb0 100644 --- a/shaders/reflection-probe/cubemap-to-octmap.frag.js +++ b/shaders/reflection-probe/cubemap-to-octmap.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - ${SHADERS.octMapUvToDir} varying vec2 vTexCoord; diff --git a/shaders/reflection-probe/downsample-from-oct-map-atlas.frag.js b/shaders/reflection-probe/downsample-from-oct-map-atlas.frag.js index 976328bc..d070457a 100644 --- a/shaders/reflection-probe/downsample-from-oct-map-atlas.frag.js +++ b/shaders/reflection-probe/downsample-from-oct-map-atlas.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - ${SHADERS.octMapUvToDir} ${SHADERS.octMap} diff --git a/shaders/reflection-probe/prefilter-from-oct-map-atlas.frag.js b/shaders/reflection-probe/prefilter-from-oct-map-atlas.frag.js index 365633b9..d3291b21 100644 --- a/shaders/reflection-probe/prefilter-from-oct-map-atlas.frag.js +++ b/shaders/reflection-probe/prefilter-from-oct-map-atlas.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - // Variables varying vec2 vTexCoord; uniform float uTextureSize; diff --git a/shaders/skybox/sky-env-map.frag.js b/shaders/skybox/sky-env-map.frag.js index b0529111..80a66116 100644 --- a/shaders/skybox/sky-env-map.frag.js +++ b/shaders/skybox/sky-env-map.frag.js @@ -1,8 +1,6 @@ const SHADERS = require('../chunks/index.js') module.exports = /* glsl */` -precision highp float; - ${SHADERS.math.PI} ${SHADERS.sky} ${SHADERS.rgbm} diff --git a/shaders/skybox/sky-env-map.vert.js b/shaders/skybox/sky-env-map.vert.js index d6481103..6f7794fc 100644 --- a/shaders/skybox/sky-env-map.vert.js +++ b/shaders/skybox/sky-env-map.vert.js @@ -1,4 +1,4 @@ -module.exports = ` +module.exports = /* glsl */` attribute vec3 aPosition; attribute vec2 aTexCoord0; diff --git a/shaders/skybox/skybox.frag.js b/shaders/skybox/skybox.frag.js index 81560f7b..7fd6d84a 100644 --- a/shaders/skybox/skybox.frag.js +++ b/shaders/skybox/skybox.frag.js @@ -5,8 +5,6 @@ module.exports = /* glsl */` #extension GL_EXT_draw_buffers : enable #endif -precision highp float; - #define USE_TONEMAPPING // Variables diff --git a/skybox.js b/skybox.js index c1c888e1..590cf97e 100644 --- a/skybox.js +++ b/skybox.js @@ -22,14 +22,15 @@ function Skybox (opts) { this.set(opts) + const precisionStr = `precision ${ctx.capabilities.maxPrecision} float;\n` const skyboxPositions = [[-1, -1], [1, -1], [1, 1], [-1, 1]] const skyboxFaces = [[0, 1, 2], [0, 2, 3]] this._drawCommand = { name: 'Skybox.draw', pipeline: ctx.pipeline({ - vert: SKYBOX_VERT, - frag: SKYBOX_FRAG, + vert: precisionStr + SKYBOX_VERT, + frag: precisionStr + SKYBOX_FRAG, depthTest: true }), attributes: { @@ -61,8 +62,8 @@ function Skybox (opts) { clearColor: [0, 0, 0, 0] }), pipeline: ctx.pipeline({ - vert: SKYTEXTURE_VERT, - frag: SKYTEXTURE_FRAG + vert: precisionStr + SKYTEXTURE_VERT, + frag: precisionStr + SKYTEXTURE_FRAG }), uniforms: { uSunPosition: [0, 0, 0]