Matt Benesi's Heightmap for Planes, Simplified

  • 1 Replies
  • 70 Views

0 Members and 1 Guest are viewing this topic.

Offline Sabine62

  • *
  • Moderator
  • ******
  • Posts: 971
  • It's just a jump to the left...
    • sabine62.deviantart.com
« on: August 09, 2020, 03:19:34 PM »
Based on Matt Benesi's MengerWorkOnHeightmap.frag, all I did was simplifying, adding a plane and a sphere, so all credit goes to Matt!

Goal is to use a heightmap with Fragmentarium's Floor, no luck until now ;)
Something happens there already, but for now it goes...  :boom:
Not sure it is possible at all...

Heightmap (1.jpg) in images below is created with JSPlacement, a free 'techy heightmap'-generator https://windmillart.net/?p=jsplacement

Update: added rotation of the heightmap

Code: [Select]
#info Heightmap by Matt Benesi, simplified, based on MengerWorkOnHeightmap.frag (Examples-folder)
#info Place the code you want to combine with the plane in DE1
#info Plane.w changes the height of the plane
#info Align texturing to orientation of plane: ...htextoff+(z.xy) or (z.yz) or (z.xz)

#define providesInit
#include "MathUtils.frag"
#include "DE-Raytracer.frag"

#group Plane
uniform vec4 Plane; slider[(-1,-1,-1,-10),(-1,-1,-1,0),(1,1,1,10)]
uniform vec3 PlaneColor;color[1,1,1]
uniform float Rotate;slider[-180,0,180]

#group Sphere
uniform float Sphere; slider[0,1,5]
uniform vec3 Orientation;slider[(-10,-10,-10),(1,1,1),(10,10,10)]

#group HeightMap
uniform sampler2D tex;file[texture.jpg]
uniform float hTextSpeedMult; slider[.01,8.34,20]
uniform float hTextureSpeed; slider[-5,0.18,5]
uniform float HighStrength; slider[-50,1.54,500]
uniform vec4 hscale;slider[(-3,-3,-3,-3),(0.023,0,0,0),(3,3,3,3)]
uniform vec2 hTextureOffset; slider[(-100,-100),(0,0),(100,100)]

mat3 rot;
void init() {
vec3 Rotation=vec3(0.,0.,Rotate);
        rot = rotationMatrixXYZ(Rotation);
}

void hTextureIT (inout vec3 z) {
                z*=rot;
vec2 horbittotal;
  vec2 hangles;
float htexturespeed=hTextureSpeed*hTextSpeedMult;
float hintensity=HighStrength*.02;
vec2 htextoff=hTextureOffset/100.0;
vec4 hcolor = texture2D(tex, htextoff+(z.xy)*htexturespeed)*hintensity;
hcolor.w=length(hcolor.xyz);
float hh=dot(hcolor.xyz,hscale.xyz)+hscale.w*hcolor.w;
z+=vec3(hh);
}

float DE1(vec3 z)
{
vec3 o=Orientation;
//plane and sphere by Inigo Quilez
float sphere= length(z+=o)-Sphere;
z-=o;
return sphere;
}

float DE2(vec3 z)
{
hTextureIT(z);
//plane and sphere by Inigo Quilez
float plane=  dot(z,Plane.xyz) + Plane.w;
return plane;
}

float DE(vec3 z)
{

float sph=DE1(z);
float pl=DE2(z);
return min(pl,sph);
}
#preset Default
FOV = 0.4197531
Eye = 4.6796472,-28.1975667,-9.20136941
Target = 4.72089528,-26.1657297,-8.64092285
Up = 0,0,-0.830732203
EquiRectangular = false
AutoFocus = true
FocalPlane = 23.188406
Aperture = 0.053557568
Gamma = 1
ToneMapping = 1
Exposure = 1
Brightness = 1.13456465
Contrast = 1.8929504
AvgLumin = 0.5,0.5,0.5
Saturation = 1
Hue = 0
LumCoeff = 0.2125,0.7154,0.0721
GaussianWeight = 1
AntiAliasScale = 1.5
DepthToAlpha = false
ShowDepth = false
DepthMagnitude = 1
Detail = -2.3
DetailAO = -0.20535704
FudgeFactor = 0.23797139
MaxDistance = 372.8362
MaxRaySteps = 211
Dither = 0
NormalBackStep = 1 NotLocked
AO = 0,0,0,0.699999988
Specular = 0.01419355
SpecularExp = 66.534915
SpecularMax = 10
SpotLight = 1,0.490196078,0.490196078,0.58956277
SpotLightDir = -0.62334218,-0.2679045
CamLight = 1,0.905882353,0.866666667,0.52676056
CamLightMin = 0.63756614
Glow = 1,0.243137255,0.243137255,0.26538988
GlowMax = 49
Fog = 0.07017544
HardShadow = 0.60000001 NotLocked
ShadowSoft = 1.5957446
QualityShadows = false
Reflection = 0.11067708 NotLocked
DebugSun = false
BaseColor = 1,1,1
OrbitStrength = 1
X = 0.5,0.6,0.6,1
Y = 1,0.6,0,0.9736148
Z = 0.8,0.78,1,1
R = 0.4,0.7,1,0.27608984
BackgroundColor = 0.415686275,0.654901961,0.909803922
GradientBackground = 1.13915415
CycleColors = false
Cycles = 0.1
EnableFloor = false
FloorNormal = 0,0,-1
FloorHeight = -4.7405966
FloorColor = 1,1,1
Plane = 0,0,-1,5.0125946
PlaneColor = 0,0.266666667,1
Sphere = 2.95226135
Orientation = -4.8302872,0.2872064,2.4543082
tex = 1.jpg
hTextSpeedMult = 0.572721096
hTextureSpeed = 0.0141914
HighStrength = 114.635763
hscale = -1.04020098,1.5829146,0.15829146,0.1658292
hTextureOffset = 0,0
#endpreset



Linkback: https://fractalforums.org/code-snippets-fragments/74/matt-benesis-heightmap-for-planes-simplified/3711/
« Last Edit: August 09, 2020, 05:04:01 PM by Sabine62 »
To thine own self be true

Offline Sabine62

  • *
  • Moderator
  • ******
  • Posts: 971
  • It's just a jump to the left...
    • sabine62.deviantart.com
« Reply #1 on: August 09, 2020, 03:20:51 PM »
With Knighty's take on pseudokleinian:


question
DE computation (simplified / pseudocode)

Started by lycium on Mandelbulber

6 Replies
320 Views
Last post May 18, 2020, 11:01:56 PM
by lycium
xx
Heightmap Hybrid

Started by Kalter Rauch on Fractal Image Gallery

2 Replies
168 Views
Last post June 16, 2018, 07:35:51 PM
by Kalter Rauch
xx
mandelbrot heightmap

Started by birational on Fractal Image Gallery

1 Replies
149 Views
Last post August 28, 2018, 03:21:53 PM
by Bill Snowzell
lamp
Heightmap for Floor

Started by Sabine62 on Fragmentarium

4 Replies
405 Views
Last post September 01, 2020, 06:34:43 PM
by Sabine62
clip
M Benesi folded bulb

Started by 3DickUlus on Fractal movie gallery

3 Replies
323 Views
Last post August 09, 2018, 01:13:18 PM
by Sabine62