A question just for a check. Is there a possibility to rescript (or whatever is the right term) Point Light in a way it could cast dynamic shadows similar to Spot Light? I am not sure if it's possible. If this feature (dynamic shadows) is hard-coded in some of engine .dll's surely it would be nearly impossible to make anything or extremely hard because it would require reassembling.
But at the same time there a shader file
...core\shaders\deferred_light_frag.glsl and maybe it's possible to make new strings for some kinda new type of light Point Shadow Light.
Here's a copypast of some strings from
deferred_light_frag.glsl shader file:
@ifdef LightType_Spot
@ifdef UseGobo || UseShadowMap
uniform mat4 a_mtxSpotViewProj;
@endif
@ifdef UseGobo
@else
uniform float afOneMinusCosHalfSpotFOV;
uniform vec3 avLightForward;
@endif
@ifdef UseShadowMap
@ifdef ShadowMapQuality_Low
@else
uniform vec2 avShadowMapOffsetMul;
@endif
@endif
//Point specfics
@else
@ifdef UseGobo
uniform mat4 a_mtxInvViewRotation;
@endif
@endif
and here's another part which I presume is code of shadows themselves:
/////////////////////////////////
// Caclulate shadow (if any)
@ifdef UseShadowMap && LightType_Spot
@ifdef UseGobo
@else
vec4 vProjectedUv = a_mtxSpotViewProj * vec4(vPos,1.0);
@endif
////////////////////////
// No Smoothing
@ifdef ShadowMapQuality_Low
fAttenuatuion *= shadow2DProj(aShadowMap, vProjectedUv).x;
///////////////////////
// Smoothing
@else
//Set up variables
float fShadowSum = 0;
float fJitterZ =0;
vec2 vScreenJitterCoord = gl_FragCoord.xy * $ShadowJitterLookupMul;
vScreenJitterCoord.y = fract(vScreenJitterCoord.y); //Make sure the coord is in 0 - 1 range
vScreenJitterCoord.y *= 1.0 / $ShadowJitterSamplesDiv2; //Access only first texture piece
////////////////
// Shader Model 3, Dynamic Branching available
@ifdef ShaderModel_4
////////////////
// Cheap pre-test
// Note1: division must occur when getting samples else gfx card gets angry.)
// Note2: It _must_ be division! doing sample * 1/8 will fail!!
for(int i=0; i<2.0; i++)
{
vec2 vJitterLookupCoord = vec2(vScreenJitterCoord.x, vScreenJitterCoord.y + fJitterZ);
vec4 vOffset = texture2D(aShadowOffsetMap, vJitterLookupCoord) *2.0-1.0;
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.xy) * avShadowMapOffsetMul ) / 4.0;
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.zw) * avShadowMapOffsetMul ) / 4.0;
fJitterZ += 1.0 / $ShadowJitterSamplesDiv2;
}
////////////////
// Check if in penumbra
if( (fShadowSum-1.0) * fShadowSum * fLDotN != 0)
{
//Multiply, so the X presamples only affect their part (X/all_samples) of samples taken.
fShadowSum *= 4.0 / $ShadowJitterSamples;
////////////////
// Fullscale filtering
for(int i=0; i<$ShadowJitterSamplesDiv2-2.0; i++)
{
vec2 vJitterLookupCoord = vec2(vScreenJitterCoord.x, vScreenJitterCoord.y + fJitterZ); //Not that coords are 0-1!
vec4 vOffset = texture2D(aShadowOffsetMap, vJitterLookupCoord) *2.0 - 1.0;
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.xy) * avShadowMapOffsetMul ) / $ShadowJitterSamples;
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.zw) * avShadowMapOffsetMul ) / $ShadowJitterSamples;
fJitterZ += 1.0 / $ShadowJitterSamplesDiv2;
}
//vDiffuse.xyz = vec3(0,0,1);
}
/*else
{
if(fShadowSum>0.5) vDiffuse.xyz = vec3(1,0,0);
else vDiffuse.xyz = vec3(0,1,0);
//fAttenuatuion *= fShadowSum;
}*/
/////////////////////
// No Dynamic Branching
@else
for(int i=0; i<$ShadowJitterSamplesDiv2; i++)
{
vec2 vJitterLookupCoord = vec2(vScreenJitterCoord.x, vScreenJitterCoord.y + fJitterZ);
vec4 vOffset = texture2D(aShadowOffsetMap, vJitterLookupCoord) *2.0 - 1.0;
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.xy) * avShadowMapOffsetMul );
fShadowSum += ShadowOffsetLookup(aShadowMap, vProjectedUv, vec2(vOffset.zw) * avShadowMapOffsetMul );
fJitterZ += 1.0 / $ShadowJitterSamplesDiv2;
}
fShadowSum /= $ShadowJitterSamples;
@endif
/////////////////////
// Add shadow sum to attenuation
fAttenuatuion *= fShadowSum;
@endif
@endif
I am not a scripter and that's why I am asking for help or just an advice. I do have some knowledge of scripts, at least I can understand what is what and what for. But... anyway if anybody can help or advice something, thanks in advance! At the same time I am sure if such an "upgrade" of HPL2 Lights is possible and could be done by someone, than it would be very useful for everybody. I mean everybody could be thankful, not just me.