Changeset 2333 for GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Timestamp:
- 04/24/07 14:04:48 (18 years ago)
- Location:
- GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreIlluminationManager.cpp
r2320 r2333 79 79 { 80 80 visitor = new VisibleFinderVisitor(&visibleObjects); 81 joinRuns = true; 81 82 maxRad = 400; 82 83 focusingMapSize = 32; 83 shadowMapSize = 512;84 84 phaseTextureSize = 256; 85 useLISPSM = false; 86 // useVSM = false; 87 blurSM = false; 88 focusingSM = true; 89 shadowMapMaterialName = "GTP/Basic/Distance_NormalizedCCW"; 85 shadowMapSizeDirectional = shadowMapSizePoint = shadowMapSizeSpot = 512; 86 useLISPSMDirectional = useLISPSMPoint = useLISPSMSpot = false; 87 blurSMDirectional = blurSMPoint = blurSMSpot = false; 88 focusingSMDirectional = focusingSMPoint = focusingSMSpot = true; 89 shadowMapMaterialNameDirectional = "GTP/Basic/Depth or GTP/Basic/DepthCCW"; 90 shadowMapMaterialNamePoint = "GTP/Basic/Distance_NormalizedCCW"; 91 shadowMapMaterialNameSpot = "GTP/Basic/Distance_NormalizedCCW"; 90 92 areaLightRadius = 0.1; 91 93 … … 515 517 fillVisibleList(rq); 516 518 517 int l = visibleObjects.size(); //debug 518 519 joinSharedRuns(); 520 521 int ll = sharedRunRoots.size(); //debug 519 if(joinRuns) 520 { 521 int l = visibleObjects.size(); //debug 522 joinSharedRuns(); 523 int ll = sharedRunRoots.size(); //debug 524 } 522 525 523 526 //update precomputings … … 717 720 { 718 721 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 722 Light* light = sm->getLight(lightName); 723 unsigned int res; 724 String MaterialName; 725 switch(light->getType()) 726 { 727 case Light::LT_DIRECTIONAL: 728 res = shadowMapSizeDirectional; 729 MaterialName = shadowMapMaterialNameDirectional; 730 break; 731 case Light::LT_POINT: 732 res = shadowMapSizePoint; 733 MaterialName = shadowMapMaterialNamePoint; 734 break; 735 case Light::LT_SPOTLIGHT: 736 res = shadowMapSizeSpot; 737 MaterialName = shadowMapMaterialNameSpot; 738 break; 739 } 740 719 741 OgreDepthShadowMapRenderingRun* run = new OgreDepthShadowMapRenderingRun( 720 742 runs, 721 743 lightName + "DEPTH_SHADOW_MAP", 722 sm->getLight(lightName),723 shadowMapSize,724 shadowMapSize,725 shadowMapMaterialName //TODO744 light, 745 res, 746 res, 747 MaterialName 726 748 ); 727 749 runs->addRun(ILLUMRUN_DEPTH_SHADOWMAP, run); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/OgreRenderingRun.cpp
r2265 r2333 5 5 Entity* OgreRenderingRun::fullScreenQuadEntity = NULL; 6 6 SceneNode* OgreRenderingRun::fullScreenQuadNode = NULL; 7 BillboardSet* OgreRenderingRun::pixelSprites = NULL; 8 Entity* OgreRenderingRun::fullscreenGrid = NULL; 9 String OgreRenderingRun::spriteSetName = ""; 7 10 8 11 class MaterialSetVisitor : public QueuedRenderableVisitor … … 231 234 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 232 235 233 if( this->fullscreenGrid == NULL)236 if(fullscreenGrid == NULL) 234 237 { 235 238 MeshPtr mesh = MeshManager::getSingleton().createManual("FullScreenGrid",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgreDepthShadowReceiverRenderTechnique.cpp
r2299 r2333 125 125 GpuProgramParametersSharedPtr fpParams = passes.at(i)->getFragmentProgramParameters(); 126 126 GpuProgramParametersSharedPtr vpParams = passes.at(i)->getVertexProgramParameters(); 127 128 //fpParams->setNamedConstant("lightViewProj", depthRun->getLightViewProjMatrix()); 127 129 128 if(setLightViewProjMatrix) 130 129 vpParams->setNamedConstant(lightViewProjParamName, depthRun->getLightViewProjMatrix()); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderTechniques/OgrePathMapRenderTechnique.cpp
r2299 r2333 63 63 TextureUnitState* st = newpass->createTextureUnitState(); 64 64 st->setTextureFiltering(TFO_BILINEAR); 65 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);65 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 66 66 st->setTextureBorderColour(ColourValue::Green); 67 67 st->setTextureName(clusters->pathMapTextureFilename); … … 71 71 st = newpass->createTextureUnitState(); 72 72 st->setTextureFiltering(TFO_NONE); 73 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);73 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 74 74 st->setTextureBorderColour(ColourValue::Red); 75 75 st->setTextureName(weightIndexTexture->getName()); … … 77 77 st = newpass->createTextureUnitState(); 78 78 st->setTextureFiltering(TFO_NONE); 79 st->setTextureAddressingMode(TextureUnitState::TAM_ BORDER);79 st->setTextureAddressingMode(TextureUnitState::TAM_CLAMP); 80 80 st->setTextureBorderColour(ColourValue::Blue); 81 81 … … 122 122 LightList lights; 123 123 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 124 sm->_populateLightList(Vector3(0,0,0), 1000, lights); //TODO 125 //TODO set weights 126 /* 127 unsigned int entryPointCount = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 128 PathMapClusters* clusters = OgreIlluminationManager::getSingleton().getPathMapClusters(parentOgreRenderable->getName()); 129 int weightTextureWidth = clusters->count / 4; 130 */ 131 for(int i = 0 ; i < 1; i++) 132 { 133 String lightName = lights.at(0)->getName(); 124 sm->_populateLightList(OgreIlluminationManager::getSingleton().getMainCamera()->getPosition(), 1000, lights); 125 126 for(int i = 0 ; i < 5 && i < lights.size(); i++) 127 { 128 String lightName = lights.at(i)->getName(); 134 129 OgreIlluminationManager::getSingleton().createPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP); 135 OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum); 136 OgrePMWeightComputeRenderingRun* PMWeightRun = (OgrePMWeightComputeRenderingRun*) 137 OgreIlluminationManager::getSingleton().getPerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP)->asOgreRenderingRun(); 138 139 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 140 st->setTextureName(PMWeightRun->getPMWeightTetureName()); 141 142 /* 143 TexturePtr tex = TextureManager::getSingleton().getByName(PMWeightRun->getPMWeightTetureName()); 144 float *allClusterWeights = new float[entryPointCount]; 145 PixelBox lockBox(entryPointCount, 1, 1, PF_FLOAT32_R, allClusterWeights); 146 tex->getBuffer()->blitToMemory(lockBox); 147 148 float *weightIndices = new float[clusters->count]; 149 for(int j = 0; j< clusters->count; j++) 150 weightIndices[j] = allClusterWeights[clusters->clusters[j]]; 151 152 PixelBox lockBox2(weightTextureWidth, 1, 1, PF_FLOAT32_RGBA, weightIndices); 153 weightIndexTexture->getBuffer()->blitFromMemory(lockBox2); 154 155 TextureUnitState* st = pathMapPass->getTextureUnitState(1); 156 st->setTextureName(weightIndexTexture->getName()); */ 130 OgreIlluminationManager::getSingleton().updatePerLightRun(lightName, ILLUMRUN_PM_WEIGHTMAP, frameNum); 157 131 } 158 } 132 OgrePMWeightComputeRenderingRun::sumWeights(frameNum); 133 TextureUnitState* st = pathMapPass->getTextureUnitState(2); 134 st->setTextureName(OgrePMWeightComputeRenderingRun::getPMWeightTextureName()); 135 } 136 137 159 138 160 139 namespace PathMapParsers -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreDepthShadowMapRenderingRun.cpp
r2321 r2333 26 26 void OgreDepthShadowMapRenderingRun::createDepthMap() 27 27 { 28 if(light->getType() == Light::LT_POINT) 29 { 30 depthMapTexture = createCubeRenderTexture(name, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 31 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 32 blurredDepthMapTexture = createCubeRenderTexture(blurredname, light->getPosition(), resolutionX,PF_FLOAT16_RGBA,0,ColourValue::White); 33 } 34 else 35 { 28 36 29 37 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name, … … 46 54 rt->setAutoUpdated(false); 47 55 48 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))56 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 49 57 { 50 58 texPtr = Ogre::TextureManager::getSingleton().createManual(blurredname, … … 64 72 rt->setAutoUpdated(false); 65 73 } 74 } 66 75 } 67 76 … … 72 81 if(light->getType() == Light::LT_POINT) 73 82 { 74 updateDepthMap(); 83 //static int currentFace = 0; 84 //updateDepthCubeFace(currentFace); 85 //currentFace = (currentFace+1)%6; 86 87 for(int i = 0; i < 6 ; i++) 88 updateDepthCubeFace(i); 75 89 } 76 90 else … … 82 96 void OgreDepthShadowMapRenderingRun::updateDepthCubeFace(int facenum) 83 97 { 98 Vector3 lightpos = light->getDerivedPosition(); 99 100 RenderTarget* rt = depthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 101 Camera* cam = rt->getViewport(0)->getCamera(); 102 cam->setPosition(lightpos); 103 cam->setFarClipDistance(lightFarPlane); 104 105 setMaterialForVisibles(materialName, cam, false); 106 rt->update(); 107 restoreMaterials(); 108 109 //rt->writeContentsToFile("shadowmap_" + StringConverter::toString(facenum) + ".dds"); 110 111 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 112 { 113 rt = blurredDepthMapTexture->getBuffer(facenum, 0).getPointer()->getRenderTarget(); 114 Material* mat = (Material*) MaterialManager::getSingleton().getByName("GameTools/BlurCubeFace").getPointer(); 115 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(depthMapTexture->getName()); 116 mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters()->setNamedConstant("face", facenum); 117 renderFullscreenQuad("GameTools/BlurCubeFace", rt); 118 119 //rt->writeContentsToFile("shadowmap_blurred_" + StringConverter::toString(facenum) + ".dds"); 120 } 121 84 122 } 85 123 … … 93 131 restoreMaterials(); 94 132 95 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))133 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 96 134 { 97 135 rt = blurredDepthMapTexture->getBuffer().getPointer()->getRenderTarget(); … … 108 146 const String& OgreDepthShadowMapRenderingRun::getDepthMapTextureName() 109 147 { 110 if(OgreIlluminationManager::getSingleton().getBlurShadowMap( ))148 if(OgreIlluminationManager::getSingleton().getBlurShadowMap(light->getType())) 111 149 return blurredname; 112 150 … … 119 157 if(light!= 0) 120 158 { 121 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM( );122 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap( );159 bool uselispsm = OgreIlluminationManager::getSingleton().getUseLISPSM(light->getType()); 160 bool usefocusing = OgreIlluminationManager::getSingleton().getFocusingShadowMap(light->getType()); 123 161 if(light->getType() == Light::LT_DIRECTIONAL) 124 162 { … … 129 167 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 130 168 131 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();132 Vector3 lightdir = light->getD irection();169 Vector3 lightpos = light->getDerivedPosition(); 170 Vector3 lightdir = light->getDerivedDirection(); 133 171 lightdir.normalise(); 134 172 … … 234 272 frun->setCameraMatrices(viewcam->getViewMatrix(), viewcam->getProjectionMatrix()); 235 273 236 Vector3 lightpos = light->get ParentSceneNode()->getWorldPosition();237 Vector3 lightdir = light->getD irection();274 Vector3 lightpos = light->getDerivedPosition(); 275 Vector3 lightdir = light->getDerivedDirection(); 238 276 lightdir.normalise(); 239 277 Radian lightangle = light->getSpotlightOuterAngle(); … … 359 397 else//point light 360 398 { 361 /* Vector3 pos = light->getParentNode()->getWorldPosition(); 362 Vector3 dir = -pos; 363 depthMapCamera->setDirection( dir ); 364 depthMapCamera->setPosition(pos); 365 depthMapCamera->setProjectionType(PT_PERSPECTIVE); 366 depthMapCamera->setFOVy(Radian(Degree(140))); 367 depthMapCamera->setNearClipDistance(1); 368 // depthMapCamera->setFarClipDistance(200); 369 370 //OGRE_EXCEPT(0, "NOT implemented for Pointlight", "OgreDepthShadowMapRenderingRun::refreshLight"); 371 */ 372 /*Vector3 pos = light->getParentNode()->getWorldPosition(); 373 Vector3 dir = -pos; 374 depthMapCamera->setDirection( dir ); 375 depthMapCamera->setPosition(pos); 376 depthMapCamera->setProjectionType(PT_ORTHOGRAPHIC); 377 depthMapCamera->*/ 378 399 lightFarPlane = light->getAttenuationRange(); 400 //no other adjustment needed 379 401 } 380 402 } … … 383 405 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewMatrix() 384 406 { 385 return depthMapCamera->getViewMatrix(); 407 Camera* cam = depthMapCamera; 408 if(light->getType() == Light::LT_POINT) 409 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 410 411 return cam->getViewMatrix(); 386 412 } 387 413 388 414 Matrix4 OgreDepthShadowMapRenderingRun::getLightViewProjMatrix() 389 415 { 390 return depthMapCamera->getProjectionMatrixWithRSDepth() * depthMapCamera->getViewMatrix(); 416 Camera* cam = depthMapCamera; 417 if(light->getType() == Light::LT_POINT) 418 cam = depthMapTexture->getBuffer(4, 0).getPointer()->getRenderTarget()->getViewport(0)->getCamera(); 419 420 return cam->getProjectionMatrixWithRSDepth() * cam->getViewMatrix(); 391 421 } 392 422 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgreLightVolumeRenderingRun.cpp
r2321 r2333 238 238 else 239 239 { 240 Vector3 pos = light->get ParentSceneNode()->getPosition();240 Vector3 pos = light->getDerivedPosition(); 241 241 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_LIGHTVOLUME_MAP) - pos; 242 242 dir.normalise(); -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePMWeightComputeRenderingRun.cpp
r2321 r2333 4 4 #include "OgreDepthShadowMapRenderingRun.h" 5 5 6 Texture* OgrePMWeightComputeRenderingRun::weightTexture = 0; 7 Texture* OgrePMWeightComputeRenderingRun::allWeightsTexture = 0; 8 6 9 OgrePMWeightComputeRenderingRun::OgrePMWeightComputeRenderingRun(String name, String LightName) 7 10 : OgreRenderingRun(1, 1) … … 19 22 void OgrePMWeightComputeRenderingRun::createWeightMap() 20 23 { 21 22 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 23 int width = entryPointCnt / 4096; 24 int height = 4096; 25 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 26 "default", 27 TEX_TYPE_2D, 28 width, 29 height, 30 0, 31 0, 32 PF_FLOAT32_R, 33 TU_RENDERTARGET); 34 allWeightsTexture = texPtr.getPointer(); 35 //add viewport to rendertarget 36 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 37 RenderTarget* rt = hpb->getRenderTarget(); 38 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 39 Viewport* v = rt->addViewport(wc); 40 v->setOverlaysEnabled(false); 41 rt->setAutoUpdated(false); 42 43 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 44 width = clustercount; 45 height = 1; 46 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 47 "default", 48 TEX_TYPE_2D, 49 width, 50 height, 51 0, 52 0, 53 PF_FLOAT32_R, 54 TU_RENDERTARGET); 55 weightTexture = texPtr.getPointer(); 56 //add viewport to rendertarget 57 hpb = (weightTexture->getBuffer()).getPointer(); 58 rt = hpb->getRenderTarget(); 59 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 60 v = rt->addViewport(wc); 61 v->setOverlaysEnabled(false); 62 rt->setAutoUpdated(false); 24 if(allWeightsTexture == 0) 25 { 26 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 27 int width = entryPointCnt / 4096; 28 int height = 4096; 29 TexturePtr texPtr = Ogre::TextureManager::getSingleton().createManual(name + "_ALL", 30 "default", 31 TEX_TYPE_2D, 32 width, 33 height, 34 0, 35 0, 36 PF_FLOAT16_RGBA, 37 TU_RENDERTARGET); 38 allWeightsTexture = texPtr.getPointer(); 39 //add viewport to rendertarget 40 HardwarePixelBuffer* hpb = (allWeightsTexture->getBuffer()).getPointer(); 41 RenderTarget* rt = hpb->getRenderTarget(); 42 Camera* wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_ALL_CAMERA"); 43 Viewport* v = rt->addViewport(wc); 44 v->setBackgroundColour(ColourValue::Black); 45 v->setClearEveryFrame(false); 46 v->setOverlaysEnabled(false); 47 rt->setAutoUpdated(false); 48 49 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 50 width = clustercount; 51 height = 1; 52 texPtr = Ogre::TextureManager::getSingleton().createManual(name, 53 "default", 54 TEX_TYPE_2D, 55 width, 56 height, 57 0, 58 0, 59 PF_FLOAT16_RGBA, 60 TU_RENDERTARGET); 61 weightTexture = texPtr.getPointer(); 62 //add viewport to rendertarget 63 hpb = (weightTexture->getBuffer()).getPointer(); 64 rt = hpb->getRenderTarget(); 65 wc = Root::getSingleton()._getCurrentSceneManager()->createCamera(name + "_CAMERA"); 66 v = rt->addViewport(wc); 67 v->setOverlaysEnabled(false); 68 rt->setAutoUpdated(false); 69 } 63 70 } 64 71 … … 83 90 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 84 91 85 Vector3 lightPos = light->get Position();86 Vector3 lightDir = light->getD irection();87 //Radian lightAngle = light->getSpotlightOuterAngle();92 Vector3 lightPos = light->getDerivedPosition(); 93 Vector3 lightDir = light->getDerivedDirection(); 94 Radian lightAngle = light->getSpotlightOuterAngle(); 88 95 89 96 Fparams->setNamedConstant("nRadionColumns", col); … … 91 98 Fparams->setNamedConstant("lightDir", lightDir); 92 99 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 100 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 93 101 Fparams->setNamedConstant("lightViewProj", SMrun->getLightViewProjMatrix()); 94 102 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 103 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 104 light->getAttenuationConstant(), 105 light->getAttenuationLinear(), 106 light->getAttenuationQuadric())); 107 Fparams->setNamedConstant("lightAngleCos", Math::Cos(lightAngle.valueRadians()/2.0)); 108 Fparams->setNamedConstant("spotLightFalloff", light->getSpotlightFalloff()); 95 109 96 110 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( … … 100 114 101 115 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 102 renderFullscreenQuad(mat->getName(), rt); 116 if(frameNum != rt->getLastFrameNumber()) 117 rt->getViewport(0)->setClearEveryFrame(true); 118 else 119 rt->getViewport(0)->setClearEveryFrame(false); 120 121 renderFullscreenQuad(mat->getName(), rt); 122 103 123 104 124 // rt->writeContentsToFile("allweights.bmp"); 105 125 // rt->writeContentsToFile("allweights.dds"); 106 107 /* float* allweights = new float[entryPointCnt / 4096 * 4096]; 108 PixelBox lockBox(entryPointCnt / 4096, 4096, 1, PF_FLOAT32_R, allweights); 109 allWeightsTexture->getBuffer()->blitToMemory(lockBox); 110 111 ///////////////////DEBUG 112 static BillboardSet* entryPointBBSet = 0; 113 if(entryPointBBSet == 0) 114 { 115 SceneManager* sm = Root::getSingleton()._getCurrentSceneManager(); 116 entryPointBBSet = sm->createBillboardSet("PATHMAP_ENTRYPOINTS", entryPointCnt); 117 entryPointBBSet->setBillboardType(BBT_POINT); 118 entryPointBBSet->setBillboardsInWorldSpace(true); 119 entryPointBBSet->setPointRenderingEnabled(true); 120 for(unsigned int i = 0; i < entryPointCnt; i++) 121 { 122 PathMapEntryPoint EP = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().at(i); 123 Vector3 billboardPosition = EP.position; 124 125 float uCoord = allweights[i]; 126 float vCoord = 0; 127 //float uCoord = ((float) (i % col) + 0.5f) / (float) col; 128 //float vCoord = ((float)(i / col) + 0.5f) / 4096.0f; 129 entryPointBBSet->createBillboard(billboardPosition, ColourValue(uCoord, vCoord, 0, 0)); 130 } 131 entryPointBBSet->setMaterialName("GTP/PM/EPBillboards"); 132 MaterialPtr mater = MaterialManager::getSingleton().getByName("GTP/PM/EPBillboards"); 133 mater->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(allWeightsTexture->getName()); 134 sm->getRootSceneNode()->createChildSceneNode()->attachObject(entryPointBBSet); 135 } 136 137 delete[] allweights;*/ 138 139 ///////////////// 126 140 127 } 141 else 128 else if(light->getType() == Light::LT_POINT) 142 129 { 143 ///not implemented 130 OgreIlluminationManager::getSingleton().createPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP); 131 OgreIlluminationManager::getSingleton().updatePerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP, frameNum); 132 OgreDepthShadowMapRenderingRun* SMrun = (OgreDepthShadowMapRenderingRun*) OgreIlluminationManager::getSingleton() 133 .getPerLightRun(light->getName(), ILLUMRUN_DEPTH_SHADOWMAP)->asOgreRenderingRun(); 134 135 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_ComputeWeights_Point"); 136 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); 137 138 Vector3 lightPos = light->getDerivedPosition(); 139 140 Fparams->setNamedConstant("nRadionColumns", col); 141 Fparams->setNamedConstant("lightPos", lightPos); 142 Fparams->setNamedConstant("lightPower", light->getPowerScale()); 143 Fparams->setNamedConstant("lightColor", light->getDiffuseColour()); 144 Fparams->setNamedConstant("lightFarPlane", SMrun->getLightFarPlane()); 145 Fparams->setNamedConstant("lightAttenuation", Vector4(light->getAttenuationRange(), 146 light->getAttenuationConstant(), 147 light->getAttenuationLinear(), 148 light->getAttenuationQuadric())); 149 150 mat->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName( 151 PMEPrun->getEntryPointTextureName()); 152 mat->getTechnique(0)->getPass(0)->getTextureUnitState(1)->setTextureName( 153 SMrun->getDepthMapTextureName()); 154 155 RenderTarget* rt = allWeightsTexture->getBuffer().getPointer()->getRenderTarget(); 156 if(frameNum != rt->getLastFrameNumber()) 157 rt->getViewport(0)->setClearEveryFrame(true); 158 else 159 rt->getViewport(0)->setClearEveryFrame(false); 160 161 renderFullscreenQuad(mat->getName(), rt); 162 144 163 } 145 164 165 } 166 167 void OgrePMWeightComputeRenderingRun::sumWeights(unsigned long frameNum) 168 { 169 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget(); 170 if(frameNum == rt->getLastFrameNumber())return; 171 172 unsigned int entryPointCnt = OgreIlluminationManager::getSingleton().getPathMapEntryPoints().size(); 173 int col = entryPointCnt / 4096; 146 174 unsigned int clustercount = OgreIlluminationManager::getSingleton().getPathMapClusterLengthsSize(); 147 175 OgrePMEntryPointMapRenderingRun* PMEPrun = (OgrePMEntryPointMapRenderingRun*) 176 OgreIlluminationManager::getSingleton().getGlobalRun(ILLUMRUN_PM_ENTRYPOINTMAP)->asOgreRenderingRun(); 177 148 178 MaterialPtr mat = MaterialManager::getSingleton().getByName("GTP/PathMap_SumWeights"); 149 179 GpuProgramParameters* Fparams = mat->getTechnique(0)->getPass(0)->getFragmentProgramParameters().getPointer(); … … 157 187 allWeightsTexture->getName()); 158 188 159 RenderTarget* rt = weightTexture->getBuffer().getPointer()->getRenderTarget();160 189 renderFullscreenQuad(mat->getName(), rt); 161 162 //rt->writeContentsToFile("weights.bmp");163 //rt->writeContentsToFile("weights.dds");164 /*165 float* weights = new float[clustercount];166 PixelBox lockBox(clustercount, 1, 1, PF_FLOAT32_R, weights);167 weightTexture->getBuffer()->blitToMemory(lockBox);168 169 delete[] weights;*/170 190 } 171 191 -
GTP/trunk/Lib/Illum/IllumModule/OgreIllumModule/src/RenderingRuns/OgrePhotonMapRenderingRun.cpp
r2321 r2333 100 100 if(light->getType() == Light::LT_DIRECTIONAL) 101 101 { 102 Vector3 dir = light->getD irection();102 Vector3 dir = light->getDerivedDirection(); 103 103 photonMapCamera->setDirection( dir ); 104 104 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius(); … … 113 113 else 114 114 { 115 Vector3 pos = light->get ParentSceneNode()->getPosition();115 Vector3 pos = light->getDerivedPosition(); 116 116 Vector3 dir = sharedRuns->getRootPosition(ILLUMRUN_PHOTONMAP) - pos; 117 117 Real r = sharedRuns->getRootBoundingSphere(ILLUMRUN_PHOTONMAP).getRadius();
Note: See TracChangeset
for help on using the changeset viewer.