void ProjectedShadow::render( F32 camDist, const TSRenderState &rdata ) { if ( !mUpdateTexture ) return; // Do the render to texture, // DecalManager handles rendering // the shadow onto the world. _renderToTexture( camDist, rdata ); }
void ImposterCapture::capture( const MatrixF &rotMatrix, GBitmap **imposterOut, GBitmap **normalMapOut ) { GFXTransformSaver saver; // this version of the snapshot function renders the shape to a black texture, then to white, then reads bitmaps // back for both renders and combines them, restoring the alpha and color values. this is based on the // TGE implementation. it is not fast due to the copy and software combination operations. the generated bitmaps // are upside-down (which is how TGE generated them...) (*imposterOut) = new GBitmap( mDim, mDim, false, GFXFormatR8G8B8A8 ); (*normalMapOut) = new GBitmap( mDim, mDim, false, GFXFormatR8G8B8A8 ); // The object to world transform. MatrixF centerMat( true ); centerMat.setPosition( -mCenter ); MatrixF objMatrix( rotMatrix ); objMatrix.mul( centerMat ); GFX->setWorldMatrix( objMatrix ); // The view transform. MatrixF view( EulerF( M_PI_F / 2.0f, 0, M_PI_F ), Point3F( 0, 0, -10.0f * mRadius ) ); mRenderPass->assignSharedXform( RenderPassManager::View, view ); mRenderPass->assignSharedXform( RenderPassManager::Projection, GFX->getProjectionMatrix() ); // Render the diffuse pass. mRenderPass->clear(); mMeshRenderBin->getMatOverrideDelegate().bind( ImposterCaptureMaterialHook::getDiffuseInst ); _renderToTexture( mBlackTex, mBlackBmp, ColorI(0, 0, 0, 0) ); _renderToTexture( mWhiteTex, mWhiteBmp, ColorI(255, 255, 255, 255) ); // Now render the normals. mRenderPass->clear(); mMeshRenderBin->getMatOverrideDelegate().bind( ImposterCaptureMaterialHook::getNormalsInst ); _renderToTexture( mNormalTex, *normalMapOut, ColorI(0, 0, 0, 0) ); _separateAlpha( *imposterOut ); _convertDXT5nm( *normalMapOut ); if ( 0 ) { // Render out the bitmaps for debug purposes. FileStream fs; if ( fs.open( "./blackbmp.png", Torque::FS::File::Write ) ) mBlackBmp->writeBitmap( "png", fs ); fs.close(); if ( fs.open( "./whitebmp.png", Torque::FS::File::Write ) ) mWhiteBmp->writeBitmap( "png", fs ); fs.close(); if ( fs.open( "./normalbmp.png", Torque::FS::File::Write ) ) (*normalMapOut)->writeBitmap( "png", fs ); fs.close(); if ( fs.open( "./finalimposter.png", Torque::FS::File::Write ) ) (*imposterOut)->writeBitmap( "png", fs ); fs.close(); } }