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

Improved Shader Remaps #160

Merged
merged 10 commits into from Sep 26, 2023
Merged

Improved Shader Remaps #160

merged 10 commits into from Sep 26, 2023

Conversation

Daggolin
Copy link
Member

@Daggolin Daggolin commented Apr 9, 2023

The vanilla shader remaps don't handle lightmaps properly, leading to various issues:

  • remapping a texture/shader to itself causes all instances to use the lightmap of the first instance, resulting in incorrect spots ("cow" look); this prevents the server from undoing some shader remaps
  • remapping a texture/shader to a texture/shader that wasn't loaded causes the new shader to use the internal lightmapNone, making the new shader either completly dark or fullbright

In most situations these issues are undesired, but maps have utilized these effects to light up and darken areas by remapping shaders. For that reason the default behavior of the shader remaps should not be altered.

This branch introduces a new function R_RemapShaderAdvanced which support additional arguments to specify the desired mode of shader remapping (preserve, fullbright, none, vertex, 2d) and indirectly exposes it to servers via configstring 1399.

Screenshots to compare:

  • Fullbright / Vanilla: Fullbright
  • Preserve: Preserve

…upport settings for lightmap and style.

Rename R_RemapShaderWithLightmaps to R_RemapShaderAdvanced.
Cheat protect the cvar r_newRemaps.
src/renderer/tr_shader.cpp Outdated Show resolved Hide resolved
src/client/cl_main.cpp Show resolved Hide resolved
src/client/cl_main.cpp Show resolved Hide resolved
src/renderer/tr_shader.cpp Outdated Show resolved Hide resolved
src/renderer/tr_shader.cpp Outdated Show resolved Hide resolved
…mapShaderAdvanced.

Expect timeOffset to be milliseconds as integer rather than seconds as float.
src/client/cl_main.cpp Outdated Show resolved Hide resolved
src/client/cl_main.cpp Show resolved Hide resolved
src/client/cl_main.cpp Outdated Show resolved Hide resolved
@aufau aufau added this to the Version 1.5 milestone Sep 14, 2023
@Daggolin Daggolin merged commit 7dc8400 into mvdevs:master Sep 26, 2023
19 checks passed
JKSunny added a commit to JKSunny/jk2mv that referenced this pull request Dec 22, 2023
@UncannyFish
Copy link
Contributor

This pull request breaks code that expects the trap_R_RegisterShaderNoMip to return 0.

https://github.com/mvdevs/mvsdk/blob/f37abd190b4edd1490e9cee5853dcde9170b566b/code/cgame/cg_info.c#L116-L119

	levelshot = trap_R_RegisterShaderNoMip( va( "levelshots/%s", s ) );
	if ( !levelshot ) {
		levelshot = trap_R_RegisterShaderNoMip( "menu/art/unknownmap" );
	}

https://github.com/mvdevs/mvsdk/blob/f37abd190b4edd1490e9cee5853dcde9170b566b/code/cgame/cg_players.c#L521-L522
https://github.com/mvdevs/mvsdk/blob/f37abd190b4edd1490e9cee5853dcde9170b566b/code/cgame/cg_draw.c#L1763-L1766

	// Model icon for drawing the portrait on screen
	ci->modelIcon = trap_R_RegisterShaderNoMip ( va ( "models/players/%s/icon_%s", modelName, skinName ) );
	
	// ...
	
	if ( ci->modelIcon )
	{
		CG_DrawPic( cgs.screenWidth - size - 5, y, size, size, ci->modelIcon );
	}

Loading map without levelshot

Before this pull request:
1
After this pull request:
2

Loading model without icon

Before this pull request:
3
After this pull request:
4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants