shadow texture per pixel

What it says on the tin: a place to discuss proposed new features.
User avatar
jordiperezarti
Halfling
Posts: 55
Joined: Sun Sep 01, 2024 7:50 pm

shadow texture per pixel

Post by jordiperezarti »

I am not sure of my suggestion, tell me if i am wrong:

when adding shadows from depth texture pass, the second pass is project the depth texture from light viewport matrix to the framebuffer interpolating with the camera viewport matrix.
But shall have sence when writing the shader per pixel program at the beauty pass, to add there the shadow, just testing from the depth texrue and setting the shadow color on the same shader just using the light viewport matrix interpolated with the camera viewport matrix, but do it in situ?
this would provide very detailed shadow per pixel accuracy and avoid on projection step where shadow resolution was needed.

rpgplayerrobin
Bugbear
Posts: 807
Joined: Wed Mar 18, 2009 3:03 am
x 468

Re: shadow texture per pixel

Post by rpgplayerrobin »

As I understand it, you have a scene that renders first shadow textures, then a "beauty" pass and then a third "projection step" pass?

The first thing needed would be just to render to the shadow texture itself.

The first pass would be the "beauty" pass, where I guess all light calculation and other stuff is happening.
The second pass would be the "depth texture pass" where you do the shadowing? There is not usually a separate "projection step" as you mention, the shadow test is done directly inside the lighting calculation (the "beauty" pass).

Usually you just render to the shadow textures and then just add them to the "beauty" pass, so that there is only one render actually happening for the visible scene of normal objects.

Does this answer your question? I am not really sure how your current setup is right now to be able to answer this correctly.

User avatar
jordiperezarti
Halfling
Posts: 55
Joined: Sun Sep 01, 2024 7:50 pm

Re: shadow texture per pixel

Post by jordiperezarti »

Code: Select all

void main()
{
  vec4 positionFromLightPovInTexture = positionFromLightPov * 0.5 + 0.5;
  float litPercent = positionFromLightPovInTexture.z < texture(shadowMap, positionFromLightPovInTexture.xy).r ? 1.0 : ambientLight;
  fragColor = vColor * litPercent;
}

This piece of code is what i had in mind.
i was imagining this step was done by projecting the depth texture from a plane quad.

thanks for the clarification.