Deferred Rendering Project WT EngineMG

Ok, thank you for your help. I will leave it like that for now and investigate it later :slight_smile:

Point lights are now able to cast simple shadows :slight_smile:

Next thing I want to implement is Exponential Shadow Mapping to get softer shadows. I hope this will be easy to do…

Turned out, it is not so easy. At least for me :slight_smile:

So nothing really to show you at the moment, except some wrong shadows:


Anybody here got ESM working for PointLights?

ShadowMaps are generated like this:

    float3 light = LightPosition - worldPosition;
    float lengthLight = length(light);
    float depth = max(0.01f, lengthLight) / ESMShadowDepthPrecision;
    float expDepth = exp((ESMShadowDepthPrecision * ESMShadowFactor) * depth);

and the shadowFactor (attenuation factor, by which the point light color is multiplied by):

    float lightDepth = texCUBE(ShadowSampler, UVW).r;
    float lengthLight = length(LightPosition - Position.xyz);
    float len = max(0.01f, lengthLight) / ESMShadowDepthPrecision;
    float shadowFactor = saturate(lightDepth * exp(-(ESMShadowDepthPrecision * ESMShadowFactor) * (len - ESMShadowDepthBias)));

I don’t know, if the parameters are wrong or if I have an error in the calculation. Depending on the values for the parameters ESMShadowDepthPrecision, ESMShadowFactor and ESMShadowDepthBias I get no shadow, or no lighting or something like you see on the images above :slight_smile:

use float16 rendertargets for the shadow map (-> format single or vec2)

I’m using SurfaceFormat.Single at the moment.

Got them working! :sunglasses:

Forgot to set the LightPosition when generating the ShadowMap… :dizzy_face:

Depending on the parameters the shadows are total black or brighter:


Although the shadows work, it is not quite the result I wanted. Would it work to blur the shadow map to get softer shadows? How would I do this for a cubemap?

Here is an update showing some soft shadows, which are generated by blurring the cubemap. The images are rendered using three directional lights and one point light (casting the shadow). Because normal mapping is not working at the moment, the model is rendered only with vertex normals.

Since @kosmonautgames posted an update showing his ScreenSpaceReflection shader in action, I wondered how it would look like in my engine. So I went ahead and implemented it.

is that the same one I’m using or a better version?

Basically it is the same. Of course I had to adjust the code, so that it fits with my setup. So for example I don’t have a “roughness” parameter, since I use simple Blinn-Phong shading.
Besides I changed some values, for example I use more samples.

Also I replaced the following commented line with the one under it.

//float multiplier = xMultiplier < yMultiplier ? xMultiplier : yMultiplier;
float multiplier = min(xMultiplier, yMultiplier);

wow what a stupid line of code by me.

That’s the result when you go back from CPU code to GPU code.

For c# it’s easier not to use the Math library in my opinion, but I’m pretty sure min() is much better on GPU :slight_smile:

Oh come on, thats not real

what’s the problem with that?

You can still use PBR materials etc. just the specular shading is calculated a bit different and less realistic.

But that said

The specular cook torrance I use is the only thing where I do not understand the complete math, and the pathway to said math, behind it (and neither do most people that implemented that one). I would never ever get to that formula by myself and so I basically copied the thing / implemented the math in my shader.

That’s not really desirable with an engine testbed. I bit the bullet for more realistic graphics.

PLUS sponza doesn’t have roughness maps etc. by default and most free assets still use “spec power” as inputs… which sucks

I was just reading through this topic, (and related thread) and found myself laughing at the “absurd sounding” lingo you guys were throwing out there, like it was nothing :slight_smile:

For an un-educatered like myself, who has never met another programmer, that’s always good fun…
And then to come across a pearl of communication like blinn-phong… Amazing.

Anyways, thanks guys, your stuff is engaging, and I’m just sucking up what I can.
Many of us are, judging by the view counters…

I added Parallax Occlusion Mapping. This is a technique, which manipulates the texture coordinates of a model using a bump or height map to make the model look more detailed.

Are you and Kosmo working on the same project, or?

cool do you have any pictures?

no

Are you gonna? …:slight_smile: …

@kosmonautgames Sure, here are the images.


@monopalle No plans so far :smile:

1 Like