i want to repeat my shader texture lets say 8x8 how can i do this within this frag below? i tried setting the normal way repeat.set( 4, 4 );
etc that didnt work tho
const _FS = `
uniform vec3 topColor;
uniform vec3 bottomColor;
uniform float offset;
uniform float exponent;
uniform vec3 fogColor;
uniform float fogNear;
uniform float fogFar;
uniform float fogDensity;
uniform samplerCube background;
varying vec3 vWorldPosition;
void main() {
vec3 viewDirection = normalize(vWorldPosition - cameraPosition);
vec3 stars = textureCube(background, viewDirection).xyz;
float h = normalize(vWorldPosition + offset).y;
float t = max(pow(max(h, 0.0), exponent), 0.0);
float f = exp(min(0.0, -vWorldPosition.y * 0.00125));
vec3 sky = mix(stars, bottomColor, f);
gl_FragColor = vec4(sky, 1.0);
}`;
js:
const texture0 = loaderSprite.load("./resources/terrain/ski.jpg");
texture0.encoding = THREE.sRGBEncoding;
const uniforms = {
"topColor": { value: new THREE.Color(0x0b152b) },
"bottomColor": { value: new THREE.Color(0x0b152b) },
"offset": { value: -30 },
"exponent": { value: 1.0 },
"fogColor": { type: "c", value: scene.fog.color },
"fogNear": { type: "f", value: scene.fog.near },
"fogFar": { type: "f", value: scene.fog.far },
"fogDensity": { type: "f", value: 1.75 },
"background": { value: texture0 },
};
uniforms["topColor"].value.copy(hemiLight.color);
this.scene_.fog.color.copy(uniforms["bottomColor"].value);
const skyGeo = new THREE.SphereBufferGeometry(4000, 40, 40);
const skyMat = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: _VS,
fragmentShader: _FS,
side: THREE.DoubleSide,
fog: true,
// glslVersion: THREE.GLSL3
});
const sky = new THREE.Mesh(skyGeo, skyMat);
this.scene_.add(sky);