Skip to content

Commit

Permalink
Gloom: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 1acf937 commit 698b8c6
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 56 deletions.
2 changes: 1 addition & 1 deletion doomsday/tests/test_gloom/gloom/render/skybox.cpp
Expand Up @@ -90,7 +90,7 @@ void SkyBox::glInit(const Context &context)
buf->setVertices(gl::TriangleStrip, verts, gl::Static);
d->skyBox.addBuffer(buf);

context.shaders->build(d->skyBox.program(), "indirect.textured.color")
context.shaders->build(d->skyBox.program(), "gloom.indirect.textured.color")
<< d->uMvpMatrix
<< context.uAtlas;
}
Expand Down
6 changes: 1 addition & 5 deletions doomsday/tests/test_gloom/net.dengine.gloom.pack/shaders.dei
@@ -1,6 +1,2 @@
@include <shaders/generic.dei>
@include <shaders/fx-blur.dei>
@include <shaders/ui.dei>
@include <shaders/indirect.dei>
@include <shaders/app/app.dei>
@include <shaders/gloom.dei>
@include <shaders/model.dei>
@@ -0,0 +1,3 @@
@include <generic.dei>
@include <fx_blur.dei>
@include <ui.dei>
@@ -1,5 +1,4 @@
group fx.blur
{
group fx.blur {
# The same vertex shader is used for both blur steps.
vertexShader = """
uniform mat4 uMvpMatrix;
Expand All @@ -19,8 +18,7 @@ group fx.blur
vColor = aColor * uColor;
}"""

shader horizontal
{
shader horizontal {
vertex $= fx.blur.vertexShader
fragment = "
uniform sampler2D uTex;
Expand All @@ -43,8 +41,7 @@ group fx.blur
}"
}

shader vertical
{
shader vertical {
vertex $= fx.blur.vertexShader
fragment = "
uniform sampler2D uTex;
Expand Down
Expand Up @@ -26,8 +26,8 @@ ui {
vScissor = uScissorRect[index];
vSaturation = uSaturation[index];
}"
include.fragment <hsv.glsl>
fragment = "
#include 'hsv.glsl'
uniform sampler2D uTex;

DENG_VAR vec2 vUV;
Expand Down
@@ -1,23 +1,24 @@
highp float fogDensity(highp vec3 worldPos, highp vec3 eyePos, highp float fogEnd)
{
#ifndef GLOOM_FOG_H
#define GLOOM_FOG_H

float fogDensity(vec3 worldPos, vec3 eyePos, float fogEnd) {
return clamp(log(distance(worldPos, eyePos) / fogEnd)/3.0 + 1.0, 0.0, 1.0);
}

/**
* Determine fog color at a given world position. The alpha component of fog color
* Determine fog color at a given world position. The alpha component of fog color
* determines how thick the fog is at the point.
*
* @param worldPos World coordinates.
* @param eyePos Eye in world coordinates.
* @param fogSpec (R, G, B, maxdist)
*/
highp vec4 fogColor(highp vec3 worldPos, highp vec3 eyePos, highp vec4 fogSpec)
{
vec4 fogColor(vec3 worldPos, vec3 eyePos, vec4 fogSpec) {
return vec4(fogSpec.rgb, fogDensity(worldPos, eyePos, fogSpec.a));
}

highp vec4 mixFog(highp vec4 color, highp vec4 fog)
{
vec4 mixFog(vec4 color, vec4 fog) {
return vec4(mix(color.rgb, fog.rgb, fog.a), color.a);
}

#endif // GLOOM_FOG_H
@@ -0,0 +1,8 @@
#ifndef GLOOM_GBUFFER_IN_H
#define GLOOM_GBUFFER_IN_H

uniform sampler2D uGBufferAlbedo;
uniform sampler2D uGBufferNormal;
uniform sampler2D uGBufferDepth;

#endif // GLOOM_GBUFFER_IN_H
@@ -1,13 +1,12 @@
#ifndef GLOOM_GBUFFER_H
#define GLOOM_GBUFFER_H
#ifndef GLOOM_GBUFFER_OUT_H
#define GLOOM_GBUFFER_OUT_H

layout (location = 1) out vec4 out_Normal;

uniform mat3 uWorldToViewMatrix;

void GBuffer_SetFragmentNormal(vec3 worldNormal)
{
void GBuffer_SetFragmentNormal(vec3 worldNormal) {
out_Normal = vec4(normalize(uWorldToViewMatrix * worldNormal) * 0.5 + vec3(0.5), 1.0);
}

#endif // GLOOM_GBUFFER_H
#endif // GLOOM_GBUFFER_OUT_H
@@ -1,22 +1,24 @@
highp float lightIntensity(highp vec3 normal, highp vec3 lightDir)
{
#ifndef GLOOM_LIGHTMODEL_H
#define GLOOM_LIGHTMODEL_H

float lightIntensity(vec3 normal, vec3 lightDir) {
return clamp(dot(normal, -lightDir) + 0.1, 0.0, 1.0);
}

/**
* Light model with one Sun-like bright light source at an infinite distance.
*
*
* @param normal Surface normal.
* @param lightDir Light direction vector.
* @param fogSpec Fog RGB, maxdistance.
*/
highp vec3 sunLightFactor(highp vec3 normal, highp vec3 lightDir, highp vec4 fogSpec)
{
vec3 sunLightFactor(vec3 normal, vec3 lightDir, vec4 fogSpec) {
// Ambient light.
highp vec3 ambientColor = fogSpec.rgb * 0.75;
vec3 ambientColor = fogSpec.rgb * 0.75;

float intensity = lightIntensity(normal, lightDir);

highp float intensity = lightIntensity(normal, lightDir);

return (ambientColor + vec3(intensity)) * 0.6;
}

#endif // GLOOM_LIGHTMODEL_H
@@ -1,7 +1,12 @@
#ifndef GLOOM_MIPLEVEL_H
#define GLOOM_MIPLEVEL_H

// Determines mipmap level.
float mipLevel(vec2 uv, vec2 texSize) {
vec2 dx = dFdx(uv * texSize.x);
vec2 dy = dFdy(uv * texSize.y);
float d = max(dot(dx, dx), dot(dy, dy));
return 0.5 * log2(d);
}

#endif // GLOOM_MIPLEVEL_H
Expand Up @@ -38,7 +38,7 @@ shader gloom.entity {
#include.fragment <includes/fog.glsl,
# includes/lightmodel.glsl>
fragment = "
#include 'gbuffer.glsl'
#include 'common/gbuffer_out.glsl'

uniform sampler2D uTex;
//uniform vec4 uFog; // RGB, max.distance
Expand Down
@@ -1,3 +1,6 @@
@include <indirect.dei>
@include <entity.dei>

group gloom {
shader surface {
path.vertex = "surface.vsh"
Expand All @@ -15,9 +18,7 @@ group gloom {
}
"
fragment = "
uniform sampler2D uGBufferAlbedo;
uniform sampler2D uGBufferNormal;
uniform sampler2D uGBufferDepth;
#include 'common/gbuffer_in.glsl'
uniform int uDebugMode;
DENG_VAR vec2 vUV;
void main(void) {
Expand Down
@@ -1,16 +1,13 @@
group indirect
{
group textured
{
group gloom.indirect {
group textured {
# Shader with one texture plus a color per vertex. Texture coords
# are indirectly mapped within the aBounds attribute. Uses a combined
# model-view-projection matrix. Texture coordinates also repeat within
# the bounds.
shader color
{
path.vertex = "indirect-textured.vsh"
shader color {
path.vertex = "indirect_textured.vsh"
fragment = "
#include 'miplevel.glsl'
#include 'common/miplevel.glsl'

uniform sampler2D uTex;
DENG_VAR vec2 vUV;
Expand All @@ -26,11 +23,10 @@ group indirect
}"
}

shader color_repeat
{
path.vertex = "indirect-textured.vsh"
shader color_repeat {
path.vertex = "indirect_textured.vsh"
fragment = "
#include 'miplevel.glsl'
#include 'common/miplevel.glsl'

uniform sampler2D uTex;
DENG_VAR vec2 vUV;
Expand Down
Expand Up @@ -11,8 +11,7 @@ DENG_VAR vec2 vTexSize;
DENG_VAR vec4 vColor;
DENG_VAR vec4 vBounds;

void main(void)
{
void main(void) {
gl_Position = uMvpMatrix * aVertex;
vUV = aUV0;
vTexSize = aUV1;
Expand Down
@@ -1,7 +1,5 @@
#include "miplevel.glsl"
#include "gbuffer.glsl"

#line 3
#include "common/gbuffer_out.glsl"
#include "common/miplevel.glsl"

uniform sampler2D uTex;
uniform sampler2D uTextureMetrics;
Expand Down
@@ -1,4 +1,4 @@
#include 'flags.glsl'
#include "common/flags.glsl"

uniform mat4 uMvpMatrix;
uniform sampler2D uPlanes;
Expand Down

0 comments on commit 698b8c6

Please sign in to comment.