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

Incomplete material data. #17

Closed
SharkPetro opened this issue Feb 29, 2024 · 6 comments · Fixed by #19
Closed

Incomplete material data. #17

SharkPetro opened this issue Feb 29, 2024 · 6 comments · Fixed by #19
Labels
enhancement New feature or request

Comments

@SharkPetro
Copy link

Material importer ignores VMT properties other than $basetexture and VTF data other than the single image that is the base texture.

The biggest issue is the lack of mip texture export. Even with VTFs where mip textures are included, the importer ignores them.

It would be great if the most used properties changed Godot material properties such as $translucent turning transparency from disabled to alpha.

@H2xDev H2xDev added the enhancement New feature or request label Feb 29, 2024
@H2xDev
Copy link
Owner

H2xDev commented Mar 1, 2024

@SharkPetro
Implemented native VTF support. Check feature/VTFTool branch and give a try :)

@SharkPetro
Copy link
Author

SharkPetro commented Mar 1, 2024

@H2xDev
Sorry for the delay, I couldn't really get to my PC. Here's what I found so far:

  • All materials are still missing mip textures which makes open areas and big interiors suffer from intense texture shimmering in the distance.
  • The materials with "$detail" are correctly imported with detail_enabled set to true, but the materials lack the detail maps themselves and thus appear completely white. Turning each material's detail off in godot fixes the issue, as well as removing "$detail" from the VMTs before export.
  • Transparency mode of "alpha scissor" should only be used for materials with "alphatest" 1, all materials with "translucent" 1 should have "alpha" instead.
  • Some materials are wrongfully exported as transparent, none of the parameters in the VMT matter as far as my testing went, instead all VTFs with alpha channel are transparent, which is wrong. Example:

glasswindow005c is a texture that correctly gets identified as transparent as there's "$translucent" 1. VMT:

"LightmappedGeneric"
{
	// Original shader: BaseTimesLightmapAlphaBlend
	"$translucent" 1
	"$basetexture" "Glass/glasswindow005c"
	"$surfaceprop" "glass"
	"%keywords" "c17industrial"
}

glasswindow005b is incorrectly set as transparent, instead the alpha channel should control emission as there's "$selfillum" 1. VMT:

"LightmappedGeneric"
{
	// Original shader: BaseTimesLightmapSelfIllum
	"$basetexture" "Glass/glasswindow005b"
	"$selfillum" 1
	"$surfaceprop" "glass"
	"%keywords" "c17industrial"
}

EDIT: Also blendtextures don't work but you probably know that.

@H2xDev
Copy link
Owner

H2xDev commented Mar 2, 2024

@SharkPetro
Good. I fixed these problems i think. You can try test it. The same branch

About blendtextures. There need a separate material shader for it that can have two textures. I already implemented the shader but i need to create a new BaseMaterial3D resource that will work this this shader and use it during import. Actually i don't really know how to implement it now.

And there are some breaking changes regarding to config. Check the installation docs again :)

@H2xDev H2xDev linked a pull request Mar 2, 2024 that will close this issue
@SharkPetro
Copy link
Author

SharkPetro commented Mar 2, 2024

I am stupid, sorry, clicking buttons accidentally, I didn't mean to close the issue.

Everything works good except transparency does not get applied to any materials at all and detail blend mode is all wrong because the detail maps were meant to be used with blend modes completely different from "mix" or any others that are in Godot.

Though to implement detail maps as they work in source there needs to be another custom shader. $detailblendmode parameter defines what exactly the detail map does.
Most materials use "$detailblendmode" 0 which is a simple brightness effect. Colors below 128 darken the image, colors above brighten it. This mode is used on bricks and concrete alike, but most notably on damage impact decals, they are the reason textures don't look like blobby mess in valve games as the albedo maps themselves are pretty blurry.
1 is additive.
2 is a translucent detail map that gets drawn on top with transparency in consideration.
3 is the same as 2 but now instead of alpha, the blend value is used for transparency.

There's also mipblend parameter that controls the way detail maps interact with mip textures.

But these are just some examples, I think for now it'll be good enough to have one blend mode "$detailblendmode" 0 which most valve made materials use. If possible it should only take effect on surfaces that are currently drawn with mip level of 3 or less, which is one thing that mipblend can do. It'll be a very long time until you implement the entire material system as it is in source so an approximation is good enough.

Thank you for this update, the mipmaps alone are enough to make up for all else, and I have few enough transparent materials for it not to be an issue.

@SharkPetro SharkPetro reopened this Mar 2, 2024
@H2xDev
Copy link
Owner

H2xDev commented Mar 2, 2024

Could you share the map you trying to import? I’d like to use it as test case :)

@SharkPetro
Copy link
Author

SharkPetro commented Mar 2, 2024

Sure thing. Github doesn't support this file type so here's google drive link: https://drive.google.com/file/d/1uXSS8ys_J-BdhOkxnxVrX4pnQ8rIYgnc/view?usp=drive_link.

It uses only Half Life 2 textures, all of which I stole from the game files.

I am currently just removing detail folder from materials to get around the issue, so the map is looking almost exactly as it does in source and I couldn't be happier.

@H2xDev H2xDev closed this as completed in #19 Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants