Deferred Engine Playground - download

is the spotlight work? how can i make it work?

I’ve Reenabled directional lights (sun lights) but not yet spotlights. I think the old spotlight Shader files are still there though in “unused”.

The idea is the same as pointloghts, but you also pass a light direction. Then when computing the light for each pixel you compare the direction from light to pixel with the spotlight direction (with a dot) and multiply by this value

nice…look forward for ur spotligting implementation.

@kosmonautgames that environment is it your own creation or a generic environment available somewhere? I found a code project page with it I think… just curious :slight_smile:

I think I provided a link to the meshes of the scene in the download. They are generic and were made for graphics research.

Look for “Crytek Sponza”

1 Like

I had a look at your code, and there is a thing I don’t catch:
sometimes you use a linear depth:
in DrawBasic_VSOut DrawBasic_VertexShader(DrawBasic_VSIn input)
Output.Depth = mul(input.Position, WorldView).z / -FarClip;

and sometimes not:
infloat4 DrawBasicVSM_PixelShader(DrawBasic_VSOut input) : SV_TARGET
float depth = input.Depth.x / input.Depth.y;

How can it be possible to compare the 2 values to make shadows ?

i don’t do linear depth for shadows (yet)

Hum ok so linear is only used for deferred and lighting and back to z/w for shadows and the rest of post processes
I thought you used linear depth for ssao too (which i had to do) and the rest of the graphics pipeline

everything uses linear viewspace except for shadow mapping ( so yes SSAO uses linear). I actually changed that today, so it uses linear, too (but that’s a bit more expensive :frowning: ). Not everything is integrated yet, so no update for the shadows are pushed ot the server right now

I actually switched to linear mainly for SSAO. Though I will admit my implementation is not great.

I have other stuff to work on right now though.

Ok :slight_smile: I think the thing I missed was in

float3 lightVectorWS = -mul(float4(lightVector, 0), InverseView).xyz;
float depthInLS = getDepthInLS(float4(input.PositionVS, 1), lightVectorWS);
float shadowVSM = chebyshevUpperBound(depthInLS, lightVectorWS);

I was wondering how I could make my shadows work with my non linear depth and yours cold work too with the same maths.

Another question:
To sample from the cubemap, isn’t it enough to use texCUBE with the light direction vector (your lightVectorWS), instead of trying to find the transformation with getDepthInLS (LS= LightSpace right ?) Some tutorials says tit is not necessary to normalize the lightvector, some say to… I’m lost, maybe my shadows are working by chance… :disappointed_relieved:

i have no idea, i haven’t looked at proper implementations, just what I thought of myself.

I think the only things that are “stolen” from tutorials are softPCF algorithms, but I’m working on some of my own right now as I am trying to optimize bias

I think for sampling with texCube, you don’t need a normalized vector. But I’m not sure, since it has been a while since experimenting with it. A normalization though should not change anything regarding the sampling. For the diffuse and specular calculation I think a normalization makes sense.

how to rendering partial transparent obj and sort properly? bcoz i try when forward render with the deferredComposite, my obj is always render overlay on infornt of the object.

Reconstruct depth before (on the rt that you draw to)

thanks, but light pre-pass demo render twice 2 for opaqe material. G-buffer = > reconstruct shading , it actually consume alot of fps.

If you use prepass you can reconstruct depth anyways for the second pass and use Depthcomparison Equal, if you have high enough precision.

But reconstructing depth alone shouldn’t be super expensive, it’s cheaper in the long run than to compare each pixel against the depth map.

Anyways this thread is not about random questions, make a new thread for that

Sry for that, i tot this thread is related to deferred rendering and somemore your r more expert on this area.

Hi @kosmonautgames, Is it possible to add HDR Rendering and SoftShadow implementation into this Engine.

If it is then please let me know where to begin?


HDR rendering is more or less in, with the latest commit there is a tonemapping operation in the postprocess.fx

Soft shadows are in for directional lights as far as I’m aware, but they have some artifacts due to the way monogame breaks the texture samplers, that’s why I didn’t feel encouraged to make them available for point lights, too.

If you want point light soft shadows you would have to change up the deferredpointlight.fx

here is the article to improve the point light soft shadow, hope it help :slight_smile:!Advanced-Lighting/Shadows/Point-Shadows