Skip to content

[REQUEST] OpenGL bump mapping restoration now matches the original Descent 3 D3D path more closely #87

@Sol1vaN

Description

@Sol1vaN

Hi Insanity,

I wanted to share a restoration milestone that may be worth looking at for master.

PiccuEngine’s modern OpenGL path now reproduces the original Descent 3 D3D bump mapping much more faithfully. This was not a simple “shader polish” job. The original effect is split across several parts of the engine, so the work required tracing the CPU-side bump generation, the model UV setup, the D3D texture-stage semantics, and the OpenGL-side emulation.

A few key pieces:

Descent 3 bumpmap generation

int iDu = v00 - v01;
int iDv = v00 - v10;
*pDst++ = (sbyte)iDu;
*pDst++ = (sbyte)iDv;
// D3D legacy setup
lpD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BUMPENVMAP);
lpD3DDevice->SetTextureStageState(1, D3DTSS_BUMPENVMAT00, ... 1.0f ...);
lpD3DDevice->SetTextureStageState(1, D3DTSS_BUMPENVMAT11, ... 1.0f ...);
lpD3DDevice->SetTextureStageState(2, D3DTSS_TEXCOORDINDEX, 1);

Original D3 bump lookup in model code

float val = dotp * 0.5f;
p->p3_uvl.u2 = val;
p->p3_uvl.v2 = val;
// OpenGL shader side
vec2 bumpDelta.x = bump.x * bumpMat00 + bump.y * bumpMat10;
vec2 bumpDelta.y = bump.x * bumpMat01 + bump.y * bumpMat11;
vec2 envCoord = vEnvUV + bumpDelta;
vec3 env = texture2D(envTex, envCoord).rgb;

The main things that were restored:

the original D3 bump map data path
the original D3 u2/v2 lookup behavior
the D3-style BUMPENVMAP matrix semantics
the use of Environment.ogf when available
mipmapped/filtered sampling so the result doesn’t look blocky or flattened
What made this tricky was that several intermediate versions “worked” visually, but were still wrong in one of these layers. The hard part was not getting a shader to move. It was getting the OpenGL path to match the old D3D behavior closely enough that the effect reads like the original game instead of a modern approximation.

I’ve attached a progression of screenshots so the evolution is visible:
early reflect/facet attempt
Image

blurry weird stage, haha!
Image

intermediate blocky versions
Image

very close to the final and good result!
Image
Image

the final smoother and nice filtered result, like original D3D descent3...
Image

reference images from original D3D with bump and OpenGL without bump
Image
Image

If you think it’s useful, I’d be happy for this to be considered for master after review.

Thanks for all the work on PiccuEngine.
If you want more details, please, let me know.
It will be great to see this in the master branch, and for everyone can enjoy piccu like we always remembered it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions