File:Desert planet 8.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (1,024 × 768 pixels, file size: 351 KB, MIME type: image/png)

Captions

Captions

Desert planet. something like Dune

Summary

[edit]
Description
English: Image of Arrakis (Dune) like desert planet
Date
Source Own work
Author Merikanto

Python 3 code to generate maps uses "noise"

    1. desert planet dem
    2. python3 source code
    3. 16.6.2023 0000.0000

import matplotlib.pyplot as plt import numpy as np import math from time import perf_counter from sys import getrefcount from PIL import Image, ImageOps

import noise

import netCDF4 as nc

def save_netcdf_elev(fn, dataa1): shp1=np.shape(dataa1) dimx1=shp1[1] dimy1=shp1[0] ds = nc.Dataset(fn, 'w', format='NETCDF4') latitude = ds.createDimension('latitude', dimy1) longitude = ds.createDimension('longitude', dimx1) lats = ds.createVariable('latitude', 'f4', ('latitude',)) lons = ds.createVariable('longitude', 'f4', ('longitude',)) data = ds.createVariable('z', 'f4', ('latitude', 'longitude',)) data.units = 'm' lats[:] = np.arange(-90, 90, 180/dimy1) lons[:] = np.arange(-180.0, 180, 360/dimx1) data[:, :] = np.flipud(dataa1) ds.close()

def normalize(arra): mini=np.min(arra) maxi=np.max(arra) deltai=maxi-mini return((arra-mini)/deltai)

dimx1=2000 dimy1=1000

outfilename1="desmo.png"

shape = (dimy1,dimx1)

scale = dimx1/2

octaves = 13 persistence = 0.5 ##0.5 lacunarity = 4.0 ## 2.0

    1. ar=0.5

ar=0.25

seed1=0 seed2=1

pi2=math.pi*2 pi=math.pi


t1 = perf_counter()

fiis=np.linspace(0,pi,dimy1) phiis=np.linspace(0,pi2,dimx1)

leni=len(fiis) lenj=len(phiis)

noise0 = np.zeros(shape) for i in range(shape[0]): for j in range(shape[1]): theta=fiis[i] phi=phiis[j] x=ar * math.sin(theta) * math.cos(phi) y=ar * math.sin(theta) * math.sin(phi) z=ar * math.cos(theta) noise0[i][j] = noise.pnoise3(x,y,z,octaves=octaves,persistence=persistence,lacunarity=lacunarity, repeatx=1024, repeaty=1024,repeatz=1024,base=seed1)


noise1 = np.zeros(shape) ar=0.25 for i in range(shape[0]): for j in range(shape[1]): theta=fiis[i] phi=phiis[j] x=ar * math.sin(theta) * math.cos(phi) y=ar * math.sin(theta) * math.sin(phi) z=ar * math.cos(theta) noise1[i][j] = noise.pnoise3(x,y,z,octaves=octaves,persistence=persistence,lacunarity=lacunarity, repeatx=1024, repeaty=1024,repeatz=1024,base=seed2)


noise2 = np.zeros(shape) ar=4 for i in range(shape[0]): for j in range(shape[1]): theta=fiis[i] phi=phiis[j] x=ar * math.sin(theta) * math.cos(phi) y=ar * math.sin(theta) * math.sin(phi) z=ar * math.cos(theta) noise2[i][j] = noise.pnoise3(x,y,z,octaves=octaves,persistence=persistence,lacunarity=lacunarity, repeatx=1024, repeaty=1024,repeatz=1024,base=seed2)


  1. qnoise0= 2 * (0.5 - np.abs(0.5 -noise0) )
  2. qnoise0b=np.power(qnoise0, 3)
  3. qnoise0c=np.abs(qnoise0b)
  1. qnoise0=np.power(noise0, 4)

qnoise0=np.copy(noise0)

qnoise1=np.where(qnoise0 < 0, np.power(qnoise0,2), np.power(qnoise0,0.5) )

qnoise2= 2 * (0.5 - np.abs(0.5 - qnoise1) )

qnoise3=np.power(qnoise2, 6)

qnoise4=np.exp(abs(qnoise3*noise1))

noisex=normalize(qnoise4)+normalize(np.exp(noise1))

  1. siny=np.copy(noisez)*0

siny=np.zeros(shape) cosy=np.zeros(shape)

midi0=shape[0]/2

for i in range(shape[0]): for j in range(shape[1]): ii=i-midi0 ii2=float(ii)/float(midi0) ii3=ii2*math.pi/2 cosy[i, j]=1-(math.cos(ii3)*math.cos(ii3)) siny[i, j]=math.sin(ii3)

siny2=np.copy(siny) siny=np.where(siny>0,0,siny/2) siny2=np.where(siny2>0.4,siny2,0.4)

  1. noisey=normalize(siny*noisex+noisex*0.2)
  1. siny2=1-normalize(siny*siny*siny*siny*siny*siny)

noisey0=normalize(siny2*cosy*noisex+noisex*0.2)

  1. noisey=siny
  1. noisey=noise2

noisey1=normalize(noise2+siny2-0.4)

  1. noisey=siny2

noisey3=normalize(noisey1-np.min(noisey1))/10

noisey=noisey0*(1-normalize(noisey3))

t2 = perf_counter() t3=t2-t1 print("T3:", t3)

  1. I=noisex
  1. I=noisey

I=noisey

maxiima1=(256.0*256.0)-1.0

I16 = (((I - I.min()) / (I.max() - I.min())) * maxiima1).astype(np.uint16)

img = Image.fromarray(I16)

img.save(outfilename1)

    1. desert planet dem, hmax=7400

