POV-Ray : Newsgroups : povray.general : Interested in 16-bit height field functions? : Re: Interested in 16-bit height field functions? Server Time
30 Jul 2024 08:21:12 EDT (-0400)
  Re: Interested in 16-bit height field functions?  
From: stbenge
Date: 10 Jan 2010 16:38:42
Message: <4b4a48e2@news.povray.org>
mone wrote:
> I tried this function and it can generate textures suitable for the heightfield
> very quickly, thanks for the code! I tried some changes with the color map in
> the code, and wonder if it's possible to change it in a way, that you don't get
> a gradient, but only a white on black pattern?

Sure, you can squeeze the color_map values together, but the jaggies 
will look much worse.

> Because all kinds of gradients, which at first I hoped would maybe result in a
> rounded or bevelled looking edge in the heightfield instead made it looking
> either jagged or make some strange sort of tiny stripes on the heightfield
> walls.
> So I removed the gradients in Photoshop (which can handle 16bit grayscale png)
> and put a gray border around the white edge without antialiasing.
> It still looked a little jagged but a lot better than with the gradients.

Whatever works :)

Do you know about sin/cos functions? With them, you can make polygonal 
shapes with any number of sides. For instance, to make a 6-sided prism 
you can use sin/cos like so:

prism{
  -1,1,7,
  <sin(pi*2/6*0),cos(pi*2/6*0)>,
  <sin(pi*2/6*1),cos(pi*2/6*1)>,
  <sin(pi*2/6*2),cos(pi*2/6*2)>,
  <sin(pi*2/6*3),cos(pi*2/6*3)>,
  <sin(pi*2/6*4),cos(pi*2/6*4)>,
  <sin(pi*2/6*5),cos(pi*2/6*5)>,
  <sin(pi*2/6*0),cos(pi*2/6*0)> // closing the hexagon
  pigment{rgb 1}
}

Essentially, sin/cos functions map a circle. By studying this code, you 
can figure out how to make polygons with any number of sides. You can 
apply it towards other objects, like cylinders and spheres to make 
skeletal frameworks.

> Yes. I had searched "hexagon" in the documentation, but I hadn't found the code
> in the functions.inc, because it's abbreviated to "hex" there and it didn't show
> up in the search result. I should definitely read more in the doc, but the
> problem is, before I'm even partly through I've already forgotten completely
> about what I had read in the beginning. I'm not good at memorizing things. I
> remember I had read  through the functions.inc half a year or so ago, but I
> didn't even remember there was this hex-function in there.

Learning POV-Ray is daunting, to be sure. It is helpful to create mini 
projects for yourself, to learn how different features work. Also, it 
might be helpful to have a testing scene file with camera, lights, 
background, etc. to test things out in. I always keep such a file 
around, as well as a texture-making scene for trying out new 
pattern-related things.

>> I released some hexagonal patterns a while back, you might want to check
>> them out:
>>
http://news.povray.org/povray.binaries.scene-files/message/%3C482478cb%40news.povray.org%3E/#%3C482478cb%40news.povra
> y.org%3E
> 
> Yes they look groovy :)
> The little yellow star thing inspired me to try to make a whole field of sphere
> sweep hexagons in a row with a while loop. But I still haven't figured out the
> correct distance between them.

I included two functions and two variables in the include file for 
working in trigonal space, you might want to check them out. With them, 
you can find the correct distances :) They are called: h1, h2, ht(x,y), 
ht2(x,y).

> Alain <aze### [at] qwertyorg> wrote:

>>
>> You can use a small tile that you use many times. That tile only covers
>> one complete hex and just enough of 4 adjacent ones to create a
>> continous pattern when tilled. That smaller tile can have much finner
>> grain than a single one covering the whole thing.
> 
> I thought I could use tiles only with textures/pigments and so on. I don't know
> how to put them on heightfields? Because in the documentation I didn't found any
> "repeat" statement in the description for heightfields, so I thought tiles are
> not possible. But maybe I missed some essential point, it wouldn't be the first
> time :).

I think he might have been talking about making a basic height_field 
tile, like this (Thunderbird might put a line directly through the hexagon):
     ____
    /    \
__/      \__
   \      /
    \____/


It's a height_field with only one hexagon, an object you can place in a 
nested #while loop to make a larger honeycomb. You can use the 
previously mentioned variables and functions from my hex patterns 
include file to scale the hexagon correctly.

Sam


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.