Cast. A Ray Marching Based Rendering

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Cast. A Ray Marching Based Rendering

Post by kornwaretm »

Image

About
Cast : an object made by shaping molten metal or similar material in a mold. The general idea of the rendering, by measuring volume using distance function. instead of using 3d textures, 2d textures are used. like pouring molten metal into mold to get desired object. Source Released using MIT license.

status
this software are part of my experiment on rendering. this codes are barely working, there are culling issue, lighting & shadow issue. source code are not in a good shape, i'm still noob in the third dimension.

How to Use
first create an instance of CastRender

Code: Select all

 
using namespace cast;
using namespace volumetric_scene;
 
CCastRender* cast = new CCastRender(device, dimension2d<u32>(W,H));
cast->fogColor = SColor(0xff884422);
cast->ambientColor = SColorf(0xff884422);
cast->setCameraFoV(60.0f);
creating light

Code: Select all

 
dinamicLight* sun = new dinamicLight();
sun->position.X = 0.0f;
sun->position.Y = -20.0f;
sun->position.Z = 10.0f;
sun->color.setRed(255);
sun->color.setGreen(255);
sun->color.setBlue(255);
sun->radius = 5.0f;
sun->castShadows = true;
cast->addLamp(sun);
 
create objects

Code: Select all

 
BaseObject* ob;
ob = new BaseObject(cast );
ob->setHeightMap(driver->getTexture("./textures/tileheight.jpg"));
ob->setColorMap(driver->getTexture("./textures/tile.jpg"));
ob->setScale(vector3df(32.0f, 0.25f, 32.0f));
ob->uvMul = vector2df(16.0f,16.0f);
cast->addObject(ob);
 
finally render all

Code: Select all

 
while(device->run())
    {
        driver->beginScene(true, true, SColor(0,200,200,200));
        cast->update();
        smgr->drawAll();
        guienv->drawAll();
        driver->endScene();
    }
 
demos
if you compile the source code as it is, you will find some lines in the main function to create demos. uncomment one to see other demo.

Code: Select all

 
    // uncomment one
    //demoCube(cast, driver);
    //demoIndianTemple(cast, driver);
    //demoTilingBricks(cast, driver);
    //demoTransparentSurface(cast, driver);
    //demoCiliderObject(cast, driver);
    //demoSphereObject(cast, driver);
    //demoComposit(cast,driver); // maximum object per composite
    demoWarrior(cast,driver);
    //demoHelloWorld(cast,driver);
 
git repo
https://github.com/kornwaretm/Cast-Render
Image
Image
Image

if you are interested in this, please let me know, post a screenshoot, hardware spec, and FPS reply. or may be an idea, correction and critique also welcome.
have fun, korn
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Cast. A Ray Marching Based Rendering

Post by Vectrotek »

Cooool!! :)
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Cast. A Ray Marching Based Rendering

Post by Vectrotek »

I ran the app, but I get..

Image

(I always try to include any dependencies in posted projects)

Code looks interesting though! :)
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: Cast. A Ray Marching Based Rendering

Post by kornwaretm »

sorry, i forget to static linking for the the gcc and cpp (-static-libgcc -static-libstdc++). updated, it should works now.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Cast. A Ray Marching Based Rendering

Post by Vectrotek »

It runs, but I get a BLACK Screen..
Is there any command line options I'm missing?

Also you've disabled the "Console Screen" so I have no clue on what went wrong..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Cast. A Ray Marching Based Rendering

Post by Vectrotek »

It could be because you referred to data as it exists on your machine..
What I mean, is that if you've refer a texture in your code as, say "C:\CODE\MY_PROGRAM\TEXTURES"\MYTEX.png" then on my machine
that's "exactly" where it will look for and NOT FIND IT..

Solve this by rather referring to your data as "RELATIVE TO YOUR EXECUTABLE", say "TEXTURES\MYTEX.png"..
(where "TEXTURES" would be a SUB-FOLDER of the Folder in which your EXE is)

Try running it on someone else's machine and see what happens..
Also, ENABLE the CONSOLE so we can see "what" is loaded and "where" it is looked for..

That COULD be the problem..

Interesting stuff though..
kornwaretm
Competition winner
Posts: 189
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia
Contact:

Re: Cast. A Ray Marching Based Rendering

Post by kornwaretm »

Thanks for the suggestion Vectrotek. i think i have all my path already relative. i think i need to test it on someone else's computer. cant do it right now it is mid night here.
Post Reply