Realistic water node

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Thanks The_Glitch! I'm going to have to do a MAJOR update on my Computers,
Software, Major Backups, Net connections, Everything!
Must get Windows 10, I've got a 64 bit Asus M-board, but it's old..

Cheers!
The_Glitch
Competition winner
Posts: 523
Joined: Tue Jan 15, 2013 6:36 pm

Re: Realistic water node

Post by The_Glitch »

Don't get windows 10 it's crap.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

You reckon?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Windows 7? Obviously.. Thanks!
rustyk
Posts: 25
Joined: Sat Jan 10, 2015 4:03 pm

Re: Realistic water node

Post by rustyk »

@Vectrotek

Could you upload your demo/source on other sites other than tinyupload? I'm getting malware alert and blocks from Chrome..

thanks.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: Realistic water node

Post by Vectrotek »

Chrome doesn't like downloading Zip files that contain EXE files.

All you have to do is to go to Chrome Settings - Advanced Settings
and DISABLE the "Protect you and your device from dangerous sites" option
before download. (frustrating I know)

Important:
Remember to ENABLE the option again AFTER the download..
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: Realistic water node

Post by Seven »

trying to setup this nope to only render a portion of the screen.
attempted to use this code to no avail.

my thought was to save the current viewport, modify the viewport and then return the viewport to original.
any ideas on rendering to only a portion of the screen?

Code: Select all

 
void RealisticWaterSceneNode::OnAnimate(u32 timeMs)
{
    ISceneNode::OnAnimate(timeMs);
 
    _time = timeMs;
 
    //fixes glitches with incomplete refraction
    const f32 CLIP_PLANE_OFFSET_Y = 5.0f;
 
    if (IsVisible)
    {
        setVisible(false); //hide the water
 
 
        // seven - save the viewport, modify it and then later return it to original.
        const irr::core::rect<s32> r(100,100,150,200);
        irr::core::rect<s32> oldViewport = _videoDriver->getViewPort();
        _videoDriver->setViewPort(r);
 
 
 
        //refraction
        _videoDriver->setRenderTarget(_refractionMap, true, true); //render to refraction
 
        //refraction clipping plane
        core::plane3d<f32> refractionClipPlane(0, RelativeTranslation.Y + CLIP_PLANE_OFFSET_Y, 0, 0, -1, 0); //refraction clip plane
        _videoDriver->setClipPlane(0, refractionClipPlane, true);
 
        _sceneManager->drawAll(); //draw the scene
 
        //reflection
        _videoDriver->setRenderTarget(_reflectionMap, true, true); //render to reflection
 
        //get current camera
        scene::ICameraSceneNode* currentCamera = _sceneManager->getActiveCamera();
 
        //set FOV anf far value from current camera
        _camera->setFarValue(currentCamera->getFarValue());
        _camera->setFOV(currentCamera->getFOV());
 
        core::vector3df position = currentCamera->getAbsolutePosition();
        position.Y = -position.Y + 2 * RelativeTranslation.Y; //position of the water
        _camera->setPosition(position);
 
        core::vector3df target = currentCamera->getTarget();
 
        //invert Y position of current camera
        target.Y = -target.Y + 2 * RelativeTranslation.Y;
        _camera->setTarget(target);
 
        //set the reflection camera
        _sceneManager->setActiveCamera(_camera);
 
        //reflection clipping plane
        core::plane3d<f32> reflectionClipPlane(0, RelativeTranslation.Y - CLIP_PLANE_OFFSET_Y, 0, 0, 1, 0);
        _videoDriver->setClipPlane(0, reflectionClipPlane, true);
 
        _sceneManager->drawAll(); //draw the scene
 
        //disable clip plane
        _videoDriver->enableClipPlane(0, false);
 
        //set back old render target
        _videoDriver->setRenderTarget(0);
 
        //set back the active camera
        _sceneManager->setActiveCamera(currentCamera);
 
        // seven - return the viewport to the original size
        _videoDriver->setViewPort(oldViewport);
 
        setVisible(true); //show it again
    }
}
Post Reply