Skip to content

VTF resource data, spritecard flag, user clip transform and texcoord fixes - #257

Merged
marchc1 merged 3 commits into
SourceDotNET:mainfrom
Earu:materialsystem/vtf-resources-and-render-gaps
Nov 16, 2026
Merged

marchc1 merged 3 commits into
SourceDotNET:mainfrom
Earu:materialsystem/vtf-resources-and-render-gaps

Conversation

@Earu

@Earu Earu commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Split from #256. Those are things needed for implemeting the particle system. Aside from the extension fix and the camera position change, nothing on main calls those yet.

  • VTF: load resource chunks, implement GetResourceData / HasResourceEntry, expose resource types. Textures keep their resource data (needed for particle sheets).
  • IMaterial.IsSpriteCard
  • MatRenderContext / ShaderAPI: EnableUserClipTransformOverride and UserClipTransform (previously threw), GetWorldSpaceCameraVectors
  • GetWorldSpaceCameraPosition recomputes the view state first, so BeamSegDraw no longer reads a possibly stale origin
  • FindMaterial strips a trailing extension before lookup
  • GL46: texcoord 6/7 go to the wrinkle/specular attribute locations so formats stay within 16 vertex attributes. Flex streams are only bound when TC4/TC5 are unused

Matches SDK 2013 and GMod's materialsystem.dll, including two existing quirks:

  • GetWorldSpaceCameraVectors returns zero forward/right
  • materials with a dot in the filename (e.g. hl2 boxrocket_chell_head/face_1.0) get truncated by the extension strip

Verification:

  • All 49,743 VTFs from GMod, HL2 + episodes and TF2 load identically to main (dimensions, format, flags, image hash)
  • All 32,951 non-image resource entries match the raw file bytes
  • Flex shaders on main request at most 3 texcoords, so their attribute bindings are unchanged
  • Debug, Release and both Dedicated configs build; tests pass

Earu added 2 commits November 13, 2026 20:39
…rm and texcoord fixes

- VTF: load resource chunks, implement GetResourceData/HasResourceEntry and
  expose resource types; textures keep their resource data
- IMaterial.IsSpriteCard
- MatRenderContext: EnableUserClipTransformOverride, UserClipTransform and
  GetWorldSpaceCameraVectors
- IMesh: TexCoord4f / TexCoord4fv
- FindMaterial strips a trailing extension
- GL46: map texcoord 6/7 to the wrinkle/specular attribute locations to stay
  within 16 vertex attributes, and only bind flex streams when TC4/TC5 are
  unused
- IsSpriteCard returns false when the render state is invalid
- UserClipTransform only flushes when the matrix changes; starts as identity
@Earu Earu changed the title materialsystem: VTF resource data, spritecard flag, user clip transform and texcoord fixes VTF resource data, spritecard flag, user clip transform and texcoord fixes Nov 13, 2026
Comment thread Source.MaterialSystem/Texture.cs Resolved
Comment thread Source.MaterialSystem/Texture.cs Resolved
Comment thread Source.VTF/VTFTexture.cs Resolved
Comment thread Source.VTF/VTFTexture.cs Resolved
Comment thread Source.Common/VTF.cs Resolved
Comment thread Source.VTF/VTFTexture.cs Resolved
Store texture resources only after a successful load, keep the first copy
until shutdown, return the unserialize result from SLoadTextureBitsFromFile,
guard resource reads past the end of the file, drop the stream settings
lookup from LoadImageData and the allocating GetResourceTypes overload.
@Earu
Earu requested a review from marchc1 November 14, 2026 23:02
@marchc1
marchc1 merged commit ff7999b into SourceDotNET:main Nov 16, 2026
16 checks passed
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.

2 participants