Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modules API #714

Open
wants to merge 20 commits into
base: vulkan
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fc1a553
Fix texture coordinates for monitors (c1a0, c1a1f)
0x4E69676874466F78 Dec 18, 2023
1526bc8
vk: create module API outline (WIP)
nilsonragee Dec 19, 2023
d52d44e
vk: rt: restore skybox sampling for bounces
w23 Dec 19, 2023
7d7535c
vk: improve logs around skybox loading
w23 Dec 19, 2023
239d7bc
rt: try to clear temporal buffers on discontinuities once more
w23 Dec 19, 2023
e33185c
vk: update overall agenda a bit
w23 Dec 19, 2023
2f4aaec
vk: modules: integrate `textures` module as an example
nilsonragee Dec 19, 2023
c3d4d0f
Merge pull request #715 from w23/stream-E350
w23 Dec 20, 2023
4b60581
Merge pull request #713 from 0x4E69676874466F78/rad&patches
w23 Dec 20, 2023
0a6b40e
Add new rad files
0x4E69676874466F78 Dec 20, 2023
c60d851
Fix traditional render tries to load bluenoise
Aty-0 Dec 20, 2023
57fcd5a
Merge pull request #717 from Aty-0/bluenoise-micro-fix
w23 Dec 21, 2023
59f7d26
Merge pull request #716 from 0x4E69676874466F78/rad&patches
w23 Dec 21, 2023
2fe88ac
vk: create module API outline (WIP)
nilsonragee Dec 19, 2023
b989288
vk: modules: integrate `textures` module as an example
nilsonragee Dec 19, 2023
f6a0e75
Merge branch 'vk_modules' of https://github.com/nilsoncore/xash3d-fwg…
nilsonragee Dec 22, 2023
99d3fc5
vk: modules: distinguish all possible modules and integrate them
nilsonragee Dec 27, 2023
725b1a7
vk: modules: fix minor bugs
nilsonragee Dec 27, 2023
b88415d
vk: modules: fix print format args
nilsonragee Dec 27, 2023
9aa5ed2
vk: modules: track init caller correctly
nilsonragee Dec 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 40 additions & 29 deletions ref/vk/TODO.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь и далее гитхабик желает замержить файлы старыми версиями. Скорее всего это из-за ребейза.
Ребейз очень грубый инструмент, он явно и неявно ломает кучу всего. Его не рекомендуется использовать за исключением особых случаев, и очень хорошо подумав о последствиях.

Скорее всего из-за него этот PR окажется невосстановим, и придётся для мержа открывать новый, потеряв/разделив часть переписки.

Original file line number Diff line number Diff line change
@@ -1,8 +1,45 @@
Longer-term agenda for current season:
- [ ] Better PBR math, e.g.:
- [ ] Black metals: https://github.com/w23/xash3d-fwgs/issues/666
- [ ] Fresnel issues (esp. with skybox)
- [ ] Just make sure that all the BRDF math is correct
- [ ] Transparency/translucency:
- [ ] Proper material mode for translucency, with reflections, refraction (index), fresnel, etc.
- [ ] Figure out why additive transparency differs visibly from raster
- [ ] Extract and specialize effects, e.g.
- [ ] Rays -> volumetrics
- [ ] Glow -> bloom
- [ ] Smoke -> volumetrics
- [ ] Sprites/portals -> emissive volumetrics
- [ ] Holo models -> emissive additive
- [ ] Some additive -> translucent
- [ ] what else
- [ ] Render-graph-ish approach to resources.
- [ ] Performance tools -- needed for perf and lighting work below:
- [ ] Needs: render-graph-ish things for fast iterations when exporting custom situational metrics for the shader.
- [ ] Purpose: shader profiling. Measure impact of changes. Regressions.
- [ ] WIP shader clocks: https://github.com/w23/xash3d-fwgs/pull/692
- [ ] WIP perf query: https://github.com/w23/xash3d-fwgs/pull/500
- [ ] Lighting
- [ ] Point spheres sampling
- [ ] Increase limits
- [ ] s/poly/triangle/ -- simpler sampling, universal
- [ ] Better and dynamically sized clusters
- [ ] Cache rays -- do not cast shadow rays for everything, do a separate ray-only pass for visibility caching
- [ ] Bounces
- [ ] Moar bounces
- [ ] MIS
- [ ] Cache directions for strong indirect light


