The MASM Forum

General => The Workshop => Topic started by: daydreamer on May 09, 2013, 03:59:28 AM

Title: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 09, 2013, 03:59:28 AM
my first try at procedural texture
16bit still ca 202 bytes

Title: Re: this would be nice to develop to 3d floormapping
Post by: avcaballero on May 09, 2013, 05:29:00 PM
Converting to a 3d floor mapping is not difficult, in short you need to divide by z, the hard part is achieving to make it realistic. I upload an example with sources ;).

Regards.
Title: Re: this would be nice to develop to 3d floormapping
Post by: avcaballero on May 10, 2013, 02:35:05 AM
Hello, daydreamer, this floor is not exactly the same as yours but maybe can helps.
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 11, 2013, 05:12:03 AM
Quote from: avcaballero on May 09, 2013, 05:29:00 PM
Converting to a 3d floor mapping is not difficult, in short you need to divide by z, the hard part is achieving to make it realistic. I upload an example with sources ;).

Regards.
I see you code very different from me, I code by reverse this formula screenx=x/z,screeny=y/z and break out so I can loop screenx and screeny and that creates a random access that complicates to make perlin noise texture on the fly, at close distance need to blend between those pixels I generated
+ the final goal of that circle is to create a racetrack
Title: Re: this would be nice to develop to 3d floormapping
Post by: avcaballero on May 13, 2013, 04:06:25 AM
If not misunderstand, you want a racing map. In my opinion you would need to generate several tiles you must join by a tile map, maybe something like this (http://abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap33.html#Teselado)? Once you have achieve it in 2D you can try it in 3D.

Biskbart had a lovely 3d racing example in qbasic, but I believe that his page (http://biskbart.free.fr/) is in other subjects now. If your are interested in it I can upload it.
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 13, 2013, 06:23:38 AM
Quote from: avcaballero on May 13, 2013, 04:06:25 AM
If not misunderstand, you want a racing map. In my opinion you would need to generate several tiles you must join by a tile map, maybe something like this (http://abreojosensamblador.net/Productos/AOE/html/Pags_en/Chap33.html#Teselado)? Once you have achieve it in 2D you can try it in 3D.

Biskbart had a lovely 3d racing example in qbasic, but I believe that his page (http://biskbart.free.fr/) is in other subjects now. If your are interested in it I can upload it.
thanks,yes please upload it
I think I will go for break up 3drendering to draw many quad polys to make up floor
and rip a 256 color palette from a road and grass photo,which I use to tween between the original random pixels
Title: Re: this would be nice to develop to 3d floormapping
Post by: avcaballero on May 13, 2013, 05:11:30 PM
Here it is ;)
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 16, 2013, 04:16:13 AM
its not finished yet
I dont know why left part of texture is weird, but middle and right part works tweening between random pixels
the blue gonna be replaced with palette
edit:included a palette from a bryce sunset render and testrender first all 32bits of perlin noise with linear interpolation, second test render of 8bits of that using palette lookup for colors, third a testrender on palette looks like
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 16, 2013, 05:40:17 AM
maybe i can ask you guys.....

i have some 2-D image data, X pos, Y pos, and amplitude is represented by color

(http://img833.imageshack.us/img833/4811/twoda.png)

i would like to learn how to convert it to 3-D image data, and rotate it on 3 different axis....

(http://img191.imageshack.us/img191/2413/threed.png)

i am not sure if i want to read about fractals, or what ???   :redface:
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 16, 2013, 06:29:45 AM
you could use d3d and first make a grid of polys where you leave y coordinate and number U and V coordinates evenly from 0.0 on one side to 1.0 to opposite side
and read in data and have a lookup table to translate red to high number in float etc and insert in y dimension in for example dataset for each coordinate in a poly is real4 x,y,z,w,u,v for textured polys, which you read in your texture and set it to be used with d3d stuff
this is from how I learned to rotate with SSE to rotate two circles in parallel
Rotating a point around (0,0,0):

    Recall that the formula for rotating in 2d is:

    Xt = X*COS(í) - Y*SIN(í)
    Yt = X*SIN(í) + Y*COS(í)
   
    Rotations in the third deminsion simply involve rotating on all 3 planes.

    To rotate a point (X,Y,Z) around the point (0,0,0) you would use this
    algorithim:

    1st, rotate on the X axis
   
    Yt = Y*COS(Xan) - Z*SIN(Xan)
    Zt = Y*SIN(Xan) + Z*COS(Xan)
    Y = Yt              --  Note that you must not alter the cordinates
    Z = Zt              --   until both transforms are preformed
   
    Next, rotate on the Y axis

    Xt  = X*COS(Yan) - Z*SIN(Yan)
    Zt  = X*SIN(Yan) + Z*COS(Yan)
    X   = Xt
    Z   = Zt

    And finally, the Z axis

    Xt  = X*COS(Zan) - Y*SIN(Zan)
    Yt  = X*SIN(Zan) + Y*COS(Zan)
    X   = Xt
    Y   = Yt
 
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 16, 2013, 06:48:56 AM
Hi Dave,

   You could use a height map with a ray-tracer.  I think I did
something like that a long time ago with the POVRay ray-
tracer.

Regards,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 16, 2013, 07:27:44 AM
many thanks for pointing me in the right direction guys   :t

gives me a place to start   :biggrin:
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 18, 2013, 02:47:32 AM
Hi,

   Just a quick example of what I can do relatively quickly in a ray-
tracer.

Regards,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 03:19:06 AM
yes - that's the idea   :P

i guess Abe was never good-looking - lol
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 18, 2013, 04:19:09 AM
Hi Dave

Are the images you showed us the originals?
Because I did load them in paintshop pro, the color pallet is not in the right order to get the right amplitudes from it.
I can try to order them on luminance but that's a lot of work. Thus making a heigth map from this image is a bit difficult.

If you want a Direct3d9 source code example how to make a 3D height map from an image and rotation on 3 axis, I can put something together.

I know 2 ways of doing this stuff.
With textures or with vertex colors.
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 18, 2013, 05:18:10 AM
Hi,

   Yes, I tried using the posted image as a height field.  It did not
work out.  One would have to have the raw data or the palette
that was used to create the image to recreate the raw data.
Not to mention that different programs would probably treat an
image as a height field differently.

Cheers,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 06:08:26 AM
this is a 24-bit image
actually, it is a 256-color image when displayed
i will see if i can make one

(http://i1154.photobucket.com/albums/p527/DednDave/TestImg.png)
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 06:45:44 AM
this might help   :biggrin:

(http://i1154.photobucket.com/albums/p527/DednDave/palette.png)
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 18, 2013, 06:55:50 AM
Nice, it's rgb from blue 000001h to red ff0000h.
We can make a height map from this image.  8)
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 18, 2013, 07:28:14 AM
Hi Dave,

   I converted your image to gray scale for a height field.  It isn't
too bad, though the mapping is not all that good.  I'll see if I can
use that palette to convert things and try again.  Off to write a
tool I guess.

Cheers,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 07:44:48 AM
don't write a tool, Steve

this evening or tomorrow, i will post some 256-color images with the palette in the same image
the mapping is pretty simple, then - the higher the palette numer, the higher the Z amplitude

however, you should be able to use the palette image above to get numbers   :P
if we have 256-color images, the actual color won't matter, though - lol

also - i may adjust the palette curve to make better looking images
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 12:11:46 PM
these are big images
you can crop out any section of either - to a size that suits your needs
the palette entry numbers indicate amplitude - that makes it easy to convert image data

image1.zip ~1.6 mb
http://dedndave.x10.mx/Files/image1.zip (http://dedndave.x10.mx/Files/image1.zip)

image2.zip ~3.44 mb
http://dedndave.x10.mx/Files/image2.zip (http://dedndave.x10.mx/Files/image2.zip)

i really appreciate your help with this   :t
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 18, 2013, 05:36:17 PM
I have a problem with this so this ends up a .99mb .exe so I can't post it here, so is my included lib
hope Siekmanski could share his smaller d3d9 includes and libs here
but this d3d shows how you can setup a grid of polys which I change UV coordinates to animate a water texture, you can change it to instead change Y coordinates reading from your file in the section that writes to vertexbuffer and make grid size based on image size, and I also didnt get d3d to work correctly so I did oldschool x/z,y/z 3d view instead
shows how it can look with my textures
also starts looking for my old grand canyon files, I have somewhere a west and east 9mb each file some odd textfile format with height in meters written down evenly divided without 'enter' between each row
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 18, 2013, 06:25:41 PM
Nice and usable pictures to create height maps.  :t
Hope to finish an example in d3d9 this weekend and post it including source code and libs.  :biggrin:
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 18, 2013, 11:28:22 PM
interesting code daydreamer - i am reading it and trying to comprehend   :biggrin:

Thanks, Marinus - i thought that would make life easier - lol
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 18, 2013, 11:59:01 PM
I am busy cleaning and now debugging my perlin noise code
my d3d9 code is like that because I am not skilled enough to make waterfall and sea with pixelshaders

@Dave: I highly recommend you take a look at Ultranos ATC and Homer's d3d9 coding
ATC is very helpful as it makes it possible to take directx C++ code data section without need tedious recode all FLOAT'S to REAL4'S
Homer has a lot of d3d9 coding examples to learn from, I just dug up few of his demos from my old backup drive

@Marinus: I started bryce to try to export some nice rocky bumpmap to add detail to Dave's landscape
I did this because some I got inspired by ATI sdk I found a cave demo screensaver
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 19, 2013, 12:21:21 AM
thanks - i am familiar with ultrano - let me see what i can find   :t

by the way....
the images use 36 "actual" vertical data points
my code interpolates values in between to come up with 771 pixel high images
(35 x 22 + 1 = 771), i interpolate 21 points between each data point
for now, i am using linear interpolation
later, i may use some sort of best-fit curve function to get nicer results
i am guessing you will be able to notice the linear interpolation in the 3-d transform   :P

btw: i can wrap my head around 3-d transformation, easily enough
the part i don't understand is "this part is visible, this part isn't" - lol
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 19, 2013, 12:30:05 AM
Quote from: dedndave on May 18, 2013, 07:44:48 AM
don't write a tool, Steve

this evening or tomorrow, i will post some 256-color images with the palette in the same image
the mapping is pretty simple, then - the higher the palette numer, the higher the Z amplitude

Hi Dave,

   That speeds things up a good bit.  My tool chain is a bit old, so
small images only for now.  But you should get the idea.

Regards,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 19, 2013, 12:37:28 AM
that is cool
you CAN see the linear interpolation   :biggrin:
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 19, 2013, 02:24:25 AM
Hi Dave,

Quote from: dedndave on May 19, 2013, 12:37:28 AM
that is cool

   Thanks.

Quote
you CAN see the linear interpolation

   That can be turned off.  But I think it looks nicer with it on.
I have some lighting options on as well.

Regards,

Steve
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 19, 2013, 02:47:54 AM
i don't know what you mean by turning it off and on
the linear interpolation i am refering to is in the original image   :P
re: reply #26
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 19, 2013, 03:50:19 AM
Hi,

   I had the "smooth" option on.  Otherwise it plots the height
field as little boxes.  Nice sharp edges all about.  Crystalline?

Regards,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 19, 2013, 07:02:55 AM
hi,
I've spend some hours because I find this very interesting.
For reconstructing the surface I've used a very simple approach, which creates triangles between the pixels (memory expensive because we need 6 vectors per pixel). For the height, the RGB values are transform to HSV and the normalized hue-value is used. The mouse control (virtual trackball) isn't perfect but it somehow works. Zooming is possible using the mouse wheel. Also the height-scaling can be changed (see buttons).
I'm curios if the attach program run on other machines, because I'm afraid the code makes some assumptions that are only true for my laptop (currently).

qWord

BTW: the attachment is an WinRAR archive and not ZIP (because of the size).
BTW2: do not assume to be able to build the source. It requires SmplMath+JWASM+WinInc+libs (e.g. from Windows SDK / DirectX SDK)

EDIT: new attachment
Title: Re: this would be nice to develop to 3d floormapping
Post by: jj2007 on May 19, 2013, 07:28:54 AM
Both executables won't run unless you have installed d3dx9_42.dll (which I haven't :()
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 19, 2013, 08:02:16 AM
You maybe try to install the latest DirectX version: http://www.microsoft.com/en-us/download/details.aspx?id=35
Title: Re: this would be nice to develop to 3d floormapping
Post by: jj2007 on May 19, 2013, 08:12:14 AM
48MB is a bit too much for my harddisk, sorry...
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 19, 2013, 03:09:16 PM
i installed it - wanted it, anyways
eventually, i would like to be able to code this without it, though   :P
nothing wrong with setting goals - lol
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 19, 2013, 07:24:22 PM
qword, runs on centrino duo 1,6ghz  :t
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 19, 2013, 11:19:46 PM
it runs, but i am not sure if i am seeing what was intended   :redface:
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 20, 2013, 02:56:15 AM
Hi,

   Tweaked a few things.  Turned off the smoothing and shininess.
Played a bit with the color.  Killed the background checkerboard
The changes should show a bit of the features of a height field.

Cheers,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 03:16:08 AM
that is AWESOME, Steve   :t
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 20, 2013, 04:16:27 AM
There were several issues in my code - I've upload a new version in my previous post.
Quote from: dedndave on May 19, 2013, 11:19:46 PM
it runs, but i am not sure if i am seeing what was intended   :redface:
you should see something like this:
(http://image-upload.de/image/HpNtQw/2512bf0b13.png)
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 04:24:04 AM
it's very nice - i like the rotation stuff   :t
but, i only seem to be seeing part of the image
this is about as much as i can see by adjustment

(http://img802.imageshack.us/img802/8770/qwordterrain.png)

i am running XP if that makes a difference
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 20, 2013, 04:38:02 AM
hi,
what I did not do is to check the maximal number of primitives that can be drawn - maybe that limit is reach fro your machine (Also, as said above, my approach is memory expensive and needs 96 bytes per pixel). You can try to reduce the image width/height and see if there is an difference.

qWord

EDIT: new version attached in above post
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 08:44:43 AM
the newer images are 256-color bmp's
it would probably be easier to use a section of one of those
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 08:52:03 AM
if i answer Yes to vertex processing, it says Can't create direct-3d device
if i answer No.....

(http://img46.imageshack.us/img46/741/qwordterrain3.png)
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 20, 2013, 03:18:35 PM
Quote from: dedndave on May 20, 2013, 08:52:03 AM
if i answer No.....
Can you please test the attached program to see if the issue is fixed?
I've also add some lighting and the graph can be translated along the x and y axis by pressing CTRL while mouse dragging.

qWord

(http://image-upload.de/image/dkXPFA/71fb8ce53e.jpg)
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 05:12:30 PM
much better   :t

(http://img69.imageshack.us/img69/1948/qwordterrain4.png)

try using this image
it is a 256-color bmp
the palette index (0 to 255) is the height

(http://dedndave.x10.mx/Files/img256.bmp)
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 20, 2013, 10:15:55 PM
Quote from: dedndave on May 20, 2013, 03:16:08 AM
that is AWESOME, Steve   :t

Hi Dave,

   Glad you liked it.  Here is the scene description / code that I used.
More complex than needed as I try to set up a right handed, Z up
coordinate system rather than the default left handed, Z forward
system.  Which is why the penny came out backwards I guess.
I think the include files are no longer used, so ignore them.

   I fire up the ray tracer every year or so to look at things.  See
http://www.povray.org (http://www.povray.org) for the current version.  I still
use the old version that came with the book I bought back when.
I tend to like hard copy documentation.

Regards,

Steve N.


// Height.POV, 17 May 2013, SRN
// Height field excursion from MASM Forum

#include "colors.inc"           // Standard colors library
#include "shapes.inc"
#include "shapes2.inc"
#include "textures.inc"

// Force a right handed system
camera { location < -1, 0, 1.5 > direction < 2.25, 0, -0.5 >
         up < 0, 0, 1 > sky < 0, 0, 1 > right < 0, -1.33, 0 > }

light_source { < 1, 2, 2 > color red 1 green 1 blue 1 }
light_source { < 2, 1, 2 > color red 1 green 1 blue 1 }

background { color White }

// Data

// // Background
// plane { z, -1.0
//   texture {
//     pigment { checker color rgb < 1.0, .7, 1.0 > color White }
//     finish {  ambient 0.1 } } }

// Height field data

// height_field { gif "New-1.GIF" smooth pigment {
height_field { gif "New-1.GIF" pigment {
                 gradient y color_map {
                   [ 0.0 color red 0 green 0 blue 1 ]
                   [ 0.05882 color red 0 green 0.35294 blue 1 ]
                   [ 0.21961 color red 0 green 0.79216 blue 0.72549 ]
                   [ 0.29020 color red 0 green 1 blue 0.25882 ]
                   [ 0.33333 color red 0 green 1 blue 0 ]
                   [ 0.49804 color red 0.98824 green 1 blue 0 ]
                   [ 0.53725 color red 0.99216 green 0.91765 blue 0 ]
                   [ 0.64706 color red 0.97647 green 0.69020 blue 0 ]
                   [ 0.72941 color red 0.95686 green 0.51765 blue 0 ]
                   [ 0.78431 color red 0.94510 green 0.40784 blue 0 ]
                   [ 0.88627 color red 0.90980 green 0.20392 blue 0 ]
                   [ 0.95686 color red 0.86667 green 0.07451 blue 0 ]
                   [ 1.0 color red 0.82745 green 0 blue 0 ] } }
//               finish { phong 0.3 }
                 finish { ambient 0.75 }
               scale < -1.66, 0.3, 1.25 > rotate < 60, 0, 90 > translate < 1.5, 0.85, 0.5 > }
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 20, 2013, 10:37:37 PM
thanks Steve - let me see what i can learn from it   :t
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 06:54:07 AM
Hi guys

Here are some D3D9 heigthmap examples without using the D3DX9 library.
Bitmaps are embedded.

Press F1 to toggle Fullscreen.

1. BMP of 64 by 64 with 4096 color vertices and 7938 polygons.
2. BMP of 128 by 128 with 16384 color vertices and 32258 polygons.
3. BMP of 256 by 256 with 65536 color vertices and 130050 polygons.

Had a lot of visitors at my house this weekend, so better late than never hahahaha....
I'll clean up my source code this week and post them.

@Dave, hope you wanted something like this.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 21, 2013, 07:20:34 AM
hi Marinus
thanks for trying, but on all three, i get "unable to create Direct3D Object"   :(
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 07:40:34 AM
 :(

And this one?
edit: new version
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 21, 2013, 07:51:09 AM
that one flies   :t

very nice image, too

the "top" edge flashes as it rotates, but i suspect that could be easily fixed
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 07:56:40 AM
So it works now?

I like to now if there where others who downloaded the examples and have problems running the 3 examples.
So I can locate the error.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 21, 2013, 08:10:03 AM
yes - the 4th one works pretty well

if it helps, i am running XP SP3, prescott @ 3 GHz, 2 Gb ram
the video is intel 82915GV Express Chipset on the motherboard
for it's time, it was decent stuff, but it's time was about 8 years ago - lol
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 08:24:54 AM
Seems to be a "IDirect3D9::CreateDevice" BehaviorFlags issue. ( type of VERTEXPROCESSING )
Like to hear from the other guys who tested the examples and make a fix then.

The "top" edge flashes are probably the very sharp 1 pixel height difference.
I'll make an amplitude factor in my code so you can play with that.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 21, 2013, 08:28:35 AM
you might look at qWord's examples
he got around the issue by using software vertex processing, as opposed to hardware
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 08:42:39 AM
@Dave,

I changed the type to "software vertex processing" in the 4th example.
I'm searching for the best type of VERTEXPROCESSING on the videocard.

Can you test this one and tell me what vertex processing type you have?
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 21, 2013, 08:46:22 AM
HAL software vertex processing

funny - i was just looking at that example
it was in with your include files on the old forum   :P
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 08:50:31 AM
 :biggrin:

Thanks, now I know what to do.....
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 21, 2013, 02:51:27 PM
Quote from: Siekmanski on May 21, 2013, 06:54:07 AM
Hi guys

Here are some D3D9 heigthmap examples without using the D3DX9 library.
Bitmaps are embedded.

Press F1 to toggle Fullscreen.

1. BMP of 64 by 64 with 4096 color vertices and 7938 polygons.
2. BMP of 128 by 128 with 16384 color vertices and 32258 polygons.
3. BMP of 256 by 256 with 65536 color vertices and 130050 polygons.

Had a lot of visitors at my house this weekend, so better late than never hahahaha....
I'll clean up my source code this week and post them.

@Dave, hope you wanted something like this.
I have no trouble running this on a 1.6ghz centrino duo laptop with ATI x1600 mobile
maybe you should check for hardware CAPS and if no hardware support use software instead
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 07:51:04 PM
I do so in my code, but Dave's videocard seems to be a special case....  ;)
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 21, 2013, 09:41:38 PM
Hi,

    Ran the program in Reply #52 on an XP machine and it looks
good.  It did not run (well) on the Win2k machine.

Regards,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 21, 2013, 11:23:31 PM
Hi guys

@FORTRANS
Can you tell me a bit more about; "It did not run (well) on the Win2k machine."

@Dave
found this text in the DirectX SDK:

"Be careful if your hardware supports pixel processing (transforms and lighting) but does not support vertex processing.
If device doesn't support HW T&L or doesn't support 1.1 vertex shaders in HW, then switch to SWVP."

Hope this solves your vertex processing issue.

Here is the "BehaviorFlags" code to control the device creation:


    mov         eax,d3dcaps.DevCaps
    test        eax,D3DDEVCAPS_HWTRANSFORMANDLIGHT
    .if (eax != 0)
        test        eax,D3DDEVCAPS_PUREDEVICE
        .if (eax != 0)
            mov         ecx,D3DCREATE_HARDWARE_VERTEXPROCESSING or D3DCREATE_PUREDEVICE
        .else
            mov         ecx,D3DCREATE_HARDWARE_VERTEXPROCESSING
        .endif
    .else
        mov         ecx,D3DCREATE_SOFTWARE_VERTEXPROCESSING
    .endif

    mov         eax,d3dcaps.VertexShaderVersion
    .if (eax < D3DVS_VERSION(1,1))
        mov         ecx,D3DCREATE_SOFTWARE_VERTEXPROCESSING
    .endif

    .if (m_MultiThreaded)
        or          ecx,D3DCREATE_MULTITHREADED
    .endif


    coinvoke    g_pD3D,IDirect3D9,CreateDevice,m_D3DAdapter,m_D3DDevType,hwnd,ecx,addr d3dpp,addr g_pD3DDevice
    if_FAILED
        return  E_FAIL
    .endif


Here are the D3D9 heigthmap examples with this piece of code.

Press F1 to toggle Fullscreen.

1. BMP of 32 by 32 with 1024 color vertices and 1922 polygons.
2. BMP of 64 by 64 with 4096 color vertices and 7938 polygons.
3. BMP of 128 by 128 with 16384 color vertices and 32258 polygons.
4. BMP of 256 by 256 with 65536 color vertices and 130050 polygons.
Title: Re: this would be nice to develop to 3d floormapping
Post by: MichaelW on May 21, 2013, 11:55:39 PM
On my Windows XP SP3, P4 Northwood, NVIDIA GeForce FX5200 system
D3D9_DaveHM2 runs fine, D3D9x3Dtext has a problem with a missing MSVCRT70.DLL, and all of the
D3D9_DaveHM3 apps run fine.
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 22, 2013, 12:09:23 AM
they run pretty well here, Marinus   :t

the 256 version has a problem where the top of the image flickers as it rotates
it's as though part of the image is cropped off for every other rotation frame

therwise, they are great images

i have been thinking about ways to do this without using direct3d
i.e., straight code   :P
there are a few "camera" examples out there to look at
but, i was trying to figure out how it works by myself - lol

EDIT: one thing these 3-d images are showing me is that i also need to work on a best curve interpolation
linear interpolation just doesn't cut it   :P
Title: Re: this would be nice to develop to 3d floormapping
Post by: FORTRANS on May 22, 2013, 12:29:33 AM
Quote from: Siekmanski on May 21, 2013, 11:23:31 PM
Hi guys

@FORTRANS
Can you tell me a bit more about; "It did not run (well) on the Win2k machine."

Hi,

   Okay, ran it three times, and got three results.

   First time from a from a command prompt in a window.  A
window showed up, but it showed the screen background.  Which
stayed unchanged when I moved it around.  I hit escape and it went
away.  That prompted my comment.

   Second time to retry things, I started it from a command line in a
full screen session.  (Had one open.)  Popup that said "CheckDeviceType:
Not available on this graphicscard, changing settings now...".  Clicking
that brought up "Unable to create Direct3D Object".  Clicked that and
nothing else happened.

   Third time as the first from a windowed command prompt.  And
a window showed up containing the background.  I hit F1 to see
what would happen.  The mouse pointer went away, the CPU went
100%, got to the Windows Task Manager, but it was unresponsive,
and I had to reboot.

HTH,

Steve N.
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 22, 2013, 01:05:00 AM
Hi MichaelW

D3D9x3Dtext uses the D3DX9 library and needs a lot of other dll's.
You get a bloated exe that only runs on the machines that have the right version of DirectX installed.

The D3D9.lib is present on all PC's

Thats why I don't use the D3DX9 library anymore and write my own routines for the math functions and the texture loading etc.

So keeping my exes small and hopefully running on every PC.

@Dave

That's a lot of work, rotation matrices, sorting, backface culling, clipping etc.
But it's fun to do.
Been there on the Amiga programming Demos.

You can have look at spline or hermite interpolation.

@FORTRANS

Thanks, but don't have a clue why they don't run.  :(
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 22, 2013, 01:42:14 AM
As promised, the sources and libs.



Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 22, 2013, 01:48:22 AM
oh great !
thanks, Marinus
i see you added the D3DMathSSE2 inc/lib   :t

many thanks for all your help, guys
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 22, 2013, 02:02:27 AM
Quote from: Siekmanski on May 22, 2013, 01:05:00 AMD3D9x3Dtext uses the D3DX9 library and needs a lot of other dll's.
You get a bloated exe that only runs on the machines that have the right version of DirectX installed.
I think that is the reason why all DX software come up with their own customized DX installation (http://msdn.microsoft.com/en-us/library/windows/desktop/ee416805%28v=vs.85%29.aspx).
If I'm not wrong, the whole installation files would have a size of 3.3MB for my above example.
Title: Re: this would be nice to develop to 3d floormapping
Post by: daydreamer on May 22, 2013, 02:10:47 AM
I think win2k might be too old for dx9c or whatever version you have targeted marinus
Also gonna share cubic, quintic, cosine interpolation code which can be used more than for perlin noise
Marinus what about add a rocky bumpmap to the terrain.?
With fast memoryspeed why not make use of a system memory zbuffer for software rendering?
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 22, 2013, 02:11:11 AM
yes - Jochen mentioned something like 48 mb
but, i think the redistributable install would be much smaller

for interpolation, i am thinking of deriving a simple integer strategy using conic sections (circle, elipse, parabola)
between each data point pair, i can find a center, initial delta, and delta-delta
that should be fairly fast and provide reasonable results
no need for a bunch of floating point math when there are only 256 colors and 21 interpolated points   :P
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 22, 2013, 02:51:18 AM
i installed the d3d sdk
part of it is a folder of redistrib files
that folder is ~93 mb
but i think it only installs a small part of that, based on which video card you have   :P
Title: Re: this would be nice to develop to 3d floormapping
Post by: qWord on May 22, 2013, 02:57:09 AM
Quote from: dedndave on May 22, 2013, 02:51:18 AMbut i think it only installs a small part of that, based on which video card you have   :P
no, only the part which is required by the application. (e.g. the latest D3DX9 lib: Jun2010_d3dx9_43_x86.cab + setup).
Title: Re: this would be nice to develop to 3d floormapping
Post by: Siekmanski on May 22, 2013, 03:29:45 AM
The D3DMathSSE2 inc/lib is not complete yet but most routines are finished.
Some of them still need to be sped up by paralel coding.

I'll clean up the source of my lib for texture loading ( jpg gif bmp ) and come up with a simple example.


Ýou can try to cheat the eyes and brain.
That's why I did 4 versions with small pictures and let the videocard do the linear color conversion.
Adding some light and shading will improve the eye candy.
Most of the games use grids of 32*32 or 64*64 vertices.

The 256 version has to much resolution so the tops flicker because they are 1 pixel wide
Title: Re: this would be nice to develop to 3d floormapping
Post by: dedndave on May 22, 2013, 08:06:52 AM
yah - it would be easy to just crop that off   :P