diff --git a/src/world/grass/GrassPatch.tsx b/src/world/grass/GrassPatch.tsx index e1a6c68..2ef1902 100644 --- a/src/world/grass/GrassPatch.tsx +++ b/src/world/grass/GrassPatch.tsx @@ -3,7 +3,11 @@ import { useTexture } from "@react-three/drei"; import { useFrame, useThree } from "@react-three/fiber"; import * as THREE from "three"; import { useWind } from "@/hooks/world/useWind"; -import { GRASS_COLORS, GRASS_CONFIG } from "@/world/grass/grassConfig"; +import { + GRASS_BASE_COLOR, + GRASS_COLORS, + GRASS_CONFIG, +} from "@/world/grass/grassConfig"; import { grassFragmentShader, grassVertexShader, @@ -125,6 +129,7 @@ function createGrassMaterial( uDiffuseMap: { value: grassTexture }, uHeightMap: { value: terrainSampler.heightTexture }, uPlayerPosition: { value: new THREE.Vector3() }, + uBaseBladeColor: { value: new THREE.Color(GRASS_BASE_COLOR) }, uBoundingBoxMin: { value: new THREE.Vector3( terrainSampler.bounds.minX, diff --git a/src/world/grass/grassConfig.ts b/src/world/grass/grassConfig.ts index fa6a805..599e09d 100644 --- a/src/world/grass/grassConfig.ts +++ b/src/world/grass/grassConfig.ts @@ -33,3 +33,4 @@ export const GRASS_CONFIG = { } as const; export const GRASS_COLORS = ["#84C66B", "#67B058", "#A3CA5B"] as const; +export const GRASS_BASE_COLOR = "#1A3A1A" as const; diff --git a/src/world/grass/grassShaders.ts b/src/world/grass/grassShaders.ts index dbbb527..3f8b461 100644 --- a/src/world/grass/grassShaders.ts +++ b/src/world/grass/grassShaders.ts @@ -7,6 +7,7 @@ export const grassVertexShader = /* glsl */ ` uniform float uTime; uniform vec3 uPlayerPosition; + uniform vec3 uBaseBladeColor; uniform sampler2D uHeightMap; uniform sampler2D uDiffuseMap; uniform sampler2D uNoiseTexture; @@ -136,9 +137,7 @@ export const grassVertexShader = /* glsl */ ` float width = smoothstep(0.02, uMaxBladeHeight * 0.85, heightModifier) * uBladeWidth * bladeVisibility; transformed += aYaw * (width / 2.0) * sideFactor; - vec3 textureColor = texture2D(uDiffuseMap, terrainUv * 10.0).rgb; - vec3 colorNoise = texture2D(uNoiseTexture, terrainUv.yx * vec2(uHeightNoiseFrequency) + (uTime * 0.1)).rgb; - vColor = mix(aBladeColor * 0.55, aBladeColor, tipFactor) * textureColor * mix(vec3(0.75), vec3(1.15), colorNoise); + vColor = mix(uBaseBladeColor, aBladeColor, tipFactor); float distanceFromCenter = length(origin.xz) / halfPatchSize; float innerCircleFactor = clamp(smoothstep(0.0, 0.5, distanceFromCenter), 0.0, 1.0);