# 2023-12-19 E350
- [x] fixup skybox reflections
- [x] improve logs "vk/tex: Loaded skybox pbr/env/%.*s"
- [x] add skybox test

# 2023-12-18 E349
- [x] KTX2 cubemaps
- [ ] improve logs "vk/tex: Loaded skybox pbr/env/%.*s"
- [ ] variable cubemap exposure
- [ ] add skybox test
- [x] variable cubemap exposure (in .mat file)

# 2023-12-15 E348
- [x] fix ktx2 sides corruption
Expand Down Expand Up @@ -38,32 +75,6 @@
- [x] Discuss shader profiling
- [-] Discuss Env-based verbose log control

Longer-term agenda for current season:
- [ ] Tools:
- [ ] Shader profiling. Measure impact of changes. Regressions.
- [ ] Better PBR math, e.g.:
- [ ] Transparency:
- [ ] Figure out why additive transparency differs visibly from raster
- [ ] Extract and specialize effects, e.g.
- [ ] Rays -> volumetrics
- [ ] Glow -> bloom
- [ ] Smoke -> volumetrics
- [ ] Sprites/portals -> emissive volumetrics
- [ ] Holo models -> emissive additive
- [ ] Some additive -> translucent
- [ ] what else
- [ ] Proper material mode for translucency, with reflections, refraction (index), fresnel, etc.
- [ ] Lighting
- [ ] Point spheres sampling
- [ ] Increase limits
- [ ] s/poly/triangle/ -- simpler sampling, universal
- [ ] Better and dynamically sized clusters
- [ ] Cache rays -- do not cast shadow rays for everything, do a separate ray-only pass for visibility caching
- [ ] Bounces
- [ ] Moar bounces
- [ ] MIS
- [ ] Cache directions for strong indirect light

# 2023-12-04 E341
- [-] investigate envlight missing #680
- couldn't reproduce more than once
Expand Down
117 changes: 117 additions & 0 deletions ref/vk/camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,120 @@ int TriWorldToScreen( const float *world, float *screen )
return retval;
}

// NOTE(nilsoncore): Moved from `vk_beams.c`.
// It uses global `g_camera` and comment suggests to use `R_SetupFrustum` -- a function inside `camera.c` -- so probably it is a good place.
#define RP_NORMALPASS() true // FIXME ???
int CL_FxBlend( cl_entity_t *e ) // FIXME do R_SetupFrustum: , vec3_t vforward )
Comment on lines +161 to +164
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Перемещено из scene для избежания циклической зависимости, подробнее в scene.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Камера для этой функции тоже не лучшее место. Если уж хочется перенести, то лучше в какой-нибудь r_common, или там r_misc, или что-нибудь похожее, что у нас там есть или может быть.

