Horde3D

Next-Generation Graphics Engine
It is currently 22.10.2017, 21:59

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: 05.05.2017, 12:58 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Hi,

I'm trying to create a bigger scene which is about 4 to 8 times than the platform demos. Basically I just resized the platform to test it out quickly. I got a bit of a problem fixing the shadow acne with the depth bias as it seems it does not go away

My settings as follows:

LightNode = "LIGHTING", "SHADOWMAP"
LightRadius = 800.0
ShadowResolution = 2094
DepthBias = 0.0001
CameraFar = 2000

Image

Any ideas for sun type lighting for larger scenes?


Top
 Profile  
Reply with quote  
PostPosted: 06.05.2017, 18:53 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1149
Location: Germany
Not sure if I see it correctly but it looks to me as it is a texture border problem not a shadow one. But maybe I'm wrong. Did you try another seamless texture?


Top
 Profile  
Reply with quote  
PostPosted: 08.05.2017, 02:33 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Volker wrote:
Not sure if I see it correctly but it looks to me as it is a texture border problem not a shadow one. But maybe I'm wrong. Did you try another seamless texture?


Thanks Volker. Yes, I did try several textures but with same results. I'm not sure about the seamless part as this was the stone texture that comes with the repo/examples. Anyway here's another seamless texture showing the shadow artifact.

Image

Can you recommend a good shadow settings for bigger scenes? Is the engine capable of producing outdoor lighting on a larger scene out of the box? I'm kind of getting a spotlight effect if I set a lower light radius value which seems obvious. Maybe I have missed something like setting up for proper directional lighting?


Top
 Profile  
Reply with quote  
PostPosted: 08.05.2017, 06:08 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1149
Location: Germany
Unfortunately I didn't ever do any shadow implementation so probably you have to ask someone with more experience with lighting calculations. As far as I know the shadow calculations are stored in a texture and it looks like your artefacts might result from a precision problem. So if possible try to increase the shadow resolution to 4096. But as mentioned I don't really know how the shadow calculations are implemented.


Top
 Profile  
Reply with quote  
PostPosted: 08.05.2017, 10:53 
Offline

Joined: 17.11.2009, 17:00
Posts: 165
Location: Russia, Moscow
I don't know if it matters in this case, but Horde currently does not support directional lights (without attenuation) that are frequently used in outdoor locations to represent sun. You'll have to create a new lighting shader to implement it.


Top
 Profile  
Reply with quote  
PostPosted: 09.05.2017, 11:26 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Thanks guys.

Volker wrote:
Unfortunately I didn't ever do any shadow implementation so probably you have to ask someone with more experience with lighting calculations. As far as I know the shadow calculations are stored in a texture and it looks like your artefacts might result from a precision problem. So if possible try to increase the shadow resolution to 4096. But as mentioned I don't really know how the shadow calculations are implemented.


Actually, the artifacts goes away if I get the bias to a reasonable value, the only problem I could see is that it is cutoff and not a full shadow and I can't seem to pin point the correct precision for it. On smaller light radius value like 200 or 400 it works btw with 0.001.

Quote:
I don't know if it matters in this case, but Horde currently does not support directional lights (without attenuation) that are frequently used in outdoor locations to represent sun. You'll have to create a new lighting shader to implement it.


I see. Will it have any effect and would it be possible to tweak the values between splits? With other engines you can just tweak the values (something like 5, 10, 50, 100) aside from shadowBias to fix the shadow quality depending on the scene.


Top
 Profile  
Reply with quote  
PostPosted: 09.05.2017, 18:50 
Offline

Joined: 17.11.2009, 17:00
Posts: 165
Location: Russia, Moscow
I'm by no means an expert in shadows, but:
If you are not using the latest code from develop branch, I suggest you to modify model.shader a bit:
In [[FS_SHADOWMAP]] uncomment line:
Code:
// Clearly better bias but requires SM 3.0
//gl_FragDepth = dist + abs( dFdx( dist ) ) + abs( dFdy( dist ) ) + shadowBias;


Quote:
With other engines you can just tweak the values (something like 5, 10, 50, 100) aside from shadowBias to fix the shadow quality depending on the scene.


