Skip to content

ARB fragment program fallback for GL_ATI_texture_env_combine3 / GL_NV_texture_env_combine4#778

Draft
Copilot wants to merge 4 commits intocore4from
copilot/implement-fragment-fallback
Draft

ARB fragment program fallback for GL_ATI_texture_env_combine3 / GL_NV_texture_env_combine4#778
Copilot wants to merge 4 commits intocore4from
copilot/implement-fragment-fallback

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

On Intel HD graphics, neither GL_ATI_texture_env_combine3 nor GL_NV_texture_env_combine4 is available, disabling specular reflection (armor), per-pixel lighting, and multi-lightmap-per-pass rendering. GL_ARB_fragment_program is available on these GPUs and can emulate the required MAD (multiply-add) operations.

Fragment programs added (driver_opengl.cpp)

  • Specular: tex1 * prev.a + prev (with base texture) and tex1 + primary (without)
  • PPL stage 0: cubemap * lightColor + primary — diffuse per-pixel lighting (2 stages)
  • PPL stage 2: full 3-stage PPL with diffuse + specular cube maps and light color uniforms
  • Lightmap: 1/2/3 lightmap stages with per-stage factor colors via program.env params

Programs are compiled in initFragmentShaders() only when combine extensions are absent but ARBFragmentProgram is present. Cleaned up in deleteARBFragmentPrograms().

Rendering paths updated (driver_opengl_material.cpp)

  • beginSpecularMultiPass() / setupSpecularPass(): single-pass specular via fragment program instead of broken 2-pass fallback (which was #ifdef'd out due to Intel texture bugs)
  • setupPPLPass() / setupPPLNoSpecPass(): early-return path binds fragment program with light colors as program.env uniforms, skipping all texenv setup
  • computeLightMapInfos() / setupLightMapPass(): up to 3 lightmaps per pass (previously fell back to 1)
  • All end*MultiPass() functions disable GL_FRAGMENT_PROGRAM_ARB when the fallback was active

Capability detection (driver_opengl.cpp)

  • checkForPerPixelLightingSupport(): ARBFragmentProgram now qualifies as combine support

Example specular fragment program:

!!ARBfp1.0
TEMP base, cube, prev;
TEX base, fragment.texcoord[0], texture[0], 2D;
TEX cube, fragment.texcoord[1], texture[1], CUBE;
MUL prev, base, fragment.color.primary;
MAD result.color.rgb, cube, prev.a, prev;
MOV result.color.a, fragment.color.primary.a;
END
Original prompt

This section details on the original issue you should resolve

<issue_title>Implement fragment program fallback for GL_ATI_texture_env_combine3 and GL_NV_texture_env_combine4</issue_title>
<issue_description>On Intel HD graphics the GL_ATI_texture_env_combine3 and GL_NV_texture_env_combine4 extensions are not supported, this causes reflection on armor to become disabled. As GL_ARB_fragment_program is available on this graphics target, it should be possible to support the MAD operator in the texture stages by generating a fragment program.

The behaviour of GL_ATI_texture_env_combine3 is the desired ideal behaviour.</issue_description>

<agent_instructions>:)</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 14, 2026 00:49
Implement fragment program fallback paths for specular reflection,
per-pixel lighting, and lightmap rendering when GL_ATI_texture_env_combine3
and GL_NV_texture_env_combine4 extensions are not available but
GL_ARB_fragment_program is (e.g., Intel HD graphics).

This fixes armor reflection being disabled on Intel HD graphics.

Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Co-authored-by: kaetemi <1581053+kaetemi@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement fragment program fallback for texture environment combine ARB fragment program fallback for GL_ATI_texture_env_combine3 / GL_NV_texture_env_combine4 Feb 14, 2026
Copilot AI requested a review from kaetemi February 14, 2026 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Implement fragment program fallback for GL_ATI_texture_env_combine3 and GL_NV_texture_env_combine4

2 participants