mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-20 23:24:16 +00:00
Adds resolve PBR compute shader
Also fixes sky shader as it was writing negative values for -Y direction.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<effect>
|
||||
<technique>
|
||||
<require shaders="glsl"/>
|
||||
<require shaders="spirv"/>
|
||||
<compute shader="compute_resolve_pbr"/>
|
||||
</technique>
|
||||
</effect>
|
||||
@@ -0,0 +1,34 @@
|
||||
#version 430
|
||||
|
||||
#include "common/compute.h"
|
||||
|
||||
BEGIN_DRAW_TEXTURES
|
||||
TEXTURE_2D(0, inTex)
|
||||
END_DRAW_TEXTURES
|
||||
|
||||
BEGIN_DRAW_UNIFORMS
|
||||
UNIFORM(vec4, screenSize)
|
||||
// Premultiplied exposure, already contains 2^exposure.
|
||||
UNIFORM(float, exposure)
|
||||
END_DRAW_UNIFORMS
|
||||
|
||||
STORAGE_2D(0, rgba8, outTex);
|
||||
|
||||
vec3 applyTonemapper(vec3 color)
|
||||
{
|
||||
float whitePoint = 10.0;
|
||||
// Extendend Reinhard:
|
||||
// https://www-old.cs.utah.edu/docs/techreports/2002/pdf/UUCS-02-001.pdf
|
||||
return color * (vec3(1.0) + color / (whitePoint * whitePoint)) / (vec3(1.0) + color);
|
||||
}
|
||||
|
||||
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
|
||||
void main()
|
||||
{
|
||||
ivec2 position = ivec2(gl_GlobalInvocationID.xy);
|
||||
if (any(greaterThanEqual(position, ivec2(screenSize.xy))))
|
||||
return;
|
||||
vec3 hdrColor = texelFetch(GET_DRAW_TEXTURE_2D(inTex), position, 0).rgb;
|
||||
vec3 sdrColor = applyTonemapper(hdrColor * exposure);
|
||||
imageStore(outTex, position, vec4(sdrColor, 1.0));
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<program type="glsl">
|
||||
<compute file="glsl/compute_resolve_pbr.cs"/>
|
||||
</program>
|
||||
@@ -6,10 +6,10 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex = SAMPLE_CUBE(GET_DRAW_TEXTURE_CUBE(baseTex), v_tex);
|
||||
vec3 color = SAMPLE_CUBE(GET_DRAW_TEXTURE_CUBE(baseTex), v_tex).rgb;
|
||||
|
||||
float m = (1.0 - v_tex.y) - 0.75;
|
||||
m *= 4.0;
|
||||
|
||||
OUTPUT_FRAGMENT_SINGLE_COLOR((v_tex.y > 0.0) ? (tex * m) : tex);
|
||||
OUTPUT_FRAGMENT_SINGLE_COLOR(vec4((v_tex.y > 0.0) ? clamp(color * m, 0.0, 1.0) : color, 1.0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user