/*! \param storm Storm3D \param shadowQuality shadow quality */ void Storm3D_FakeSpotlight::createBuffers(Storm3D &storm, int shadowQuality) { if(BUFFER_WIDTH <= 0 || BUFFER_HEIGHT <= 0) return; bool status = renderTargets.createAll(storm, shadowQuality); while(!status && shadowQuality >= 0) { IStorm3D_Logger *logger = storm.getLogger(); if(logger) logger->warning("Failed creating fakelight's shadow rendertargets - trying again using lower resolution"); shadowQuality -= 50; querySizes(storm, shadowQuality); status = renderTargets.createAll(storm, shadowQuality); } IStorm3D_Logger *logger = storm.getLogger(); if(logger && !renderTargets.targets[0]->hasInitialized()) logger->warning("Failed creating fakelight's shadow rendertargets - feature disabled!"); Storm3D_FakeSpotlight::Data::indexBuffer = new frozenbyte::storm::IndexBuffer(); { Storm3D_FakeSpotlight::Data::indexBuffer->create(4, false); WORD *pointer = Storm3D_FakeSpotlight::Data::indexBuffer->lock(); *pointer++ = 4; *pointer++ = 0; *pointer++ = 1; *pointer++ = 2; *pointer++ = 0; *pointer++ = 4; *pointer++ = 4; *pointer++ = 3; *pointer++ = 2; *pointer++ = 3; *pointer++ = 4; *pointer++ = 1; Storm3D_FakeSpotlight::Data::indexBuffer->unlock(); } Storm3D_FakeSpotlight::Data::shadowVertexShader = new frozenbyte::storm::VertexShader(); Storm3D_FakeSpotlight::Data::shadowVertexShader->createFakePlaneShadowShader(); Storm3D_FakeSpotlight::Data::depthPixelShader = new frozenbyte::storm::PixelShader(); Storm3D_FakeSpotlight::Data::depthPixelShader->createFakeDepthPixelShader(); Storm3D_FakeSpotlight::Data::shadowPixelShader = new frozenbyte::storm::PixelShader(); Storm3D_FakeSpotlight::Data::shadowPixelShader->createFakeShadowPixelShader(); }
void init(Storm3D &storm) { if (!effect.source1.texture.texture.empty()) { Storm3D_Texture *t1 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.source1.texture.texture.c_str())); if(t1) { texture1.reset(t1, std::mem_fun(&IStorm3D_Texture::Release)); texture1->setAutoRelease(false); } } if (!effect.source2.texture.texture.empty()) { Storm3D_Texture *t2 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.source2.texture.texture.c_str())); if(t2) { texture2.reset(t2, std::mem_fun(&IStorm3D_Texture::Release)); texture2->setAutoRelease(false); } } if (!effect.source1.offset.texture.empty()) { Storm3D_Texture *t3 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.source1.offset.texture.c_str())); if(t3) { offset1.reset(t3, std::mem_fun(&IStorm3D_Texture::Release)); offset1->setAutoRelease(false); } } if (!effect.source2.offset.texture.empty()) { Storm3D_Texture *t4 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.source2.offset.texture.c_str())); if(t4) { offset2.reset(t4, std::mem_fun(&IStorm3D_Texture::Release)); offset2->setAutoRelease(false); } } if (!effect.distortion1.offset.texture.empty()) { Storm3D_Texture *t5 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.distortion1.offset.texture.c_str())); if(t5) { distortion1.reset(t5, std::mem_fun(&IStorm3D_Texture::Release)); distortion1->setAutoRelease(false); } } if (!effect.distortion2.offset.texture.empty()) { Storm3D_Texture *t6 = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.distortion2.offset.texture.c_str())); if(t6) { distortion2.reset(t6, std::mem_fun(&IStorm3D_Texture::Release)); distortion2->setAutoRelease(false); } } if (!effect.fallback.empty()) { Storm3D_Texture *f = static_cast<Storm3D_Texture *> (storm.CreateNewTexture(effect.fallback.c_str())); if(f) { fallback.reset(f, std::mem_fun(&IStorm3D_Texture::Release)); fallback->setAutoRelease(false); } } else { storm.getLogger()->warning("ProceduralEffect::init - effect has no fallback texture."); } }
void Storm3D_Spotlight::createShadowBuffers(Storm3D &storm, IDirect3D9 &d3d, IDirect3DDevice9 &device, bool ps14, bool ps20, int shadowQuality) { bool status = staticBuffers.createAll(storm, d3d, device, ps14, shadowQuality); while(!status && shadowQuality > 0) { IStorm3D_Logger *logger = storm.getLogger(); if(logger) logger->warning("Failed creating light's shadow depth rendertargets - trying again using lower resolution"); shadowQuality -= 50; querySizes(storm, ps14, shadowQuality); status = staticBuffers.createAll(storm, d3d, device, ps14, shadowQuality); } IStorm3D_Logger *logger = storm.getLogger(); if(logger && !staticBuffers.buffers[0]->hasInitialized()) logger->warning("Failed creating light's shadow depth rendertargets - shadows disabled!"); if(ps14) { if(type == Storm3D_Spotlight::AtiFloatBuffer) { Storm3D_SpotlightData::atiFloatDepthPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiFloatDepthPixelShader->createAtiFloatDepthPixelShader(); Storm3D_SpotlightData::atiFloatShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiFloatShadowPixelShader->createAtiFloatShadowPixelShader(); Storm3D_SpotlightData::atiFloatShadowTerrainPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiFloatShadowTerrainPixelShader->createAtiFloatShadowTerrainPixelShader(); Storm3D_SpotlightData::atiFloatNoShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiFloatNoShadowPixelShader->createAtiFloatNoShadowPixelShader(); Storm3D_SpotlightData::atiFloatNoShadowTerrainPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiFloatNoShadowTerrainPixelShader->createAtiFloatNoShadowTerrainPixelShader(); } Storm3D_SpotlightData::atiDepthPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiDepthPixelShader->createAtiDepthPixelShader(); Storm3D_SpotlightData::atiShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiShadowPixelShader->createAtiShadowPixelShader(); Storm3D_SpotlightData::atiShadowSolidPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiShadowSolidPixelShader->createAtiShadowSolidPixelShader(); Storm3D_SpotlightData::atiShadowTerrainPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiShadowTerrainPixelShader->createAtiShadowTerrainPixelShader(); Storm3D_SpotlightData::atiNoShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiNoShadowPixelShader->createAtiNoShadowPixelShader(); Storm3D_SpotlightData::atiNoShadowTerrainPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::atiNoShadowTerrainPixelShader->createAtiNoShadowTerrainPixelShader(); Storm3D_SpotlightData::coneAtiPixelShader_Texture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneAtiPixelShader_Texture->createAtiLightConeShader_Texture(); Storm3D_SpotlightData::coneAtiPixelShader_NoTexture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneAtiPixelShader_NoTexture->createAtiLightConeShader_NoTexture(); if(type == Storm3D_Spotlight::AtiFloatBuffer) { Storm3D_SpotlightData::coneAtiFloatPixelShader_Texture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneAtiFloatPixelShader_Texture->createAtiFloatLightConeShader_Texture(); Storm3D_SpotlightData::coneAtiFloatPixelShader_NoTexture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneAtiFloatPixelShader_NoTexture->createAtiFloatLightConeShader_NoTexture(); } } if(type == Storm3D_Spotlight::DepthBuffer) { if(ps20) { Storm3D_SpotlightData::nvSmoothShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::nvSmoothShadowPixelShader->createNvSmoothShadowShader(); } Storm3D_SpotlightData::nvShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::nvShadowPixelShader->createNvShadowShader(); Storm3D_SpotlightData::nvNoShadowPixelShader = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::nvNoShadowPixelShader->createNvNoShadowShader(); Storm3D_SpotlightData::coneNvPixelShader_Texture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneNvPixelShader_Texture->createNvConeShader_Texture(); Storm3D_SpotlightData::coneNvPixelShader_NoTexture = new frozenbyte::storm::PixelShader(device); Storm3D_SpotlightData::coneNvPixelShader_NoTexture->createNvConeShader_NoTexture(); } Storm3D_SpotlightData::coneStencilVertexShader = new frozenbyte::storm::VertexShader(device); Storm3D_SpotlightData::coneStencilVertexShader->createConeStencilShader(); }