#Perlin Noise Water Generation

1 messages · Page 1 of 1 (latest)

valid verge
#

I have code to generate some terrain out of 1x1x1 cubes, and it looks sort of like ocean water, and color shifts to white as it reaches the top, but it looks unnatural. Observe the following result:

#

Here's the problem: There's too much white water on the top. I'm trying to achieve a water effect where only the very top of the “waves” have a bright, reflective look, while the rest is a deeper, darker blue. Right now, the brightness of the water is tied directly to how high/low it is in the terrain generation. Since tying brightness directly to height makes the whole height range bright, we’ll need to introduce a way to control brightness independently and emphasize highlights only near the top. Problem is, I have no idea how to do that. I'm not good at visualizing math. My code is below:

#
local NoiseStorageFolder = workspace.NoiseStorage

local RenderSize = 100 -- Controls The Size
local Resolution = 100 -- Controls The Resolution
local Frequency = 3
local Amplitude = 4
local BlockSize = 1 -- Controls The Block Size
local Blocky: boolean = true -- Controls If We're Making A Blocky Render Like Minecraft

local function GetHeight(x: number, z: number)
    local noiseHeight = math.noise(
        x / Resolution * Frequency,
        z / Resolution * Frequency
    )
    
    noiseHeight = math.clamp(noiseHeight, -0.5, 0.5) + 0.5
    return noiseHeight
    
end

for x = 0, RenderSize do
    for z = 0, RenderSize do
        local Part = Instance.new("Part")
        Part.Anchored = true
        Part.Size = Vector3.new(BlockSize, BlockSize, BlockSize)
        Part.Parent = NoiseStorageFolder
        local height = GetHeight(x, z)
        
        if Blocky then
            Part.Position = Vector3.new(math.floor(x), math.floor(height * Amplitude), math.floor(z))
        else
            Part.Position = Vector3.new(x, height * Amplitude, z)
        end

        Part.Color = Color3.new(
            0, -- We don't want the blocks to be red at all.
            math.clamp(height + 0.3, 0, 1), 
            math.clamp(height + 0.5, 0, 1))
    end
end
#

I tried fiddling around with it, particularly in the values inside the Color3 you see at the bottom of the code. However, this efford didn't help at all.

#

There's actually a site for equations based on different EasingStyles you can use, but I tried implementing the equations and nothing happened. You can find it here.
https://easings.net/

#

@crude pagoda What is the Suphi bot doing above? Also, I looked on your page for any terrain generation related to parts rather than, you know, regular roblox terrain, and couldn't find anything. Do you know anything about how to solve my problem or at least point me in the right direction? This seems like the type of thing you could figure out off the top of your head so that's why I'm mentioning you

deep breach
#

and ANY roblox terrain generator can be turned into a block terrain generator

#

depending on the way the terrain is being placed