Skip to content

Commit

Permalink
Smaller improvements, use 8 bit instead of 16bit textures for smaa
Browse files Browse the repository at this point in the history
  • Loading branch information
tobspr committed Jan 16, 2016
1 parent ade54c0 commit 327d57f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Config/plugins.yaml
Expand Up @@ -31,7 +31,7 @@ overrides:
AO.ssao_sample_count: 8
AO.ssao_sample_radius: 119.11
AO.ssvo_max_distance: 1.49
AO.ssvo_sample_count: 8
AO.ssvo_sample_count: 4
AO.ssvo_sphere_radius: 11.34556
AO.technique: SSVO
AO.ue4ao_max_distance: 4.3
Expand Down
20 changes: 4 additions & 16 deletions Plugins/AO/Shader/Stages/AOSample.frag.glsl
Expand Up @@ -50,11 +50,11 @@ void main() {
vec2 screen_size = vec2(WINDOW_WIDTH, WINDOW_HEIGHT);
vec2 pixel_size = vec2(1.0) / screen_size;

int ox = instance % 2;
int oy = instance / 2;
int quad_x = instance % 2;
int quad_y = instance / 2;
float disk_rotate = (instance / 4.0) * TWO_PI;

ivec2 coord = ivec2(gl_FragCoord.xy) * 2 - ivec2(ox, oy) * SCREEN_SIZE_INT;
ivec2 coord = ivec2(gl_FragCoord.xy) * 2 - ivec2(quad_x, quad_y) * SCREEN_SIZE_INT;
vec2 texcoord = (coord + 0.5) / SCREEN_SIZE;

// Shader variables
Expand All @@ -67,7 +67,7 @@ void main() {
vec3 view_vector = normalize(pixel_world_pos - MainSceneData.camera_pos);
float view_dist = distance(pixel_world_pos, MainSceneData.camera_pos);

vec3 noise_vec = texelFetch(Noise4x4, ivec2(gl_FragCoord.xy) % 4, 0).xyz * 2.0 - 1.0;
vec3 noise_vec = fma(texelFetch(Noise4x4, ivec2(gl_FragCoord.xy) % 4, 0).xyz, vec3(2), vec3(-1));

if (view_dist > 10000.0) {
result = vec4(1);
Expand All @@ -79,29 +79,17 @@ void main() {

// Include the appropriate kernel
#if ENUM_V_ACTIVE(AO, technique, SSAO)

#pragma include "../SSAO.kernel.glsl"

#elif ENUM_V_ACTIVE(AO, technique, HBAO)

#pragma include "../HBAO.kernel.glsl"

#elif ENUM_V_ACTIVE(AO, technique, SSVO)

#pragma include "../SSVO.kernel.glsl"

#elif ENUM_V_ACTIVE(AO, technique, ALCHEMY)

#pragma include "../ALCHEMY.kernel.glsl"

#elif ENUM_V_ACTIVE(AO, technique, UE4AO)

#pragma include "../UE4AO.kernel.glsl"

#else

#error Unkown AO technique!

#endif

result.w = pow(result.w, GET_SETTING(AO, occlusion_strength));
Expand Down
4 changes: 2 additions & 2 deletions Plugins/SMAA/SMAAStage.py
Expand Up @@ -83,7 +83,7 @@ def create(self):

# Edge detection
self._edge_target = self._create_target("SMAA:EdgeDetection")
self._edge_target.add_color_texture(bits=16)
self._edge_target.add_color_texture()
self._edge_target.prepare_offscreen_buffer()
self._edge_target.set_clear_color(color=Vec4(0))

Expand All @@ -93,7 +93,7 @@ def create(self):

# Weight blending
self._blend_target = self._create_target("SMAA:BlendWeights")
self._blend_target.add_color_texture(bits=16)
self._blend_target.add_color_texture(bits=8)
self._blend_target.prepare_offscreen_buffer()
self._blend_target.set_clear_color(color=Vec4(0))

Expand Down
2 changes: 1 addition & 1 deletion Plugins/SMAA/Shader/Stages/BlendingWeights.frag.glsl
Expand Up @@ -56,5 +56,5 @@ void main() {

// Actual Fragment shader
result = SMAABlendingWeightCalculationPS(texcoord, pixcoord, offset, EdgeTex, AreaTex, SearchTex, subsampleIndices);

}
25 changes: 2 additions & 23 deletions Shader/Stages/AmbientStage.frag.glsl
Expand Up @@ -50,21 +50,9 @@ uniform samplerCube DefaultEnvmap;
out vec4 result;

float get_mipmap_for_roughness(samplerCube map, float roughness) {

// We compute roughness in the shader as:
// roughness = 0.03 + current_mip * 0.07
// So current_mip is (roughness - 0.03) / 0.07

roughness = sqrt(roughness);
// int num_mipmaps = get_mipmap_count(map);

// Increase mipmap at extreme roughness, linear doesn't work well there
// reflectivity += (0.1 - min(0.1, roughness) ) / 0.1 * 20.0;
return roughness / 0.1;
return roughness / 0.1 + 1;
}



void main() {

vec2 texcoord = get_texcoord();
Expand All @@ -87,9 +75,8 @@ void main() {
vec3 reflected_dir = reflect(-view_vector, m.normal);

// Bend normal depending on roughness
float bend = m.roughness;
reflected_dir = mix(m.normal, reflected_dir,
(1 - bend) * (bend + sqrt(1 - bend)));
(1 - m.roughness) * (m.roughness + sqrt(1 - m.roughness)));

// Get environment coordinate, cubemaps have a different coordinate
// system
Expand Down Expand Up @@ -152,15 +139,7 @@ void main() {
ambient *= saturate(pow(occlusion, 3.0));

#endif

// ambient = ibl_specular;

} else {
// Optionally just display the environment texture
// ambient = textureLod(DefaultEnvmap, fix_cubemap_coord(-view_vector), 0).xyz;
// ambient = pow(ambient, vec3(2.2));
}

#endif

#if DEBUG_MODE
Expand Down

0 comments on commit 327d57f

Please sign in to comment.