To tweak what? Light attenuation? Current shaders do not support this, so you'll have to add this functionality and send your parameters through uniforms.
Number of shadow maps (splits)? You can set it through h3dSetNodeParamI( light, H3DLight::ShadowMapCountI, value ). Judging by the internal code, you can change it dynamically when you need it.


Top
 Profile  
Reply with quote  
PostPosted: 10.05.2017, 07:22 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Thanks Idris. The uncomment model shader fix did it! :)

This is now the develop branch that I tested earlier. I got rid of the bigger artifact but just left with this artifact line that I assume is the split there.

Replaced the texture to plain white (w/ custom yellowish ambient map texture there) and diffuse only shading to isolate texture seamless issues.

Image

view from top

Image

Platform is scaled to 2.0 from 0.23 default.

I'm also not an expert when it comes to shadow and shader stuff, but I'm quite interested in shadows and level/scene optimizations.

So are there plans to add direct lighting included in Horde3D so the lighting won't be limited to spotlight type lighting?

Thanks.


Top
 Profile  
Reply with quote  
PostPosted: 10.05.2017, 07:40 
Offline

Joined: 17.11.2009, 17:00
Posts: 165
Location: Russia, Moscow
I'm planning to implement directional lights support, because it will be used extensively in our projects, but I cannot say exactly when it will be implemented.

Basically, for a quick and dirty solution, see fragLighting(GL4).glsl, copy function "createPhongSpotLight" and rename it to something like "createPhongDirectionalLight". Now comment out spotlight falloff and, probably, in distance attenuation atten should be set to 1.0.
Now, create a new context in model.shader, something like LIGHTINGDIRECT that references your vertex and fragment shaders.
Vertex shader should be the same and copy/rename a fragment shader to something like FS_LIGHTINGDIRECT. Here, change the last function from calcPhongSpotLight to your function name.

I'll dig into shadow code and try to find the problem that generates this line.


Top
 Profile  
Reply with quote  
PostPosted: 10.05.2017, 12:56 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Thanks Idris! for a quick solution it does work somehow. There are some issues and I'm sure this is to be expected. I only made some modification (light radius and position) to compare settings.

There is still a bit of a spotlight edge but not that noticeable.
Image

Got rid of darker areas around but the bright spot is still there. This is the result using the default radius and position..

Image

Increasing the light radius and moving the light source farther away from the ground makes it less noticeable but it's still visible.

Image

and comparing to the default spotlight code it is definitely an improvement.

Image

Looking forward to your DL implementation, and thanks again. :)


Top
 Profile  
Reply with quote  
PostPosted: 10.05.2017, 13:45 
Offline

Joined: 17.11.2009, 17:00
Posts: 165
Location: Russia, Moscow
Ah, this is probably due to specular. Try to get rid of specular in the last formula (fragLighting.glsl):
Code:
// Final color
   return (albedo + specular) * lightColor * atten * shadowTerm;


Top
 Profile  
Reply with quote  
PostPosted: 10.05.2017, 17:00 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Irdis wrote:
Ah, this is probably due to specular. Try to get rid of specular in the last formula (fragLighting.glsl):
Code:
// Final color
   return (albedo + specular) * lightColor * atten * shadowTerm;



Thanks. It did lessen a bit, but apparently the spot is still there.

I was also wondering if the HGE version got this covered. It's been a while since I checked out the demos but I see most of them are setup for outside environment.

Image

https://www.youtube.com/watch?v=SUTtzWli9VM


Top
 Profile  
Reply with quote  
PostPosted: 11.05.2017, 21:13 
Offline

Joined: 17.11.2009, 17:00
Posts: 165
Location: Russia, Moscow
It seems that HGE has special shaders that are variations of model.shader with a bit changed lighting shader. I wasn't digging a lot, but fragLighting.glsl was changed a bit too and the changes had something to do with shadows.


Top
 Profile  
Reply with quote  
PostPosted: 14.05.2017, 11:23 
Offline

Joined: 02.04.2013, 16:49
Posts: 24
Thanks! I think I'll check out HGE again as well.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group