Logo by mclarekin - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Visit us on facebook
 
*
Welcome, Guest. Please login or register. February 20, 2019, 07:35:30 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Ray Marching Voxel based Cube World ?  (Read 1465 times)
0 Members and 1 Guest are viewing this topic.
glennmarshall
Alien
***
Posts: 26


« on: August 29, 2013, 11:59:26 AM »

Hi
I'm trying to implement a Minecraft type Voxel world using cubes - using Ray Marching.

I'm using 3d perlin noise to 'cut' away areas in an infinite field of cubes.
My problem is that I'm getting lots of unpleasant artifacts like banding and rough, broken looking edges around the geometry.  Pictures attached.
The Ray Marching engine I'm using was written by someone else, so most of the variables look alien to me, and I'm having to guess what the problem might be by changing various constants I see.

Here's my method for cube voxels.  Maybe there is a better way, that will get rid of the artifacts, or maybe someone could suggest which parts of the Ray Marching engine I should look at which is responsible.  Thanks.


Code:
 
float finalModel(PVector p)
  {
    PVector cp=p.get();

    float boxsize=.150;
    PVector box=new PVector(boxsize, boxsize, boxsize);

    float w=.3;

    float x1=rounder(cp.x, w);
    float y1=rounder(cp.y, w);
    float z1=rounder(cp.z, w);
    cp.x-=x1;
    cp.y-=y1;
    cp.z-=z1;

    float s=.3;
    double val=(float)sn.noise(1000+x1*s, 1000+y1*s, 1000+z1*s);
    val=(val+1)/2;

    if (val<.8)
    {
      box.x=-.15;
      box.y=-.15;
      box.z=-.15;
    }

    float DE1=sdBox2(   cp, box);
    float bounds=sdBox2(   new PVector(p.x, p.y+3, p.z), new PVector(15, 3, 15));

 return max(DE1, bounds);

float rounder(float ii, float vv) {
  return round(ii/vv) * vv;
}


* Screen Shot 2013-08-29 at 10.36.35 AM copy.jpg (128.47 KB, 629x353 - viewed 330 times.)

* Screen Shot 2013-08-29 at 10.36.52 AM.jpg (91.25 KB, 636x353 - viewed 354 times.)
Logged
eiffie
Guest
« Reply #1 on: August 29, 2013, 05:56:54 PM »

The renderer is expecting a distance estimate that is continuous. Meaning return values won't jump drastically when comparing points that are close to each other. When you see cuts in the surface that is typically the problem.
Logged
glennmarshall
Alien
***
Posts: 26


« Reply #2 on: August 29, 2013, 09:56:34 PM »

actually, I was just checking things, I think I had my camera stuck in the middle of the geometry - giving wired results, so I made sure the camera was safely away from the bounded area, and everything looks as it should.. sorry for wasting your time!



* Screen Shot 2013-08-29 at 5.57.42 PM.png (185.71 KB, 634x354 - viewed 436 times.)
Logged
eiffie
Guest
« Reply #3 on: August 29, 2013, 10:40:26 PM »

Glad it works. Looks nice!
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.109 seconds with 27 queries. (Pretty URLs adds 0.006s, 2q)