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

renderer: fix vertex lighting with terrain blending and with non-style lightmap with tcGen lightmap #1026

Merged
merged 4 commits into from Jan 18, 2024

Conversation

illwieckz
Copy link
Member

@illwieckz illwieckz commented Jan 13, 2024

I guess I've set that value after some trial and error to workaround what I didn't knew was a bug, but I fixed that bug later.

In the current state of the renderer, I don't see bugs popping when removing that part, and this is needed to fix terrain blending.

I also added a commit fixing some bad spacing that was mistakenly merged.

@illwieckz
Copy link
Member Author

In thunder map, terrain blending was already working with vertex lighting, but the two stages are opaque:

unvanquished_2024-01-13_153926_000

textures/thunder_custom/ter_rocksand_xy
{
	qer_editorImage textures/thunder_custom_src/ter_rocksand_p

	q3map_nonplanar
	q3map_shadeAngle 90
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0 0 .75 )

	{
		diffuseMap textures/shared_pk02_src/rock01_d
		normalMap textures/shared_pk02_src/rock01_n
		specularMap textures/shared_pk02_src/rock01_s
		rgbGen identity
	}
	{
		diffuseMap textures/shared_pk02_src/sand01_d
		normalMap textures/shared_pk02_src/sand01_n
		specularMap textures/shared_pk02_src/sand01_s
		blendFunc blend
		alphaGen vertex
	}
}

In station15, terrain blending was broken with vertex lighting, as one of the stage is not opaque and the code was resetting the alpha channel:

unvanquished_2024-01-13_154527_000

textures/station15_custom/ter_mudmoss1
{
	qer_editorImage textures/station15_custom_src/ter_mudmoss1_p

	q3map_nonplanar
	q3map_shadeangle 120
	q3map_tcGen ivector ( 256 0 0 ) ( 0 256 0 )
	q3map_alphaMod dotproduct2 ( 0 0 .75 )

	{
		diffuseMap textures/station15_custom_src/ter_moss1_d
		rgbGen identity
	}
	{
		diffuseMap textures/station15_custom_src/ter_mud1_d
		blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
		alphaFunc GE128
		rgbGen identity
		alphaGen vertex
	}
}

Here is how it now works:

unvanquished_2024-01-13_154914_000

I don't see anymore any problem with other maps, example here with rusty (before/after) that was the map I was used when testing vertex lighting and then when I wrote that original code:

unvanquished_2024-01-13_155651_000

unvanquished_2024-01-13_155831_000

I also tested other maps like wolf:et oasis wich is known to do complex mixed lightmap/vertex ligthing and I see no regression when enabling vertex lighting or light mapping.

Scenes used to debug:

map viewpos
thunder 3906 473 142 47 13
station15 532 -1189 21 -180 34
rusty -1134 -2261 111 31 8

@illwieckz
Copy link
Member Author

I added a commit to add a debug cvar named r_showVertexColors to render the vertex colors used for vertex lighting:

unvanquished_2024-01-13_172100_000

unvanquished_2024-01-13_172014_000

@illwieckz
Copy link
Member Author

I added a commit making a difference between a light style map and a light map with useless “tcGen lightmap”.

This fixes #1027:

I verified this don't break light styled maps like gloom2 and pulse.

Before, after:

unvanquished_2024-01-13_162254_000

unvanquished_2024-01-13_180723_000

@illwieckz illwieckz changed the title renderer: fix vertex lighting with terrain blending renderer: fix vertex lighting with terrain blending and with non-style lightmap with tcGen lightmap Jan 14, 2024
@slipher
Copy link
Member

slipher commented Jan 15, 2024

LGTM

@illwieckz illwieckz merged commit 83a165d into master Jan 18, 2024
6 checks passed
@illwieckz illwieckz deleted the illwieckz/lighting branch January 18, 2024 14:58
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

2 participants