Sunday, August 30, 2015

Procedural texturing

Lots of hours have been spent on shaping Playform's terrain, playing with noise functions, isosurface extraction, and brushes. Lately I've been realizing how much of an impact the finer visual details make, starting with the introduction of depth fog. They help break up the monotony of an otherwise pretty homogenous landscape. I plan to bring in landscape features like trees to help too.

Procedural texturing means not having hand-crafted textures ahead of time. Because the terrain can shift and change organically, mapping these textures seamlessly is a bit of a headache. It's not impossible by any stretch (e.g. via Wang tiles). But I'm not convinced I want preconstructed assets at all - I think eventually, I'd like the user to be able to paint the terrain, much like how they can sculpt it. I want some cheap, easy, and decent-looking texturing there as a base, but I don't want the user married to it.

Noise
So how do we make a cheap, easy, and decent-looking texture from nothing? The solution is to find some smooth noise function, and twist and turn it into the desired texture. Lots of noise functions exist (Perlin noise is probably the most well-known), and there are even some built right into GLSL, the OpenGL shader language, but I ended up using this one for performance reasons, and because I'm not too nitpicky about the details as long as it's smooth and kind of bubbly looking. Here's a little patch of noise:


I'm still figuring out how to transform this basic thing, and how to think about stacks of transformations, but I've adopted Miguel Cepero's approach of adding layers until it looks halfway-decent. Here's what I've got so far. I suggest clicking to see the full-size images.

Dirt
Grass

Bark

I'm still having trouble getting things to look more jagged. The bark texture is the closest I've gotten (and I wasn't even trying to make bark - I was going for a dirt texture like this). Maybe I should just be using a different noise function for more jagged things. I'm not well-read on noise functions, so to my smooth bubbly mind, everything looks like a sinusoidal nail.

The code is up at github.com/bfops/procedural-textures. I encourage you to play around and try and make some better-looking things!

1 comment:

  1. Casino Tycoon, LLC (WV) - MapyRO
    View Casino 전주 출장마사지 Tycoon, 진주 출장샵 LLC (WV) 수원 출장샵 location 구리 출장샵 in Maricopa, 양주 출장마사지 Arizona, United States, revenue, industry and

    ReplyDelete