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.

Cast. A Ray Marching Based Rendering

Postby kornwaretm » Mon Feb 06, 2017 9:13 am

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
cpp 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
cpp 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
cpp 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
cpp 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.
cpp 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
kornwaretm
Competition winner
 
Posts: 188
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia

Re: Cast. A Ray Marching Based Rendering

Postby Vectrotek » Mon Feb 06, 2017 8:47 pm

Cooool!! :)
User avatar
Vectrotek
Competition winner
 
Posts: 1056
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Cast. A Ray Marching Based Rendering

Postby Vectrotek » Mon Feb 06, 2017 8:53 pm

I ran the app, but I get..

Image

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

Code looks interesting though! :)
User avatar
Vectrotek
Competition winner
 
Posts: 1056
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Cast. A Ray Marching Based Rendering

Postby kornwaretm » Tue Feb 07, 2017 3:23 am

sorry, i forget to static linking for the the gcc and cpp (-static-libgcc -static-libstdc++). updated, it should works now.
kornwaretm
Competition winner
 
Posts: 188
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia

Re: Cast. A Ray Marching Based Rendering

Postby Vectrotek » Tue Feb 07, 2017 7:38 pm

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..
User avatar
Vectrotek
Competition winner
 
Posts: 1056
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Cast. A Ray Marching Based Rendering

Postby Vectrotek » Tue Feb 07, 2017 8:07 pm

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..
User avatar
Vectrotek
Competition winner
 
Posts: 1056
Joined: Sat May 02, 2015 5:05 pm
Location: South Africa

Re: Cast. A Ray Marching Based Rendering

Postby kornwaretm » Thu Feb 09, 2017 5:25 pm

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.
kornwaretm
Competition winner
 
Posts: 188
Joined: Tue Oct 16, 2007 3:53 am
Location: Indonesia


Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 1 guest