haedri / shadow-mapping Goto Github PK
View Code? Open in Web Editor NEWShadow mapping tutorial for LibGdx
Shadow mapping tutorial for LibGdx
Hi haedri, thank you for great tutorials,
I tried to change direction of light at part 2:
from this:
currentLight = new DirectionalLight(this, new Vector3(33, 10, 3), new Vector3(-10, 0, 0));
to this:
currentLight = new DirectionalLight(this, new Vector3(15, 10, 0), new Vector3(0, -10, 0));
However it does not create lighting as expected.
Using this values seems to be working (only x is different):
currentLight = new DirectionalLight(this, new Vector3(15, 10, 0), new Vector3(0.01f, -10, 0));
Maybe there is a bug at the framework, but I did not succeed at finding source of problem yet.
In my opinion your tutorial of "part2" contains a mistake.
See topic "Creating a depth shader":
Your fragment shader has the following line:
gl_FragColor = vec4(length(v_position.xyz-u_lightPosition)/u_cameraFar);
... and you said:
A darker pixel means the point is farther away from the camera.
But it is the other way round, it is more brighter if the point is farther away.
For instance, "v_position.xyz-u_lightPosition" would be 10 and u_cameraFar would be 10 too. than the result is 10/10 = 1.. the farthest distance possible. This will give us vec4(1.0f) seen as Color (gl_FragColor) would be white, rgba(255,255,255,255).
So your supporting image is also not correct.
Regarding to your source code example the result depthmap-image is also like my assumption.
See my attached image file;
So this part of your tutorial is a little confusing and finally not correct.. it costs me a few hours to find out ;-)
Nevertheless, thank you 'lot for this tutorial!
I am trying to make it work with my custom shaders.
I have some model instances and some custom shaders with them. How can this adopt to work with that? I tried everything but I got strange results...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.