Subversion Repository Public Repository

Divide-Framework

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

Diff Revisions 167 vs 168 for /trunk/Source Code/Rendering/Lighting/ShadowMapping/SingleShadowMap.cpp

Diff revisions: vs.
  @@ -24,15 +24,20 @@
24 24 _previewDepthMapShader = CreateResource<ShaderProgram>(shadowPreviewShader);
25 25 _renderQuad->setCustomShader(_previewDepthMapShader);
26 26 _renderQuad->renderInstance()->draw2D(true);
27 +
28 + SamplerDescriptor depthMapSampler;
29 + depthMapSampler.setWrapMode(TEXTURE_CLAMP_TO_EDGE);
30 + depthMapSampler.toggleMipMaps(false);
31 + depthMapSampler._useRefCompare = true; //< Use compare function
32 + depthMapSampler._cmpFunc = CMP_FUNC_LEQUAL; //< Use less or equal
33 + depthMapSampler._depthCompareMode = LUMINANCE;
34 +
27 35 TextureDescriptor depthMapDescriptor(TEXTURE_2D,
28 36 DEPTH_COMPONENT,
29 37 DEPTH_COMPONENT,
30 38 UNSIGNED_BYTE); ///Default filters, LINEAR is OK for this
31 - depthMapDescriptor.setWrapMode(TEXTURE_CLAMP_TO_EDGE,TEXTURE_CLAMP_TO_EDGE);
32 - depthMapDescriptor._useRefCompare = true; //< Use compare function
33 - depthMapDescriptor._cmpFunc = CMP_FUNC_LEQUAL; //< Use less or equal
34 - depthMapDescriptor._depthCompareMode = LUMINANCE;
35 39
40 + depthMapDescriptor.setSampler(depthMapSampler);
36 41 _depthMap = GFX_DEVICE.newFBO(FBO_2D_DEPTH);
37 42 _depthMap->AddAttachment(depthMapDescriptor, TextureDescriptor::Depth);
38 43 _depthMap->toggleColorWrites(false);
  @@ -44,8 +49,8 @@
44 49 RemoveResource(_renderQuad);
45 50 }
46 51
47 - void SingleShadowMap::resolution(U16 resolution,SceneRenderState* sceneRenderState){
48 - U8 resolutionFactorTemp = sceneRenderState->shadowMapResolutionFactor();
52 + void SingleShadowMap::resolution(U16 resolution, const SceneRenderState& renderState){
53 + U8 resolutionFactorTemp = renderState.shadowMapResolutionFactor();
49 54 CLAMP<U8>(resolutionFactorTemp, 1, 4);
50 55 U16 maxResolutionTemp = resolution;
51 56 if(resolutionFactorTemp != _resolutionFactor || _maxResolution != maxResolutionTemp){
  @@ -56,11 +61,11 @@
56 61 U16 shadowMapDimension = _maxResolution/_resolutionFactor;
57 62 _depthMap->Create(shadowMapDimension,shadowMapDimension);
58 63 }
59 - ShadowMap::resolution(resolution,sceneRenderState);
64 + ShadowMap::resolution(resolution, renderState);
60 65 _renderQuad->setDimensions(vec4<F32>(0,0,_depthMap->getWidth(),_depthMap->getHeight()));
61 66 }
62 67
63 - void SingleShadowMap::render(SceneRenderState* renderState, boost::function0<void> sceneRenderFunction){
68 + void SingleShadowMap::render(const SceneRenderState& renderState, boost::function0<void> sceneRenderFunction){
64 69 ///Only if we have a valid callback;
65 70 if(sceneRenderFunction.empty()) {
66 71 ERROR_FN(Locale::get("ERROR_LIGHT_INVALID_SHADOW_CALLBACK"), _light->getId());
  @@ -71,10 +76,10 @@
71 76 renderInternal(renderState);
72 77 }
73 78
74 - void SingleShadowMap::renderInternal(SceneRenderState* renderState) const {
79 + void SingleShadowMap::renderInternal(const SceneRenderState& renderState) const {
75 80 GFXDevice& gfx = GFX_DEVICE;
76 81 //Get our eye view
77 - vec3<F32> eyePos = renderState->getCamera()->getEye();
82 + vec3<F32> eyePos = renderState.getCameraConst().getEye();
78 83 //For every depth map
79 84 //Lock our projection matrix so no changes will be permanent during the rest of the frame
80 85 //Lock our model view matrix so no camera transforms will be saved beyond this light's scope
  @@ -86,7 +91,7 @@
86 91 //bind the associated depth map
87 92 _depthMap->Begin();
88 93 //draw the scene
89 - GFX_DEVICE.render(_callback, GET_ACTIVE_SCENE()->renderState());
94 + GFX_DEVICE.render(_callback, renderState);
90 95 //unbind the associated depth map
91 96 _depthMap->End();
92 97
  @@ -105,7 +110,7 @@
105 110 _previewDepthMapShader->bind();
106 111 _previewDepthMapShader->UniformTexture("tex",0);
107 112 GFX_DEVICE.toggle2D(true);
108 - GFX_DEVICE.renderInViewport(vec4<I32>(0,0,256,256),
113 + GFX_DEVICE.renderInViewport(vec4<U32>(0,0,256,256),
109 114 boost::bind(&GFXDevice::renderInstance,
110 115 DELEGATE_REF(GFX_DEVICE),
111 116 DELEGATE_REF(_renderQuad->renderInstance())));