{
int blend = 0;
float offset, dist;
vec3_t tmp;

offset = ((int)e->index ) * 363.0f; // Use ent index to de-sync these fx

switch( e->curstate.renderfx )
{
case kRenderFxPulseSlowWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFastWide:
blend = e->curstate.renderamt + 0x40 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxPulseSlow:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 2 + offset );
break;
case kRenderFxPulseFast:
blend = e->curstate.renderamt + 0x10 * sin( gpGlobals->time * 8 + offset );
break;
case kRenderFxFadeSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 0 )
e->curstate.renderamt -= 1;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxFadeFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt > 3 )
e->curstate.renderamt -= 4;
else e->curstate.renderamt = 0;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidSlow:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 255 )
e->curstate.renderamt += 1;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxSolidFast:
if( RP_NORMALPASS( ))
{
if( e->curstate.renderamt < 252 )
e->curstate.renderamt += 4;
else e->curstate.renderamt = 255;
}
blend = e->curstate.renderamt;
break;
case kRenderFxStrobeSlow:
blend = 20 * sin( gpGlobals->time * 4 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFast:
blend = 20 * sin( gpGlobals->time * 16 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxStrobeFaster:
blend = 20 * sin( gpGlobals->time * 36 + offset );
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerSlow:
blend = 20 * (sin( gpGlobals->time * 2 ) + sin( gpGlobals->time * 17 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxFlickerFast:
blend = 20 * (sin( gpGlobals->time * 16 ) + sin( gpGlobals->time * 23 + offset ));
if( blend < 0 ) blend = 0;
else blend = e->curstate.renderamt;
break;
case kRenderFxHologram:
case kRenderFxDistort:
VectorCopy( e->origin, tmp );
VectorSubtract( tmp, g_camera.vieworg, tmp );
dist = DotProduct( tmp, g_camera.vforward );

// turn off distance fade
if( e->curstate.renderfx == kRenderFxDistort )
dist = 1;

if( dist <= 0 )
{
blend = 0;
}
else
{
e->curstate.renderamt = 180;
if( dist <= 100 ) blend = e->curstate.renderamt;
else blend = (int) ((1.0f - ( dist - 100 ) * ( 1.0f / 400.0f )) * e->curstate.renderamt );
blend += gEngine.COM_RandomLong( -32, 31 );
}
break;
default:
blend = e->curstate.renderamt;
break;
}

blend = bound( 0, blend, 255 );

return blend;
}
3 changes: 3 additions & 0 deletions ref/vk/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ void R_SetupCamera( const struct ref_viewpass_s *rvp );
int R_WorldToScreen( const vec3_t point, vec3_t screen );
int TriWorldToScreen( const float *world, float *screen );

struct cl_entity_s;
int CL_FxBlend( struct cl_entity_s *e );

// TODO move to infotool.h
void XVK_CameraDebugPrintCenterEntity( void );
19 changes: 18 additions & 1 deletion ref/vk/data/valve/luchiki/maps/c1a0.patch
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,27 @@
{
"_xvk_ent_id" "10 17 9 18 51 15 12 11 19 13 16" // remove hack lights
}
// monitors
{
"_xvk_surface_id" "930"
"_xvk_tex_offset" "-2.4 0"
}
{
"_xvk_surface_id" "934"
"_xvk_tex_offset" "3 0"
}
{
"_xvk_surface_id" "2082"
"_xvk_tex_offset" "-2.7 0"
}
{
"_xvk_surface_id" "2086"
"_xvk_tex_offset" "-2.4 0"
}


// end

// end
{
"_xvk_ent_id" "20" // tune hack light entity
"_cone" "0"
Expand Down
24 changes: 21 additions & 3 deletions ref/vk/data/valve/luchiki/maps/c1a1f.patch
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,29 @@
"origin" "-53 285 -142"
}

// section 3
// section 3 (servernaya)
{
"_xvk_ent_id" "283 296 275 278 291 273 292 271" // remove hack lights entity
}

// monitors // TODO: BETTER STRETCH
{
"_xvk_surface_id" "4146" // 4140
"_xvk_tex_offset" "1 0"
}
{
"_xvk_surface_id" "4158" // 4152
"_xvk_tex_offset" "1.5 0"
}
{
"_xvk_surface_id" "4170" // 4164
"_xvk_tex_offset" "0.3 0"
}
{
"_xvk_surface_id" "4176" // 4134
"_xvk_tex_offset" "1.5 0"
}

{
"_xvk_surface_id" "4592 4593 4594 4591 4589" // remove additive "god rays" fade2
"_xvk_material" ""
Expand Down Expand Up @@ -159,14 +177,14 @@
}
{
"_xvk_surface_id" "796 795 807 800 809 808 805 801 796 780"
"_xvk_material" "generic_metal1" // TODO: texture -> material
"_xvk_material" "generic_metal1"
}
{
"_xvk_smoothing_group" "766 765 772 773 777 776 768 769"
}
{
"_xvk_surface_id" "766 765 772 773 777 776 768 769"
"_xvk_material" "generic_metal1" // TODO: texture -> material
"_xvk_material" "generic_metal1"
}

{
Expand Down
4 changes: 4 additions & 0 deletions ref/vk/data/valve/maps/c2a5a.rad
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//~LIGHT3C 220 210 150 3000
~LIGHT3C 220 210 150 2000
//+0~LIGHT4A 200 190 130 11000
+0~LIGHT4A 200 190 130 5000
2 changes: 2 additions & 0 deletions ref/vk/data/valve/maps/c2a5d.rad
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
+0~FIFTIES_LGT2 175 175 255 5000
+0~DRKMTLS2C 255 200 100 1000
1 change: 1 addition & 0 deletions ref/vk/data/valve/maps/c2a5e.rad
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
+0~FIFTIES_LGT2 175 175 255 5000
Loading