2 Questions: Tiling and a Shader for Shadows

Started by AGP, January 28, 2015, 10:20:18 PM

Previous topic - Next topic

EgonOlsen

Quote from: AGP on February 02, 2015, 05:34:33 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.

AGP

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.

EgonOlsen

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...

AGP

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...

EgonOlsen

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?

AGP

What do you mean? Did I not send you the whole log via email?

EgonOlsen

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.

AGP

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:


     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

EgonOlsen

What do you mean? I can't spot anything wrong with the shadows... ???

AGP

#24
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.

EgonOlsen

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...