maven


Raymarching tetrahedron fractal visual artifacts


I've been working with some basic ray marching stuff lately and I've encountered some issues with visual artifacts for a tetrahedron fractal. These artifacts occur whenever objects seem to get close to one another. The issue is most certainly within the surface distance function I am using and not my ray marching engine.
http://i.imgur.com/FmyRetV.png
http://i.imgur.com/TFKA6sV.png
Code:
float sdTet4(vec3 p, int iterations, float scale) {
//in cube from p(-1,-1,-1) to p(1,1,1)
//equilateral triangle (sorta lol)
float sideLength = 0.0; //side length
float radius = 0.0; //inscribed circle radius
float radius2 = 0.0; //circumscribed circle radius
float sphereRadius = 0.0; //radius of sphere for sd function
vec3 z = p;
for (int i = 0; i < iterations; i++) {
sideLength = scale/pow(2.0, float(i+1));
radius = sideLength*0.2886751346; //sqrt(3.0)/6.0 = 0.2886751346
radius2 = radius*2.0;
float height = sideLength*0.8164965809; //sqrt(6.0)/3.0 = 0.8164965809
sphereRadius = sideLength;
vec3 z1 = z - vec3(0.0, height, 0.0); //top center
vec3 z2 = z - vec3(0.0, -height, -height); //bottom back
vec3 z3 = z - vec3(-sideLength, -height, height); //bottom front left
vec3 z4 = z - vec3(sideLength, -height, height); //bottom front right
float d1 = sdSphere(z1, sphereRadius*2.0);
float d2 = sdSphere(z2, sphereRadius*2.0);
float d3 = sdSphere(z3, sphereRadius*2.0);
float d4 = sdSphere(z4, sphereRadius*2.0);
z = z1;
float d = d1;
if (d2 < d) { d = d2; z = z2; }
if (d3 < d) { d = d3; z = z3; }
if (d4 < d) { d = d4; z = z4; }
}
return sdSphere(z, sphereRadius);
}
Alternative code that somehow works:
float sdTet4(vec3 p, int iterations, float scale) {
vec3 a1 = vec3(1.0, 1.0, 1.0);
vec3 a2 = vec3(-1.0, -1.0, 1.0);
vec3 a3 = vec3(1.0, -1.0, -1.0);
vec3 a4 = vec3(-1.0, 1.0, -1.0);
iterations = 7;
int n = 0;
float dist = 0.0;
float d = 0.0;
vec3 z = p;
vec3 c = vec3(0.0);
//scale = 1.0;
float iterationScale = 0.0;
while (n < iterations) {
iterationScale = scale/pow(2.0, float(n));
c = a1; dist = length(z-a1);
d = length(z-a2); if (d < dist) { c = a2; dist = d; }
d = length(z-a3); if (d < dist) { c = a3; dist = d; }
d = length(z-a4); if (d < dist) { c = a4; dist = d; }
z -= c*iterationScale;
n++;
}
return sdSphere(z, iterationScale);
}
Thanks for the tips!
Edit: So why does the alternative code that I found work and not the original code? Something in the original code causes the visual artifacts but I don't know what.

Related Links

Problems adding xom to Maven project
Maven 3 antrun issue
Is there a way to tell maven to always use the latest _stable_ version of a dependency?
jslint-maven-plugin 1.0.2-SNAPSHOT repository
how to wildcard attach multiple files to an artifact in maven?
SCM-Activity-Plugin and Taglist in SONAR
Maven - Is it possible to specify mirror in pom.xml?
Maven: Show comment/alert in console when a dependency is used (compile/package/…)
Remove filter in web.xml in jetty
How to execute code before TestNG for ie. building up the test suite
Reading a maven settings.xml when building with gradle?
Maven Nested Multi-module project
mvn clean package, I want to copy the created jar to the current directory
Merging configuration values in Maven
In Maven 3 how can I use project.version for the module as a dependency to another project
jmeter plugin maven test-jar

Categories

HOME
ionic-framework
osgi
reflection
c#-4.0
azure-data-factory
onedrive
tesseract
grep
webstorm
at-command
cmd
amazon-cloudformation
python-unittest
google-translate
ssl-client-authentication
here-api
reveal.js
django-simple-history
worldwind
pugjs
evopdf
cx-freeze
opencover
tokenize
microsoft-r
apache-commons-io
semantic-analysis
intel-pin
fopen
maxmind
perlin-noise
windows-dev-center
azure-sql-database
fusionpbx
jmonkeyengine
swisscomdev
service-discovery
splice
galen
dynamic-reports
http-redirect
flashair
thin
cubic-spline
upstart
revapi
atomicity
statsd
setter
imanage
redundancy
firmata
impresspages
jwplayer7
suffix-tree
energy
prerequisites
collapse
tmuxinator
cisco-ios
operator-precedence
oxwall
camanjs
relocation
gulp-less
flask-cors
responsive-slides
android-2.2-froyo
srs
gnu-smalltalk
multiprocessor
gridfs
dataservice
file-locking
qt-faststart
plasma
sharp-repository
enterprisedb
smtp-auth
android-hardware
e4x
bluepill
appconkit
jmock
sudzc
gamequery
vc90
rescale
substrings
audio-capture
mediarss
genealogy
msdev
rtml

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App