Derpius / VisTrace

Garry's Mod binary module for tracing meshes at high speed on the CPU (and much more)
https://derpius.github.io/VisTrace
MIT License
27 stars 1 forks source link

[feature] Implement texture scaling #32

Closed Derpius closed 2 years ago

Derpius commented 2 years ago

Is your feature request related to a problem? Please describe. Textures are incorrectly scaled on many surfaces

Describe the solution you'd like Multiply UV coordinates by the texture transforms before being used in sampling and texture LoD calculations

Additional context Code from the Source SDK for initialising a 2x4 mat from a 3x4 mat

void CBaseVSShader::SetVertexShaderTextureTransform( int vertexReg, int transformVar )
{
    Vector4D transformation[2];
    IMaterialVar* pTransformationVar = s_ppParams[transformVar];
    if (pTransformationVar && (pTransformationVar->GetType() == MATERIAL_VAR_TYPE_MATRIX))
    {
        const VMatrix &mat = pTransformationVar->GetMatrixValue();
        transformation[0].Init( mat[0][0], mat[0][1], mat[0][2], mat[0][3] );
        transformation[1].Init( mat[1][0], mat[1][1], mat[1][2], mat[1][3] );
    }
    else
    {
        transformation[0].Init( 1.0f, 0.0f, 0.0f, 0.0f );
        transformation[1].Init( 0.0f, 1.0f, 0.0f, 0.0f );
    }
    s_pShaderAPI->SetVertexShaderConstant( vertexReg, transformation[0].Base(), 2 ); 
}
Derpius commented 2 years ago

Implemented, need to test

Derpius commented 2 years ago

Transformation is completely incorrect

Derpius commented 2 years ago

Added in 15fa7e8395881c8ed8ac54296a3f3dbe09ef6f30