Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Rendering/Lighting/ShadowMapping/SingleShadowMap.cpp

Diff revisions: vs.
  @@ -11,7 +11,10 @@
11 11
12 12 namespace Divide {
13 13
14 - SingleShadowMap::SingleShadowMap(Light* light, Camera* shadowCamera) : ShadowMap(light, shadowCamera, SHADOW_TYPE_Single)
14 + SingleShadowMap::SingleShadowMap(Light* light,
15 + Camera* shadowCamera) : ShadowMap(light,
16 + shadowCamera,
17 + SHADOW_TYPE_Single)
15 18 {
16 19 PRINT_FN(Locale::get("LIGHT_CREATE_SHADOW_FB"), light->getGUID(), "Single Shadow Map");
17 20 ResourceDescriptor shadowPreviewShader("fbPreview.LinearDepth");
  @@ -20,10 +23,10 @@
20 23 SamplerDescriptor depthMapSampler;
21 24 depthMapSampler.setWrapMode(TEXTURE_CLAMP_TO_EDGE);
22 25 depthMapSampler.toggleMipMaps(false);
23 - depthMapSampler._useRefCompare = true; //< Use compare function
24 - depthMapSampler._cmpFunc = CMP_FUNC_LEQUAL; //< Use less or equal
25 -
26 - TextureDescriptor depthMapDescriptor(TEXTURE_2D, DEPTH_COMPONENT, UNSIGNED_INT); ///Default filters, LINEAR is OK for this
26 + depthMapSampler._useRefCompare = true;
27 + depthMapSampler._cmpFunc = CMP_FUNC_LEQUAL;
28 + // Default filters, LINEAR is OK for this
29 + TextureDescriptor depthMapDescriptor(TEXTURE_2D, DEPTH_COMPONENT, UNSIGNED_INT);
27 30
28 31 depthMapDescriptor.setSampler(depthMapSampler);
29 32 _depthMap = GFX_DEVICE.newFB();
  @@ -36,34 +39,38 @@
36 39 RemoveResource(_previewDepthMapShader);
37 40 }
38 41
39 - void SingleShadowMap::init(ShadowMapInfo* const smi){
42 + void SingleShadowMap::init(ShadowMapInfo* const smi) {
40 43 resolution(smi->resolution(), _light->shadowMapResolutionFactor());
41 44 _init = true;
42 45 }
43 46
44 - void SingleShadowMap::resolution(U16 resolution, U8 resolutionFactor){
47 + void SingleShadowMap::resolution(U16 resolution, U8 resolutionFactor) {
45 48 U16 resolutionTemp = resolution * resolutionFactor;
46 - if (resolutionTemp != _resolution){
49 + if (resolutionTemp != _resolution) {
47 50 _resolution = resolutionTemp;
48 51 //Initialize the FB's with a variable resolution
49 52 PRINT_FN(Locale::get("LIGHT_INIT_SHADOW_FB"), _light->getGUID());
50 53 _depthMap->Create(_resolution, _resolution);
51 54 }
55 +
52 56 ShadowMap::resolution(resolution, resolutionFactor);
53 57 }
54 58
55 - void SingleShadowMap::render(SceneRenderState& renderState, const DELEGATE_CBK<>& sceneRenderFunction){
59 + void SingleShadowMap::render(SceneRenderState& renderState,
60 + const DELEGATE_CBK<>& sceneRenderFunction) {
56 61 ///Only if we have a valid callback;
57 - if(!sceneRenderFunction) {
62 + if (!sceneRenderFunction) {
58 63 ERROR_FN(Locale::get("ERROR_LIGHT_INVALID_SHADOW_CALLBACK"), _light->getGUID());
59 64 return;
60 65 }
66 +
61 67 renderState.getCameraMgr().pushActiveCamera(_shadowCamera, false);
62 68 renderInternal(renderState, sceneRenderFunction);
63 69 renderState.getCameraMgr().popActiveCamera(false);
64 70 }
65 71
66 - void SingleShadowMap::renderInternal(const SceneRenderState& renderState, const DELEGATE_CBK<>& sceneRenderFunction) {
72 + void SingleShadowMap::renderInternal(const SceneRenderState& renderState,
73 + const DELEGATE_CBK<>& sceneRenderFunction) {
67 74 _shadowCamera->lookAt(_light->getPosition(), _light->getPosition() * _light->getDirection());
68 75 _shadowCamera->setProjection(1.0f, 90.0f, vec2<F32>(1.0, _light->getRange()));
69 76 _shadowCamera->renderLookAt();
  @@ -76,7 +83,7 @@
76 83 LightManager::getInstance().registerShadowPass();
77 84 }
78 85
79 - void SingleShadowMap::previewShadowMaps(){
86 + void SingleShadowMap::previewShadowMaps() {
80 87 _depthMap->Bind(ShaderProgram::TEXTURE_UNIT0);
81 88 GFX_DEVICE.drawPoints(1, GFX_DEVICE.getDefaultStateBlock(true), _previewDepthMapShader);
82 89 }