Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [LWJGL] [JOML] Shadow Map to an Ortographic View  (Read 2114 times)
0 Members and 1 Guest are viewing this topic.
Offline vfmachado

Junior Devvie


Medals: 9
Exp: 4 years



« Posted 2017-09-19 21:27:48 »

Hello,

I'm adding and studying about shadows and I've came across a lot with tutorials that use something like this for the LightView Ortho matrix:
new Matrix4f().setOrtho(-10.0f, 10.0f, -10.0f, 10.0f, -1f, 20.0f);

Playing with the values and the light I got this values as "good" values:
new Matrix4f().setOrtho(-50.0f, 50.0f, -50.0f, 50.0f, -1f, 200.0f);

I've tried different values and approaches with the distance of light trying to understand what is happening...

My question is: there is a way to compute this ortho matrix based on my current camera properties?

Thanks in advanced ... this forum is the best Tongue

[edit] I've updated the image with more objects in the scene.
Current result:



Offline Guerra2442

Senior Devvie


Medals: 25
Exp: 2 years


Guerra24


« Reply #1 - Posted 2017-09-20 03:31:18 »

My question is: there is a way to compute this ortho matrix based on my current camera properties?

What do you mean? The position of the camera that is used to generate the shadow?

Working on Light Engine.
Offline vfmachado

Junior Devvie


Medals: 9
Exp: 4 years



« Reply #2 - Posted 2017-09-20 13:39:53 »

Sorry if I wasn't clear...

My question is how to compute (which values must be used) for the ortographic projection for the camera view.

I'm considering the distance 100 in the example with the values cited before. But according with the scene size I think this values must change... How to get this values?

Also, I've noted a lot the increase/decrease of quality according with the ortographic matrix and I want avoid it to get always the same result in smaller and bigger scenes.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Guerra2442

Senior Devvie


Medals: 25
Exp: 2 years


Guerra24


« Reply #3 - Posted 2017-09-21 01:16:52 »

I'm considering the distance 100 in the example with the values cited before. But according with the scene size I think this values must change... How to get this values?

Also, I've noted a lot the increase/decrease of quality according with the ortographic matrix and I want avoid it to get always the same result in smaller and bigger scenes.

Most, if not all game engines use a fixed value for the shadow distance because calculating these per scene basis will give very bad consistency, small scenes will have sharp shadows and bigger ones soft because the resolution is not the correct for each ortho matrix.

The most performance/quality method is to use cascaded shadow maps, they work by rendering the scene multiple times using multiple ortho matrix (from small to big size).


Working on Light Engine.
Offline vfmachado

Junior Devvie


Medals: 9
Exp: 4 years



« Reply #4 - Posted 2017-09-26 13:14:56 »

Thanks for the answer,

I'm updating the code to cascade shadow maps but I still with a problem to calculate the ortho matrixes.

I found this awesome example http://ogldev.atspace.co.uk/www/tutorial49/tutorial49.html

But the code/framework is different of mine and when I update to this approach I got a problem, probably because ortho calculation isn't correct.

Question:
What I've tried is to put fix sizes of ortho projections and transforming it according to camera position, is that correct?

This is the problem that I'm getting ... running shadows just for red area.
Pages: [1]
  ignore  |  Print  
 
 

 
xxMrPHDxx (13 views)
2017-11-21 16:21:00

xxMrPHDxx (10 views)
2017-11-21 16:14:31

xxMrPHDxx (10 views)
2017-11-21 16:10:57

Ecumene (113 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (246 views)
2017-08-02 12:28:51

cybrmynd (242 views)
2017-08-02 12:19:43

cybrmynd (242 views)
2017-08-02 12:18:09

Sralse (257 views)
2017-07-25 17:13:48

Archive (875 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!