mirror of
https://github.com/w23/xash3d-fwgs
synced 2025-01-18 23:00:01 +01:00
rtx: add reflections for water; add sky as emissive surfaces
This commit is contained in:
parent
0356013db6
commit
355ebd8d23
@ -70,9 +70,10 @@ struct Kusok {
|
||||
uint index_offset;
|
||||
uint vertex_offset;
|
||||
uint triangles;
|
||||
uint is_emissive;
|
||||
|
||||
// Material
|
||||
uint texture;
|
||||
//vec4 emissive;
|
||||
float roughness;
|
||||
};
|
||||
|
||||
struct Vertex {
|
||||
@ -311,7 +312,8 @@ void main() {
|
||||
break;
|
||||
}
|
||||
if (rayQueryGetIntersectionTypeEXT(rayQuery, true) == gl_RayQueryCommittedIntersectionNoneEXT) {
|
||||
C += kc * vec3(0., 0., 0.);
|
||||
// SKY/Nothing
|
||||
C += kc * vec3(1., 0., 0.);
|
||||
break;
|
||||
}
|
||||
if (rayQueryGetIntersectionTypeEXT(rayQuery, true) != gl_RayQueryCommittedIntersectionTriangleEXT) {
|
||||
@ -343,12 +345,8 @@ void main() {
|
||||
// break;
|
||||
|
||||
//C = vec3(hash(float(leaf)), hash(float(leaf)+15.43), hash(float(leaf)+34.));
|
||||
//C = vec3(hash(float(leaf)), float(kusok.num_surface_lights) / 63., float(kusok.is_emissive));
|
||||
//C = vec3(hash(float(leaf)), float(kusok.num_surface_lights) / 63., 0.);
|
||||
//break;
|
||||
// if (kusok.is_emissive != 0) {
|
||||
// C = vec3(0., 1., 0.);
|
||||
// break;
|
||||
//}
|
||||
|
||||
const int prim_index = rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true);
|
||||
const mat4x3 transform = rayQueryGetIntersectionObjectToWorldEXT(rayQuery, true);
|
||||
@ -526,8 +524,7 @@ void main() {
|
||||
// C += kc * vec3(hash(float(kusok_index)-102.3), hash(float(kusok_index)+15.43), hash(float(kusok_index)+34.));//kusok.emissive.rgb;
|
||||
//}
|
||||
|
||||
//const float rough = .4;
|
||||
const float rough = .9;// * hash(.01 * dot(floor((inverse(mat4(transform)) * vec4(pos, 1.))/10.).xyz, vec3(1.)));
|
||||
const float rough = kusok.roughness;
|
||||
O = pos;
|
||||
// TODO this is totally not correct
|
||||
D = normalize(mix(
|
||||
@ -535,7 +532,9 @@ void main() {
|
||||
vec3(rand01(), rand01(), rand01())*2.-1.,
|
||||
rough
|
||||
));
|
||||
kc *= .9 * baseColor * dot(D, normal);
|
||||
kc *= baseColor * dot(D, normal);
|
||||
//kc *= dot(D, normal);
|
||||
//kc *= .9;
|
||||
} // for all bounces
|
||||
|
||||
//C = mix(C, vec3(1.), printText(vec2(1.,-1.) * vec2(gl_GlobalInvocationID.xy) + vec2(0., imageSize(image).y)));
|
||||
|
@ -209,6 +209,7 @@ static void EmitWaterPolys( const cl_entity_t *ent, const msurface_t *warp, qboo
|
||||
{
|
||||
const vk_render_geometry_t geometry = {
|
||||
.texture = warp->texinfo->texture->gl_texturenum, // FIXME assert >= 0
|
||||
.material = kXVkMaterialWater,
|
||||
|
||||
.vertex_count = num_vertices,
|
||||
.vertex_buffer = vertex_buffer,
|
||||
@ -359,13 +360,36 @@ void VK_BrushModelDraw( const cl_entity_t *ent, int render_mode )
|
||||
}
|
||||
|
||||
static qboolean renderableSurface( const msurface_t *surf, int i ) {
|
||||
if( surf->flags & ( SURF_DRAWSKY | SURF_DRAWTURB | SURF_CONVEYOR | SURF_DRAWTURB_QUADS ) ) {
|
||||
// if ( i >= 0 && (surf->flags & ~(SURF_PLANEBACK | SURF_UNDERWATER | SURF_TRANSPARENT)) != 0)
|
||||
// {
|
||||
// gEngine.Con_Reportf("\t%d flags: ", i);
|
||||
// #define PRINTFLAGS(X) \
|
||||
// X(SURF_PLANEBACK) \
|
||||
// X(SURF_DRAWSKY) \
|
||||
// X(SURF_DRAWTURB_QUADS) \
|
||||
// X(SURF_DRAWTURB) \
|
||||
// X(SURF_DRAWTILED) \
|
||||
// X(SURF_CONVEYOR) \
|
||||
// X(SURF_UNDERWATER) \
|
||||
// X(SURF_TRANSPARENT)
|
||||
|
||||
// #define PRINTFLAG(f) if (FBitSet(surf->flags, f)) gEngine.Con_Reportf(" %s", #f);
|
||||
// PRINTFLAGS(PRINTFLAG)
|
||||
// gEngine.Con_Reportf("\n");
|
||||
// }
|
||||
|
||||
//if( surf->flags & ( SURF_DRAWSKY | SURF_DRAWTURB | SURF_CONVEYOR | SURF_DRAWTURB_QUADS ) ) {
|
||||
if( surf->flags & ( SURF_DRAWTURB | SURF_CONVEYOR | SURF_DRAWTURB_QUADS ) ) {
|
||||
//if( surf->flags & ( SURF_DRAWSKY | SURF_CONVEYOR ) ) {
|
||||
// FIXME don't print this on second sort-by-texture pass
|
||||
//gEngine.Con_Reportf("Skipping surface %d because of flags %08x\n", i, surf->flags);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( FBitSet( surf->flags, SURF_DRAWSKY )) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if( FBitSet( surf->flags, SURF_DRAWTILED )) {
|
||||
//gEngine.Con_Reportf("Skipping surface %d because of tiled flag\n", i);
|
||||
return false;
|
||||
@ -440,7 +464,7 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) {
|
||||
const float sample_size = gEngine.Mod_SampleSizeForFace( surf );
|
||||
int index_count = 0;
|
||||
|
||||
if (!renderableSurface(surf, i))
|
||||
if (!renderableSurface(surf, -1))
|
||||
continue;
|
||||
|
||||
if (t != surf->texinfo->texture->gl_texturenum)
|
||||
@ -465,7 +489,12 @@ static qboolean loadBrushSurfaces( model_sizes_t sizes, const model_t *mod ) {
|
||||
model_geometry->vertex_buffer = vertex_buffer;
|
||||
model_geometry->index_buffer = index_buffer;
|
||||
|
||||
VK_CreateSurfaceLightmap( surf, mod );
|
||||
if( FBitSet( surf->flags, SURF_DRAWSKY )) {
|
||||
model_geometry->material = kXVkMaterialSky;
|
||||
} else {
|
||||
model_geometry->material = kXVkMaterialDiffuse;
|
||||
VK_CreateSurfaceLightmap( surf, mod );
|
||||
}
|
||||
|
||||
for( int k = 0; k < surf->numedges; k++ )
|
||||
{
|
||||
|
@ -425,14 +425,19 @@ void VK_LightsAddEmissiveSurfacesFromModel( const struct vk_render_model_s *mode
|
||||
if (!geom->surf)
|
||||
continue; // TODO break? no surface means that model is not brush
|
||||
|
||||
if (!g_lights.map.emissive_textures[texture_num].set)
|
||||
if (geom->material != kXVkMaterialSky && !g_lights.map.emissive_textures[texture_num].set)
|
||||
continue;
|
||||
|
||||
if (g_lights.num_emissive_surfaces < 256) {
|
||||
// Insert into emissive surfaces
|
||||
vk_emissive_surface_t *esurf = g_lights.emissive_surfaces + g_lights.num_emissive_surfaces;
|
||||
esurf->kusok_index = geom->kusok_index;
|
||||
VectorCopy(g_lights.map.emissive_textures[texture_num].emissive, esurf->emissive);
|
||||
if (geom->material != kXVkMaterialSky) {
|
||||
VectorCopy(g_lights.map.emissive_textures[texture_num].emissive, esurf->emissive);
|
||||
} else {
|
||||
// TODO per-map sky emissive
|
||||
VectorSet(esurf->emissive, 1000.f, 1000.f, 1000.f);
|
||||
}
|
||||
Matrix3x4_Copy(esurf->transform, *transform_row);
|
||||
|
||||
// Insert into light grid cell
|
||||
|
@ -64,12 +64,20 @@ typedef struct vk_vertex_s {
|
||||
vec2_t lm_tc; //float p3_[2];
|
||||
} vk_vertex_t;
|
||||
|
||||
// TODO not sure how to do materials yet. Figure this out
|
||||
typedef enum {
|
||||
kXVkMaterialDiffuse,
|
||||
kXVkMaterialWater,
|
||||
kXVkMaterialSky,
|
||||
} XVkMaterialType;
|
||||
|
||||
typedef struct {
|
||||
vk_buffer_handle_t index_buffer, vertex_buffer;
|
||||
uint32_t index_offset, vertex_offset;
|
||||
|
||||
// TODO can be dynamic
|
||||
int texture;
|
||||
XVkMaterialType material;
|
||||
|
||||
uint32_t element_count;
|
||||
uint32_t vertex_count;
|
||||
|
@ -42,9 +42,10 @@ typedef struct {
|
||||
uint32_t index_offset;
|
||||
uint32_t vertex_offset;
|
||||
uint32_t triangles;
|
||||
uint32_t debug_is_emissive;
|
||||
|
||||
// Material parameters
|
||||
uint32_t texture;
|
||||
//float sad_padding_[1];
|
||||
float roughness;
|
||||
} vk_kusok_data_t;
|
||||
|
||||
typedef struct {
|
||||
@ -536,7 +537,6 @@ static void validateModelData( void ) {
|
||||
// uint32_t index_offset;
|
||||
// uint32_t vertex_offset;
|
||||
// uint32_t triangles;
|
||||
// uint32_t debug_is_emissive;
|
||||
}
|
||||
|
||||
// Check for as model memory aliasing
|
||||
@ -1129,8 +1129,9 @@ vk_ray_model_t* VK_RayModelCreate( vk_ray_model_init_t args ) {
|
||||
kusochki[i].vertex_offset = vertex_offset;
|
||||
kusochki[i].index_offset = index_offset;
|
||||
kusochki[i].triangles = prim_count;
|
||||
kusochki[i].debug_is_emissive = false; // is_emissive;
|
||||
|
||||
kusochki[i].texture = mg->texture;
|
||||
kusochki[i].roughness = mg->material == kXVkMaterialWater ? 0. : 1.;
|
||||
|
||||
mg->kusok_index = i + kusochki_count_offset;
|
||||
}
|
||||
|
@ -2012,6 +2012,7 @@ static void R_StudioDrawNormalMesh( short *ptricmds, vec3_t *pstudionorms, float
|
||||
const vk_render_geometry_t geometry = {
|
||||
//.lightmap = tglob.whiteTexture,
|
||||
.texture = texture,
|
||||
.material = kXVkMaterialDiffuse,
|
||||
|
||||
.vertex_count = num_vertices,
|
||||
.vertex_buffer = vertex_buffer,
|
||||
|
Loading…
x
Reference in New Issue
Block a user