mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-08 23:13:10 -04:00
sky: improve sun scatter
This commit is contained in:
parent
1d9cd231ae
commit
8af2dd1435
@ -34,7 +34,7 @@ Resources:
|
||||
|
||||
## Tasks
|
||||
|
||||
- [ ] Light scatter
|
||||
- [x] Light scatter
|
||||
- [ ] Atmosphere effect
|
||||
- [ ] improve fog color
|
||||
- [ ] Lens flare
|
||||
|
@ -56,10 +56,9 @@ class SunScatterRenderer(
|
||||
}
|
||||
|
||||
private fun calculateIntensity(progress: Float): Float {
|
||||
val delta = (abs(progress - 0.5f) * 2.0f)
|
||||
val sine = minOf(sin(delta * PI.toFloat() / 2.0f), 0.6f)
|
||||
val delta = (abs(progress) * 2.0f)
|
||||
|
||||
return 1.0f - sine
|
||||
return maxOf(sin(delta * PI.toFloat() / 2.0f), 0.5f)
|
||||
}
|
||||
|
||||
private fun calculateSunPosition(): Vec3 {
|
||||
@ -79,9 +78,9 @@ class SunScatterRenderer(
|
||||
if (!sky.profile.sunScatter || sky.time.phase == DayPhases.DAY || sky.time.phase == DayPhases.NIGHT || !sky.properties.sun) {
|
||||
return
|
||||
}
|
||||
shader.use()
|
||||
if (timeUpdate) {
|
||||
calculateMatrix()
|
||||
shader.use()
|
||||
shader.setMat4("uScatterMatrix", matrix)
|
||||
shader.setFloat("uIntensity", calculateIntensity(sky.time.progress))
|
||||
shader.setVec3("uSunPosition", calculateSunPosition())
|
||||
|
@ -36,11 +36,11 @@ uniform vec3 uSunPosition;
|
||||
|
||||
#define END_DISTANCE MAX_DISTANCE - 0.2f
|
||||
|
||||
#define YELLOWISH vec3(0.9f, 0.8f, 0.25f)
|
||||
#define YELLOWISH vec3(1.0f, 0.6f, 0.15f)
|
||||
#define REDISH vec3(1.0f, 0.4f, 0.05f)
|
||||
|
||||
void main() {
|
||||
foutColor = vec4(REDISH, uIntensity * 0.8f);
|
||||
foutColor = vec4(REDISH, uIntensity);
|
||||
float distance = length(uSunPosition - finFragmentPosition);
|
||||
|
||||
float distanceMultiplier = 0.0f;
|
||||
|
Loading…
x
Reference in New Issue
Block a user