RhodoniteTS icon indicating copy to clipboard operation
RhodoniteTS copied to clipboard

Shadow from a parallel light source is more efficient.

Open KaYaF opened this issue 4 years ago • 4 comments

This issue is senooyudai 's effort. I'm posting this on his behalf.

senooyudai suggested a shadow shader using a parallel light source.

Currently, the light source is a point light in ShadowMap shader(ShadowMapDecodeClassicShader.ts). The shader uses the length method to compute the length between the point light source and an object. The code is: https://github.com/emadurandal/RhodoniteTS/blob/5706ecfc96911831e4732cb66de1c48a6767099f/src/webgl/shaders/ShadowMapDecodeClassicShader.ts#L181 The length method is slow. If we adopt a parallel light source, we do not need to use the length method.

To change the light type from point to parallel, we need to change at least two things.

  1. Change the computation of depth in the shadow map shader like:
 float linerDepth = normalizationCoefficient * v_position_inLocal.z;
 float measureDepth = normalizationCoefficient * v_projPosition_from_light.z;
  1. Change the settings of a camera in the render pass of the depth (need to use orthographic type)

What do you think of this?

┆Issue is synchronized with this Wrike Item

KaYaF avatar Aug 03 '20 08:08 KaYaF

@KaYaF What should we do about this issue now?

emadurandal avatar Feb 19 '21 01:02 emadurandal

Discuss we need this solution and answer the question that is I wrote the last line.

In my opinion, the answer to the question is yes, but I think it is a low priority for implementation. The reason for this is that the purpose of this solution is to reduce the computational cost at the expense of accuracy, but we need to implement it to verify how much we can reduce the computational cost. So the answer is yes. However, since we are not facing a problem where we need to reduce the computation cost using this shader, it is a low priority.

If the answer is true, we should start step1. I think it would be good to allow two modes: point light and parallel light.

KaYaF avatar Feb 19 '21 02:02 KaYaF

I see. I can wait.

emadurandal avatar Feb 19 '21 07:02 emadurandal

https://github.com/actnwit/RhodoniteTS/blob/9b3a9e8c65813cb0af22597fefc7b098a49255f1/src/webgl/shaderity_shaders/DepthEncodeSingleShader/DepthEncodeSingleShader.frag#L37

I think this means parallel light.

KaYaF avatar Jun 29 '21 02:06 KaYaF