vk: rt: add test for srgb-vs-linear model color
This commit is contained in:
parent
9843f53cde
commit
7bfba01954
|
@ -49,7 +49,7 @@ void readNormals(ivec2 uv, out vec3 geometry_normal, out vec3 shading_normal) {
|
|||
}
|
||||
|
||||
|
||||
bool getHit(vec3 origin, vec3 direction, inout RayPayloadPrimary payload) {
|
||||
bool getHit(vec3 origin, vec3 direction, inout RayPayloadPrimary payload, int test_val) {
|
||||
rayQueryEXT rq;
|
||||
const uint flags = 0
|
||||
//| gl_RayFlagsCullFrontFacingTrianglesEXT
|
||||
|
@ -84,10 +84,11 @@ bool getHit(vec3 origin, vec3 direction, inout RayPayloadPrimary payload) {
|
|||
if (rayQueryGetIntersectionTypeEXT(rq, true) != gl_RayQueryCommittedIntersectionTriangleEXT)
|
||||
return false;
|
||||
|
||||
primaryRayHit(rq, payload);
|
||||
primaryRayHit(rq, payload, test_val);
|
||||
//L = rayQueryGetIntersectionTEXT(rq, true);
|
||||
return true;
|
||||
}
|
||||
const int INDIRECT_SCALE = 2;
|
||||
|
||||
void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specular) {
|
||||
diffuse = vec3(0.);
|
||||
|
@ -149,7 +150,8 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
|
|||
payload.base_color_a = vec4(0.);
|
||||
payload.emissive = vec4(0.);
|
||||
const vec3 pos = imageLoad(position_t, pix).xyz + geometry_normal * ray_normal_fudge;
|
||||
if (!getHit(pos, bounce_direction, payload))
|
||||
const ivec2 res = ivec2(imageSize(out_indirect_diffuse)) / INDIRECT_SCALE;
|
||||
if (!getHit(pos, bounce_direction, payload, (pix.x < res.x / 2) ? 0 : 1))
|
||||
return;
|
||||
|
||||
throughput *= payload.base_color_a.rgb;
|
||||
|
@ -180,7 +182,6 @@ void computeBounce(ivec2 pix, vec3 direction, out vec3 diffuse, out vec3 specula
|
|||
}
|
||||
}
|
||||
|
||||
const int INDIRECT_SCALE = 2;
|
||||
|
||||
void main() {
|
||||
const ivec2 pix = ivec2(gl_GlobalInvocationID);
|
||||
|
|
|
@ -103,7 +103,7 @@ void main() {
|
|||
if (rayQueryGetIntersectionTypeEXT(rq, true) == gl_RayQueryCommittedIntersectionTriangleEXT) {
|
||||
//debug_geometry_index = rayQueryGetIntersectionGeometryIndexEXT(rq, true);
|
||||
//debug_geometry_index = rayQueryGetIntersectionPrimitiveIndexEXT(rq, true);
|
||||
primaryRayHit(rq, payload);
|
||||
primaryRayHit(rq, payload, (pix.x < res.x / 2) ? 0 : 1);
|
||||
L = rayQueryGetIntersectionTEXT(rq, true);
|
||||
} else {
|
||||
// Draw skybox when nothing is hit
|
||||
|
|
|
@ -20,7 +20,7 @@ vec4 sampleTexture(uint tex_index, vec2 uv, vec4 uv_lods) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
|
||||
void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload, int test_value) {
|
||||
Geometry geom = readHitGeometry(rq, ubo.ubo.ray_cone_width, rayQueryGetIntersectionBarycentricsEXT(rq, true));
|
||||
const float hitT = rayQueryGetIntersectionTEXT(rq, true); //gl_HitTEXT;
|
||||
const vec3 rayDirection = rayQueryGetWorldRayDirectionEXT(rq); //gl_WorldRayDirectionEXT
|
||||
|
@ -99,7 +99,18 @@ void primaryRayHit(rayQueryEXT rq, inout RayPayloadPrimary payload) {
|
|||
|
||||
const int model_index = rayQueryGetIntersectionInstanceIdEXT(rq, true);
|
||||
const ModelHeader model = getModelHeader(model_index);
|
||||
const vec4 color = model.color * SRGBtoLINEAR(kusok.material.base_color); // FIXME why is material.base_color in gamma space?
|
||||
|
||||
//#define TEST_COLORS_GAMMA
|
||||
#ifdef TEST_COLORS_GAMMA
|
||||
// FIXME:
|
||||
// - should material.base_color (which we control) be linear or sRGB?
|
||||
// - is model.color linear or sRGB? It's a value from the engine, which implies sRGB. Can we convert it once in the native code?
|
||||
const vec4 color = test_value == 0
|
||||
? SRGBtoLINEAR(model.color) * kusok.material.base_color
|
||||
: model.color * kusok.material.base_color;
|
||||
#else
|
||||
const vec4 color = SRGBtoLINEAR(model.color) * kusok.material.base_color;
|
||||
#endif
|
||||
|
||||
payload.base_color_a *= color;
|
||||
payload.emissive.rgb *= color.rgb;
|
||||
|
|
Loading…
Reference in New Issue