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

OpenGL2: Fix merged lightmaps using tcGen environment #638

Merged
merged 3 commits into from
Feb 10, 2024

Conversation

zturtleman
Copy link

  • Fix the texcoord range for external lightmaps in a shader with an internal lightmap to be 0.0 to 1.0. (With texture repeating it would wrap around and read correctly but clampMap or tcMods might not of worked.)
  • Fix merged lightmaps using tcGen environment. (Fixes OpenGL2: Lightmap as an environment map renders incorrect with r_mergeLightmaps 1 #636.)
  • Only apply the hack to fix tcMod transform on internal merged lightmaps to tcGen lightmap.

This fixes the texcoord range to be 0.0 to 1.0 for external lightmaps in
shaders that also have an internal lightmap. (Instead of 2.0 to 3.0 for
example.) This only affects clampMap as repeating wrapping sampled the
correct location. I haven't found such a shader but I need to get real
lightmap index for future merged lightmap hacks.
tcGen environment generates texcoords in range of 0.0 to 1.0 and they
need to be offset to the position/size in the merged lightmap atlas.

This also needs to be after tcMods so they apply for the original range.
This fixes tcMod scale used by main_q3abanner and shinygrate1_4.

This issue was visible on the blue monitor (comp3c) near the plasmagun
in q3dm0 and the Quake III Arena banner in q3dm17.

Affected shaders in Quake 3 and Team Arena maps:

textures/base_wall/comp3
textures/base_wall/comp3b
textures/base_wall/comp3b_dark
textures/base_wall/comp3c
textures/base_wall/main_q3abanner
textures/base_wall/shinygrate1_4
textures/sfx/teslacoil

All of the shaders are used by q3dm0 but other maps also use some.
When using merged lightmaps, only change tcMod transform for tcGen
lightmap.
@zturtleman zturtleman merged commit 5d60f60 into ioquake:main Feb 10, 2024
3 checks passed
@zturtleman zturtleman deleted the opengl2_env_lightmap branch February 10, 2024 21:23
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.

OpenGL2: Lightmap as an environment map renders incorrect with r_mergeLightmaps 1
1 participant