Skip to content

Instantly share code, notes, and snippets.

// Derive slope from surface normal (0 = flat, 1 = vertical cliff)
// Clamp to guard against floating-point overshoot on nearly-vertical faces
float slope = saturate(1.0 - dot(normalize(worldNormal), float3(0, 1, 0)));
// Normalize height into 0..1 across the terrain's actual used range
// Use the real min/max of your sculpted terrain, not the asset's full range
float height = saturate((worldPos.y - terrainMinY) / (terrainMaxY - terrainMinY));
// Sample each gradient using the derived 0..1 values
float3 slopeColor = sampleGradient(slopeGradient, slope);
class NoiseNode : public ImageNodeBase
{
protected:
Slot m_outputSlot;
float2 m_offset{ 0,0 };
float2 m_scale{ 500,500 };
int m_layerCount{ 1 };
float m_lacunarity{ 2 };
float m_persistence{ 1.0f / 3.0f };
bool GUI::Float2Field(const char* label, float2* value)
{
PrefixLabelC(label);
ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems)
return false;
int c = 2; //component count
float w = ImGui::CalcItemWidth();
bool GUI::FloatField(const char* label, float* value)
{
return ImGui::InputFloat(PrefixLabelC(label), value);
}