noisez=noisey*8700

  1. plt.imshow(noisey, cmap="terrain")
  2. plt.imshow(noisey, cmap="YlOrBr")
  3. plt.imshow(noisey, cmap="Oranges")

plt.imshow(np.flipud(noisey), cmap="copper_r")

shaded=1

if(shaded==1): x, y = np.gradient(noisey) slope = np.pi/2. - np.arctan(np.sqrt(x*x + y*y)) aspect = np.arctan2(-x, y) altitude = np.pi / 4. azimuth = np.pi / 2. shaded = np.sin(altitude) * np.sin(slope)+ np.cos(altitude) * np.cos(slope)* np.cos((azimuth - np.pi/2.) - aspect) plt.imshow(np.flipud(shaded), cmap='Greys', origin='lower', alpha=0.5) plt.imsave('desmap.png', noisey, cmap="copper_r")


fig = plt.figure(frameon=False)

fig.savefig("desmap2.png")

plt.show()

save_netcdf_elev("desdem.nc", noisez)

  1. plt.show()

POV-Ray 3.7 scode to render image


// planet from surface imagemap, dem bumpmap

// 19.6.2022 v 0000.0002

  1. include "colors.inc"
  2. include "functions.inc"



global_settings {

  assumed_gamma 1.5
  noise_generator 1

}


light_source {

  <10, 2, -10>*1000*1000*1000, rgb <1, 1, 1>

}

camera {

 location <0,4, -3>
 look_at <0,0,0>   
angle 35

}




  1. declare planetex1= texture {
 pigment { 
 image_map {
  png "desmap.png"

//transmit all 0

       map_type 1
     interpolate 2
  
        }

}


normal {

bump_map {
png "desmo.png"
         bump_size 15
        map_type 1
     interpolate 2

}

//agate

}

finish { ambient 0}

//finish {diffuse 0.85 }

// rotate y*90

}


// clouds ...

  1. declare cloudiness1=0.5; //## suitable 0.5
  2. declare cloudturb1=1;
  3. declare cloudturb2=2;


  1. declare cloudpig1=pigment {

wrinkles // granite // agate //scale 1/10

scale 3 warp { turbulence cloudturb1 } scale 1/2

turbulence cloudturb2

//turbulence 1

pigment_map {
 [0 color rgbt <1,1,1,1>*1]
  [1-cloudiness1 color rgbt <1,1,1,1>]
[1 color rgbt <1,1,1,0>*4]

}



}


  1. declare cloudes1=texture {
   pigment {
   gradient y    
   scale 2
   translate y*-1
  // sine_wave    

scale 3

warp {turbulence 0.7 }

//scale 1/3

 scale 1/2


   pigment_map {
       

[0.1 cloudpig1]

        [0.2 rgbt 1]  
 //     [0.5 cloudpig1]
          [0.7 rgbt 1]
 [0.75 cloudpig1]


   }
   }    
   finish {ambient 0}

}


// rayleigh based atm

  1. declare atm_thickness1 = 0.01;

//#declare atm_color1 = rgb <pow(460/650, 4), pow(460/555, 4), 1>;

#declare atm_color1 = rgb  <1,0.5,0.3>*2; 


  1. declare atm_amount1=1;


  1. declare atm_density1 = density

{

    function
    {
      1*exp(-6.7*(sqrt(x*x+(y)*(y)+z*z)- 1 - 0.00001)/atm_thickness1)
   //   1*exp(-6.7*(sqrt(x*x+(y)*(y)+z*z)-1- 0.00001)/atm_thickness1)
   

} }


  1. declare atm_media1 = media

{

    method 3
    intervals 3
    samples 3
    scattering
    { 4

color atm_amount1*atm_color1/atm_thickness1 // extinction 1

    }
    density {atm_density1}

}


  1. declare atmos1 = difference

{

    sphere {0, 1.00001 + atm_thickness1}
 //   sphere {0, 1.00001}
    hollow
    pigment {rgbt 1}
    interior {media{atm_media1}}

}


  1. declare cloudlayer1= object {
 sphere {0,1


texture {    cloudes1    } 


}


scale 1.003

}


#declare Polar1=

texture { pigment {

  color rgb <1,1,1>*5

}

  normal {
    granite
    scale 0.05   
    //  scale 5
     octaves 15
     
      turbulence 0.1
      bump_size 0.1 

}

finish { ambient 0}

}


  1. declare eis1=texture {
 gradient y 

scale 2 translate y*1

scale 10 warp {turbulence 0.2 } scale 0.1

scale 100

warp {turbulence 0.2 } scale 0.01


texture_map {

      [0 Polar1] 
       [0.04  pigment {color rgbt 1}] 
         [0.97 pigment {color rgbt 1}] 
       [1 Polar1 ]

}

}


  1. declare icecaps1=object {

sphere {0,1 scale 1.001 }

texture {eis1}


}


  1. declare testplate1= object {

// plane {z,0 }

 sphere {0,1

// texture {pigment { wrinkles color_map {[0 color rgb <0,0,1>]}} }

  texture { planetex1

// scale 1 rotate z*90

// rotate x*-45

// rotate x*-90 }



// texture {    cloudes1    } 


}

// rotate x*-90 // rotate y*-90


}




union {

object {testplate1}  
object {icecaps1} 
object {atmos1}  
object {cloudlayer1}

// rotate y*-150 // rotate y*-90 // rotate x*30 }






Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current16:15, 19 June 2023Thumbnail for version as of 16:15, 19 June 20231,024 × 768 (351 KB)Merikanto (talk | contribs)Polar caps, some clouds
17:19, 16 June 2023Thumbnail for version as of 17:19, 16 June 20231,024 × 768 (346 KB)Merikanto (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Metadata