UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.76 kB
import{RenderPassShaderQuad as t}from"../../scene/graphics/render-pass-shader-quad.js";class e extends t{constructor(t,e){super(t),this.sourceTexture=e,this.shader=this.createQuadShader("UpSampleShader","\n\t\t\tuniform sampler2D sourceTexture;\n\t\t\tuniform vec2 sourceInvResolution;\n\t\t\tvarying vec2 uv0;\n\t\t\tvoid main()\n\t\t\t{\n\t\t\t\tfloat x = sourceInvResolution.x;\n\t\t\t\tfloat y = sourceInvResolution.y;\n\t\t\t\tvec3 a = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y + y)).rgb;\n\t\t\t\tvec3 b = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y + y)).rgb;\n\t\t\t\tvec3 c = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y + y)).rgb;\n\t\t\t\tvec3 d = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y)).rgb;\n\t\t\t\tvec3 e = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y)).rgb;\n\t\t\t\tvec3 f = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y)).rgb;\n\t\t\t\tvec3 g = texture2D (sourceTexture, vec2 (uv0.x - x, uv0.y - y)).rgb;\n\t\t\t\tvec3 h = texture2D (sourceTexture, vec2 (uv0.x,\t uv0.y - y)).rgb;\n\t\t\t\tvec3 i = texture2D (sourceTexture, vec2 (uv0.x + x, uv0.y - y)).rgb;\n\t\t\t\tvec3 value = e * 4.0;\n\t\t\t\tvalue += (b + d + f + h) * 2.0;\n\t\t\t\tvalue += (a + c + g + i);\n\t\t\t\tvalue *= 1.0 / 16.0;\n\t\t\t\tgl_FragColor = vec4(value, 1.0);\n\t\t\t}"),this.sourceTextureId=t.scope.resolve("sourceTexture"),this.sourceInvResolutionId=t.scope.resolve("sourceInvResolution"),this.sourceInvResolutionValue=new Float32Array(2)}execute(){this.sourceTextureId.setValue(this.sourceTexture),this.sourceInvResolutionValue[0]=1/this.sourceTexture.width,this.sourceInvResolutionValue[1]=1/this.sourceTexture.height,this.sourceInvResolutionId.setValue(this.sourceInvResolutionValue),super.execute()}}export{e as RenderPassUpsample};