Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
edge-of-space
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dario Seyb
edge-of-space
Commits
fd666247
Commit
fd666247
authored
Jan 15, 2016
by
Dario Seyb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed skybox leaking through planet
parent
b4fe425c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
23 deletions
+56
-23
data/shader/Atmosphere.fsh
data/shader/Atmosphere.fsh
+42
-14
data/shader/DeferredCombine.fsh
data/shader/DeferredCombine.fsh
+1
-1
data/shader/PassBlit.fsh
data/shader/PassBlit.fsh
+1
-0
data/shader/WaterSurface.fsh
data/shader/WaterSurface.fsh
+3
-1
data/shader/terrain/dispMapping_fsh.glsl
data/shader/terrain/dispMapping_fsh.glsl
+4
-4
src/game/src/engine/graphics/RendererSystem.cpp
src/game/src/engine/graphics/RendererSystem.cpp
+2
-1
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
+3
-2
No files found.
data/shader/Atmosphere.fsh
View file @
fd666247
#pragma import "CommonTransparentFrag.glsl"
#pragma import "noise/noise3d.glsl"
uniform vec3 uObjectPosition;
uniform vec3 uSunDir;
...
...
@@ -24,30 +24,58 @@ vec3 intersectSphere(vec3 o, vec3 l, vec3 c, float r) {
return o + l * max(0, min(a + dsqrt, a - dsqrt));
}
float pow8(float val) {
val = val * val;
val *= val;
val *= val;
return val;
}
vec4 color() {
float depth = texture(uSamplerDepth, gl_FragCoord.xy*uOneOverScreenSize ).r;
float atmosphereRadius =
length(tePosition - uObjectPosition)
;
float planetRadius = 6374.1305775862702;
float atmosphereRadius =
planetRadius * 1.025
;
vec3 camSpaceWorldPos = unpackWorldPosition(depth) - uCameraPosition;
vec3 viewDir = normalize(tePosition - uCameraPosition);
vec3 camSpaceAtmospherePos = intersectSphere(uCameraPosition, viewDir, uObjectPosition, atmosphereRadius) - uCameraPosition;
if(camSpaceAtmospherePos == -uCameraPosition) discard;
vec3 worldPos = camSpaceWorldPos - uObjectPosition + uCameraPosition;
float planetRadius = length(worldPos);
float atmosphereThickness = atmosphereRadius - planetRadius;
vec3 atmospherePos = camSpaceAtmospherePos - uObjectPosition;
float distance = depth == 1 ? 1000000000.0f : abs(length(camSpaceWorldPos) - length(camSpaceAtmospherePos));
distance = min(distance, length(camSpaceAtmospherePos - tePosition + uCameraPosition));
float fogAmount = 1.0 - exp( -distance*4.0/atmosphereRadius );
vec3 currentPos = camSpaceAtmospherePos;
float totalDistance = depth == 1 ? 1000000000.0f : abs(length(camSpaceWorldPos) - length(camSpaceAtmospherePos));
totalDistance = min(totalDistance, length(camSpaceAtmospherePos - tePosition + uCameraPosition));
int steps = 10;
float sunAmount = max( dot( viewDir, uSunDir ), 0.0 );
vec3 fogColor = mix( vec3(0.5,0.6,0.9), // bluish
vec3(1.0,0.9,0.7), // yellowish
pow(sunAmount,8.0) );
float distance = totalDistance/steps;
float totalFog = 0;
for(int i = 0; i < steps; i++) {
currentPos += viewDir * distance;
vec3 localPos = currentPos - uObjectPosition + uCameraPosition;
float currentHeight = length(localPos) - planetRadius;
float h = currentHeight/atmosphereThickness;
float cloud = abs((fbm_3d( localPos, 4, 0.00005) * 300 - fbm_3d( localPos, 1, 0.002) * 100))* abs((h - 0.5) * (h-0.5)) * (1.0-h);
float atm = 20 * (1-h) * (1-h)* (1-h);
float density = ( atm + cloud)/atmosphereRadius;
totalFog += density * distance;
}
float fogAmount = 1.0 - exp(-totalFog);
vec3 fogColor = mix( vec3(0.2,0.3,0.9), // bluish
vec3(1.0,0.9,0.7) * 1.2, // yellowish
pow8(sunAmount) );
return vec4(fogColor, fogAmount); //texture(uTexture, teTexCoord).rgba * uTintColor;
}
...
...
@@ -58,4 +86,4 @@ vec4 emissive() {
vec3 normal() {
return teNormal;
}
}
\ No newline at end of file
data/shader/DeferredCombine.fsh
View file @
fd666247
...
...
@@ -102,5 +102,5 @@ void main()
float lightNdotL = max(0, dot(lightDir, normal));
vec4 lighting = BRDF (albedo.rgb, specularSmoothness.rgb, oneMinusReflectivity, specularSmoothness.a, normal, viewDir, lightDir, lightNdotL, uLightColor.rgb * uLightColor.a);
oColor = vec4(lighting.rgb + emissive.rgb,
albedo.a *
uOneOverLightCount);
oColor = vec4(lighting.rgb + emissive.rgb, uOneOverLightCount);
}
data/shader/PassBlit.fsh
View file @
fd666247
...
...
@@ -9,4 +9,5 @@ out vec4 oColor;
void main()
{
oColor = texture(uSamplerColor, vTexCoord);
oColor.a = min(1, max(0, oColor.a));
}
data/shader/WaterSurface.fsh
View file @
fd666247
...
...
@@ -4,7 +4,9 @@
#pragma import "Utils.glsl"
vec4 color() {
return texture(uTexture, teTexCoord).rgba * uTintColor;
vec4 color = texture(uTexture, teTexCoord).rgba * uTintColor;
color.a = 1;
return color;
}
vec4 emissive() {
...
...
data/shader/terrain/dispMapping_fsh.glsl
View file @
fd666247
...
...
@@ -24,10 +24,10 @@ vec4 color() {
vec4
color
=
texture_getColor
(
gPosInModelspace
,
gUpVector_normalized
,
approxNormal
);
float
d1
=
min
(
min
(
gTriDistance
.
x
,
gTriDistance
.
y
),
gTriDistance
.
z
);
/*
float d1 = min(min(gTriDistance.x, gTriDistance.y), gTriDistance.z);
float d2 = min(min(gPatchDistance.x, gPatchDistance.y), gPatchDistance.z);
color
=
amplify
(
d1
,
80
,
-
0
.
5
)
*
amplify
(
d2
,
120
,
-
0
.
5
)
*
color
;
color
.
w
=
1
.
0
;
color = amplify(d1, 80, -0.5) * amplify(d2, 120, -0.5) * color;
*/
color
.
a
=
1
.
0
;
return
color
;
}
...
...
@@ -40,5 +40,5 @@ vec3 normal() {
}
vec4
specularSmoothness
()
{
return
vec4
(
0
.
2
,
0
.
2
,
0
.
2
,
0
.
5
);
return
vec4
(
0
.
2
,
0
.
2
,
0
.
2
,
0
.
1
);
}
src/game/src/engine/graphics/RendererSystem.cpp
View file @
fd666247
...
...
@@ -497,7 +497,8 @@ void RendererSystem::render(RenderPass& pass, double interp, double totalTime) {
// Transparent rendering
glEnable
(
GL_DEPTH_TEST
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glBlendFuncSeparate
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
,
GL_SRC_ALPHA
,
GL_ONE
);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glCullFace
(
GL_FRONT
);
for
(
size_t
i
=
0
;
i
<
pass
.
submittedDrawCallsTransparent
.
size
();
i
++
)
{
auto
&
drawCall
=
pass
.
submittedDrawCallsTransparent
[
i
];
...
...
src/game/src/engine/scene/OrbitalSimulationSystem.cpp
View file @
fd666247
...
...
@@ -105,7 +105,7 @@ bool OrbitalSimulationSystem::startup() {
RenderQueue
::
OPAQUE
,
GL_BACK
};
atmosphereMat
=
{
glm
::
vec4
(
0
,
0
,
1
,
0.9
f
),
atmosphereMat
=
{
glm
::
vec4
(
0
,
0
,
1
,
1.0
),
glm
::
vec4
(
0
,
0
,
.2
,
1
),
texture
,
nullptr
,
...
...
@@ -214,6 +214,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
glm
::
dvec3
pos
=
applyKepler
(
planetComponent
,
0
);
pos
=
glm
::
dvec3
(
AUToWorld
(
pos
.
x
),
AUToWorld
(
pos
.
y
),
AUToWorld
(
pos
.
z
));
planetTransform
->
scale
=
glm
::
dvec3
(
solarToWorld
(
r
),
solarToWorld
(
r
),
solarToWorld
(
r
));
planetTransform
->
position
=
pos
;
...
...
@@ -224,7 +225,7 @@ Entity OrbitalSimulationSystem::addPlanet(Transform::Handle sun, std::string n,
auto
atmosphereTransform
=
atmosphere
.
assign
<
Transform
>
();
atmosphereTransform
->
parent
=
planetTransform
;
atmosphere
.
assign
<
Drawable
>
(
defaultGeom
,
atmosphereMat
,
0
,
m_renderer
->
getRenderPassId
(
"Main"
_sh
));
atmosphereTransform
->
scale
=
planetTransform
->
scale
*
1.05
;
atmosphereTransform
->
scale
=
planetTransform
->
scale
*
1.0
2
5
;
// Add simple water as well
auto
water
=
m_scene
->
create
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment