Author Topic: 2 Questions: Tiling and a Shader for Shadows  (Read 8601 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #15 on: February 02, 2015, 08:26:56 pm »
So another hypothesis is that the merging of both planes produces too complex a mesh for the ShadowHelper. Is that possible? If so, is there a workaround?
Actually no. All it does it adding the depth map as an addional texture layer to all receivers. That's independent from the mesh's size. The only size related issue that i can think of might come up if you don't compile the mesh. In that case, rendering it from the light source (which is what the ShadowHelper) might exceed the maximum number of visible polygons. If that's the case, you'll get a warning message printed into the log once.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #16 on: February 03, 2015, 02:55:03 am »
My observation about rotateMesh() and clearRotation() still stands: without calling them on one of the planes, the merged was rotated so that its normals didn't face the camera and the plane was invisible.

Can you hypothesize something else about the shadows? All I know is that when the planes aren't merged, the shadows (and tiling) work. When they are, they break.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #17 on: February 03, 2015, 12:22:27 pm »
I've double checked it: The merge operation doesn't do anything with the rotations matrices. Not with those of the source object and not with those of the merged target. It just merges two arrays into one. The resulting mesh of course differs if you have or haven't called rotateMesh on either one of the sources or both. Anyway, i'm actually not sure what your issue is, so maybe we are talking about different things here.

Back to the shadows: No, i'm out of ideas ATM. You can try to the set the Logger to debug and Config.glVerbose=true and post the log output. Maybe it will reveal something...

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #18 on: February 03, 2015, 03:00:53 pm »
That's a good idea, thanks. I've e-mailed you the log file because it's too big to attach here. There's a "Found empty stage at 0" message that I don't know what it means but which looks suspicious to me...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #19 on: February 03, 2015, 05:05:17 pm »
No, that's actually a good sign... ;) It means that the shadow map has been added at stage 0 of the multi-texturing stages, which is stage 1 of the object. Or in other words: The object has one texture stage only (which is to be expected) and two after adding it as a receiver. And that's exactly how it's supposed to be. Judging from the number of messages, the object added as a receiver has ~6000 polygons. Does this match your terrain mesh?

The log looks fine to me. Can you post/mail the rest as well, i.e. the first rendering cycle up to the first visible frame?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #20 on: February 03, 2015, 05:27:06 pm »
What do you mean? Did I not send you the whole log via email?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #21 on: February 03, 2015, 07:56:33 pm »
I'm not sure. It ends with "Loading Texture...from Image"...if it would be the complete log with Config.glVerbose=true, i would expect some more details about texture uploads and such.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #22 on: February 12, 2015, 08:52:40 pm »
I stopped merging the planes in order to get my shadows. It works this way, so whatever.

Now, the problem is that I'm moving the shadows with the following code:

Code: [Select]
     double currentTime = time.getTimeOfDay();
     if (time.getTimeOfDay() >= 0.00f && time.getTimeOfDay() < 0.05f){
projector.setPosition(sunInitialPosition);
sun.setPosition(sunInitialPosition);
     }
     SimpleVector position = sun.getPosition();
     position.x = sunInitialPosition.x +(300f*(float)time.percentage);
     sun.setPosition(position);
     projector.setPosition(position);

The results are horrendous-looking shadows as shown in the following video:
https://drive.google.com/file/d/0Bxu4PEHAObLJVzBuNnM1bFNDTXM/view?usp=sharing

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #23 on: February 13, 2015, 07:31:56 am »
What do you mean? I can't spot anything wrong with the shadows... ???

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #24 on: February 13, 2015, 02:41:51 pm »
The shadows look horrendous. The first thing that anyone says when they see this is how bad the shadows look, but if I don't move the sun, the shadows look distinctly better.
« Last Edit: February 13, 2015, 02:54:29 pm by AGP »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: 2 Questions: Tiling and a Shader for Shadows
« Reply #25 on: February 13, 2015, 05:10:10 pm »
If you are moving the sun/projector, you'll get some aliasing effects on the shadows based on the size of the shadow map, the distance of the sun from the scene and the fov of the projector. You can try to decrease the fov and/or the distance to increase the accuracy. Apart from that, there's nothing you can do with this kind of shadows. I haven't seen anything in the video that i found surprising, but the quality was pretty low though. Maybe you can upload the video that shows the problem in more detail? Maybe i'm just not sseing it.
If it still doesn't work out, just don't move the sun...