@@ -205,8 +205,7 @@ class DegradedIBLShader : public TextureShader<DegradedIBLShader, 2>
205
205
class ShadowedSunLightShaderPCF : public TextureShader <ShadowedSunLightShaderPCF,
206
206
3 , float , float , float ,
207
207
float , float , float ,
208
- core::vector3df, core::vector3df,
209
- core::vector3df, core::vector3df,
208
+ float , float , float , float ,
210
209
core::vector3df, video::SColorf>
211
210
{
212
211
public:
@@ -220,7 +219,8 @@ class ShadowedSunLightShaderPCF : public TextureShader<ShadowedSunLightShaderPCF
220
219
1 , " dtex" , ST_NEAREST_FILTERED,
221
220
8 , " shadowtex" , ST_SHADOW_SAMPLER);
222
221
assignUniforms (" split0" , " split1" , " split2" , " splitmax" , " shadow_res" ,
223
- " overlap_proportion" , " box0" , " box1" , " box2" , " box3" , " sundirection" , " sun_color" );
222
+ " overlap_proportion" , " texel0" , " texel1" , " texel2" , " texel3" ,
223
+ " sundirection" , " sun_color" );
224
224
} // ShadowedSunLightShaderPCF
225
225
// ------------------------------------------------------------------------
226
226
void render (GLuint normal_depth_texture,
@@ -233,15 +233,19 @@ class ShadowedSunLightShaderPCF : public TextureShader<ShadowedSunLightShaderPCF
233
233
setTextureUnits (normal_depth_texture,
234
234
depth_stencil_texture,
235
235
shadow_framebuffer->getDepthTexture () );
236
- drawFullScreenEffect (ShadowMatrices::m_shadow_split[1 ],
237
- ShadowMatrices::m_shadow_split[2 ],
238
- ShadowMatrices::m_shadow_split[3 ],
239
- ShadowMatrices::m_shadow_split[4 ],
240
- float (UserConfigParams::m_shadows_resolution),
241
- ShadowMatrices::m_shadow_overlap_proportion,
242
- shadow_box_extents[0 ], shadow_box_extents[1 ],
243
- shadow_box_extents[2 ], shadow_box_extents[3 ],
244
- direction, col);
236
+ std::array<float , 4 > texel;
237
+ for (int i = 0 ; i < 4 ; i++)
238
+ {
239
+ texel[i] = std::max (shadow_box_extents[i].X , shadow_box_extents[i].Y );
240
+ }
241
+ drawFullScreenEffect (ShadowMatrices::m_shadow_split[1 ],
242
+ ShadowMatrices::m_shadow_split[2 ],
243
+ ShadowMatrices::m_shadow_split[3 ],
244
+ ShadowMatrices::m_shadow_split[4 ],
245
+ float (UserConfigParams::m_shadows_resolution),
246
+ ShadowMatrices::m_shadow_overlap_proportion,
247
+ texel[0 ], texel[1 ], texel[2 ], texel[3 ],
248
+ direction, col);
245
249
246
250
} // render
247
251
}; // ShadowedSunLightShaderPCF
@@ -250,8 +254,8 @@ class ShadowedSunLightShaderPCF : public TextureShader<ShadowedSunLightShaderPCF
250
254
class ShadowedSunLightShaderPCSS : public TextureShader <ShadowedSunLightShaderPCSS,
251
255
4 , float , float , float ,
252
256
float , float , float ,
253
- core::vector3df , core::vector3df ,
254
- core::vector3df , core::vector3df ,
257
+ core::vector2df , core::vector2df ,
258
+ core::vector2df , core::vector2df ,
255
259
core::vector3df, video::SColorf>
256
260
{
257
261
public:
@@ -266,7 +270,8 @@ class ShadowedSunLightShaderPCSS : public TextureShader<ShadowedSunLightShaderPC
266
270
8 , " shadowtexdepth" , ST_NEAREST_FILTERED_ARRAY2D,
267
271
16 , " shadowtex" , ST_SHADOW_SAMPLER);
268
272
assignUniforms (" split0" , " split1" , " split2" , " splitmax" , " shadow_res" ,
269
- " overlap_proportion" , " box0" , " box1" , " box2" , " box3" , " sundirection" , " sun_color" );
273
+ " overlap_proportion" , " penumbra0" , " penumbra1" , " penumbra2" , " penumbra3" ,
274
+ " sundirection" , " sun_color" );
270
275
} // ShadowedSunLightShaderPCF
271
276
// ------------------------------------------------------------------------
272
277
void render (GLuint normal_depth_texture,
@@ -280,15 +285,20 @@ class ShadowedSunLightShaderPCSS : public TextureShader<ShadowedSunLightShaderPC
280
285
depth_stencil_texture,
281
286
shadow_framebuffer->getDepthTexture (),
282
287
shadow_framebuffer->getDepthTexture () );
283
- drawFullScreenEffect (ShadowMatrices::m_shadow_split[1 ],
284
- ShadowMatrices::m_shadow_split[2 ],
285
- ShadowMatrices::m_shadow_split[3 ],
286
- ShadowMatrices::m_shadow_split[4 ],
287
- float (UserConfigParams::m_shadows_resolution),
288
- ShadowMatrices::m_shadow_overlap_proportion,
289
- shadow_box_extents[0 ], shadow_box_extents[1 ],
290
- shadow_box_extents[2 ], shadow_box_extents[3 ],
291
- direction, col);
288
+ std::array<core::vector2df, 4 > penumbra;
289
+ for (int i = 0 ; i < 4 ; i++)
290
+ {
291
+ float size = tan (core::PI64 * 0.54 / 360 .) * shadow_box_extents[i].Z ;
292
+ penumbra[i] = core::vector2df (size / shadow_box_extents[i].X , size / shadow_box_extents[i].Y );
293
+ }
294
+ drawFullScreenEffect (ShadowMatrices::m_shadow_split[1 ],
295
+ ShadowMatrices::m_shadow_split[2 ],
296
+ ShadowMatrices::m_shadow_split[3 ],
297
+ ShadowMatrices::m_shadow_split[4 ],
298
+ float (UserConfigParams::m_shadows_resolution),
299
+ ShadowMatrices::m_shadow_overlap_proportion,
300
+ penumbra[0 ], penumbra[1 ], penumbra[2 ], penumbra[3 ],
301
+ direction, col);
292
302
293
303
} // render
294
304
}; // ShadowedSunLightShaderPCSS
0 commit comments