Skip to content

Commit

Permalink
- Fix Resize particles
Browse files Browse the repository at this point in the history
  • Loading branch information
MisterPrada committed May 12, 2024
1 parent 2860e1f commit b2db789
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "vite build"
},
"devDependencies": {
"three": "^0.156.1",
"three": "^0.164.1",
"vite": "^4.4.9",
"vite-plugin-glsl": "^1.0.2",
"vite-plugin-glslify": "^2.0.2",
Expand Down
3 changes: 2 additions & 1 deletion src/Experience/Shaders/Particles/particles.vert
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
uniform sampler2D uPositions;//RenderTarget containing the transformed positions
uniform float uSize;
uniform float uPixelRatio;
uniform vec2 uResolution;
uniform float uScroll;
varying vec3 vPos;
varying vec2 vUv;
Expand Down Expand Up @@ -30,7 +31,7 @@ void main() {
}

gl_Position = projectionPosition;
gl_PointSize = customSize * uPixelRatio;
gl_PointSize = customSize * uResolution.y * 0.0013;
gl_PointSize *= (1.0 / - viewPosition.z);

vPos = pos;
Expand Down
7 changes: 7 additions & 0 deletions src/Experience/World/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ export default class Page {
uTime: { value: 0 },
uPixelRatio: { value: Math.min(window.devicePixelRatio, 2) },
uScroll : { value: this.normalizedScrollY },
uResolution: new THREE.Uniform(
new THREE.Vector2(
this.sizes.width * this.sizes.pixelRatio,
this.sizes.height * this.sizes.pixelRatio
)
),
},
defines:
{
Expand Down Expand Up @@ -305,6 +311,7 @@ export default class Page {
this.fbo.resize(this.sizes.width, this.sizes.height);
this.renderMaterial.uniforms.uPixelRatio.value = Math.min(window.devicePixelRatio, 2)
this.horsePointsMaterial.uniforms.uPixelRatio.value = Math.min(window.devicePixelRatio, 2)
this.renderMaterial.uniforms.uResolution.value.set(this.sizes.width * this.sizes.pixelRatio, this.sizes.height * this.sizes.pixelRatio)
}

scroll()
Expand Down
2 changes: 1 addition & 1 deletion src/Experience/World/World.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class World
}

resize() {

this.page.resize()
}

scroll()
Expand Down

0 comments on commit b2db789

Please sign in to comment.