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

Export & decompile shaders should output VFX files #777

Open
szmarczak opened this issue Apr 21, 2024 · 6 comments
Open

Export & decompile shaders should output VFX files #777

szmarczak opened this issue Apr 21, 2024 · 6 comments

Comments

@szmarczak
Copy link

Describe the bug

image

image

Relevant log output or exception with stacktrace

No response

What game does this happen in

CS2

Reference file in a Source 2 game

game\csgo_core\shaders_pc_dir.vpk

Expected behavior

VFX should be exported

What version of VRF are you using?

v9.0.3420

@szmarczak szmarczak added the bug label Apr 21, 2024
@xPaw xPaw removed the bug label Apr 22, 2024
@szmarczak
Copy link
Author

szmarczak commented Apr 22, 2024

Also the generated VFX may be invalid (csgo_character.vfx). I tried recompiling it with vxc from https://github.com/kristiker/csgo-shader-pipeline/tree/main and it said that it couldn't guess the type for all variables with DWORD.

https://github.com/ValveResourceFormat/ValveResourceFormat/blob/cfcaea9f6a6df4e8fc8b0b18f6be3d7afc7abf43/ValveResourceFormat/IO/ShaderExtract.cs#L485C13-L485C32

https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-scalar

When I changed it to uint [manually in the generated shader code] it worked (I mean the could not guess the type errors were gone). Also could be that it's case sensitive (in that case it should be dword but I haven't checked that.

Also StaticCombo and DynamicCombo (not: StaticComboRule nor DynamicComboRule) require 3 parameters, while 2 are only present. I guess the third parameter is a description. I set it to empty string.

csgo_character.txt

I still couldn't get it to compile but that could be because the compiler is outdated in that repo (Build: Oct 31 2023 01:31:11).
I had to replace ChildOf1 with

+StaticComboRule( Requires1( S_ANISOTROPIC_GLOSS == 1, S_SPHERICAL_PROJECTED_ANISOTROPIC_TANGENTS == 0 ) );
-StaticComboRule( ChildOf1( S_SPHERICAL_PROJECTED_ANISOTROPIC_TANGENTS, S_ANISOTROPIC_GLOSS ) );

otherwise it would output that it doesn't know what ChildOf1 is.

compile logs
//---------------------------------------------------------------------------//
// VFXC - Valve FXC Wrapper (64-bit) ( Build: Oct 31 2023 01:31:11 )         //
// Copyright (c) Valve Corporation, All rights reserved.                     //
// Command: C:\Users\szmar\Downloads\csgo-shader-pipeline-main\compiler\bin\win64\vfxc.exe C:\Users\szmar\Downloads\csgo-shader-pipeline-main\compiler\core\shaders\csgo_character.shader -vs -ps -50 -v -binout
////---------------------------------------------------------------------------//
// Vertex Shader
//---------------------------------------------------------------------------//
Static: S_ANISOTROPIC_GLOSS=0 S_SPHERICAL_PROJECTED_ANISOTROPIC_TANGENTS=0 S_SUBSURFACE_SCATTERING=0 S_USE_PER_VERTEX_CURVATURE=0 S_EYEBALLS=0 S_MODE_TOOLS_VIS=0 S_SUPPORTS_DECALS=0 S_MODE_DEPTH=0 S_MORPH_SUPPORTED=0
Dynamic: D_SKINNING=0 D_COMPRESSED_NORMALS_AND_TANGENTS=0 D_BAKED_LIGHTING_FROM_VERTEX_STREAM=0 D_BAKED_LIGHTING_FROM_LIGHTMAP=0 D_MORPH=0

//---------------------------------------------------------------------------//
// Pixel Shader
//---------------------------------------------------------------------------//
Static: S_ANISOTROPIC_GLOSS=0 S_SPHERICAL_PROJECTED_ANISOTROPIC_TANGENTS=0 S_SUBSURFACE_SCATTERING=0 S_USE_PER_VERTEX_CURVATURE=0 S_EYEBALLS=0 S_MODE_TOOLS_VIS=0 S_DECAL_TEXTURE=0 S_ALPHA_TEST=0 S_TRANSLUCENT=0 S_ADDITIVE_BLEND=0 S_TINT_MASK=0 S_RETRO_REFLECTIVE=0 S_ANISOTROPIC_HAIR=0 S_MODE_DEPTH=0 S_PATCHES=0 S_SUPPORTS_DECALS=0
Dynamic: D_BAKED_LIGHTING_FROM_VERTEX_STREAM=0 D_BAKED_LIGHTING_FROM_PROBE=0 D_BAKED_LIGHTING_FROM_LIGHTMAP=0 D_MBOIT_PASS1=0 D_MBOIT_PASS2=0 D_MBOIT_4_MOMENTS=0 D_DECALS_ENABLED=0

ANTLR - Expecting ID
      ; > ;

      #line 264
====> float g_fDistanceContrastExposure < string uitype = "Slider" ; string uigroup = "Visibility" ; string expression = "F_TRANSLUCENT ? this : (1-this)" ; UiVisibility ( F_DISTANCE_CONTRAST_ADJUSTMENT ) ; > ;

      #line 267
      float g_flEyeBallWalleyeL1 < float range1 [ 2 ] = { 0 , 25 } ; string uitype = "Slider" ; string uigroup = "Material1/Eyes/95" ; > ;

ANTLR - Expecting '>'
      ; > ;

      #line 264
====> float g_fDistanceContrastExposure < string uitype = "Slider" ; string uigroup = "Visibility" ; string expression = "F_TRANSLUCENT ? this : (1-this)" ; UiVisibility ( F_DISTANCE_CONTRAST_ADJUSTMENT ) ; > ;

      #line 267
      float g_flEyeBallWalleyeL1 < float range1 [ 2 ] = { 0 , 25 } ; string uitype = "Slider" ; string uigroup = "Material1/Eyes/95" ; > ;

ANTLR - Expecting '>'
      ; > ;

      #line 264
====> float g_fDistanceContrastExposure < string uitype = "Slider" ; string uigroup = "Visibility" ; string expression = "F_TRANSLUCENT ? this : (1-this)" ; UiVisibility ( F_DISTANCE_CONTRAST_ADJUSTMENT ) ; > ;

      #line 267
      float g_flEyeBallWalleyeL1 < float range1 [ 2 ] = { 0 , 25 } ; string uitype = "Slider" ; string uigroup = "Material1/Eyes/95" ; > ;

HLSL parser encountered 3 errors
ANTLR - Expecting '>'
      string g_inputTexture2D_TextureRoughness < string inputColorSpace = "Linear" ; string minPrecision = "8" ; string imageAlgorithm = "Inverse" ; string fileExt = "_rough" ; string uigroup = "Lighting,30/Roughness,20/10" ; float default4 [ 4 ] = { 0.5 , 0.5 , 0.5 , 0 } ; > = "" ; ;
      float g_flAmbientOcclusionMasking < float range1 [ 2 ] = { 0 , 0.99 } ; string uitype = "Slider" ; string uigroup = "Lighting,30/Rimlight,50/10" ; > ;
      float g_flHairTransmission < string uitype = "Slider" ; string uigroup = "Lighting,30/Hair/45,10" ; > ;
====> string g_inputTexture2D_TextureHairMask < string inputColorSpace = "Linear" ; string minPrecision = "8" ; string imageAlgorithm = "" ; string fileExt = "_hair" ; string uigroup = "Lighting,30/Hair/45,20" ; "materials/default/default_mask.tga" ; > = "" ; ;
      string g_inputTexture2D_TextureRetroReflectiveMask < string inputColorSpace = "Linear" ; string minPrecision = "8" ; string imageAlgorithm = "" ; string fileExt = "_mask" ; string uigroup = "Lighting,30/RetroReflectivity,30/20" ; float default4 [ 4 ] = { 1 , 1 , 1 , 0 } ; > = "" ; ;
      string g_inputTexture2D_TextureCloth < string inputColorSpace = "Linear" ; string minPrecision = "8" ; string imageAlgorithm = "" ; string fileExt = "_cloth" ; string uigroup = "Lighting,30/Cloth,40" ; "materials/default/default_black_mask.tga" ; > = "" ; ;
      float g_flSheenScale < float range1 [ 2 ] = { 0 , 10 } ; string uitype = "Slider" ; string uigroup = "Lighting,30/Cloth,40" ; UiVisibility ( F_CLOTH_SHADING ) ; > ;

HLSL parser encountered 1 error

@xPaw
Copy link
Member

xPaw commented Apr 22, 2024

You vastly underestimate the complexity of the shaders.

@kristiker
Copy link
Member

The shader decompile output does not have enough data to be compiled back.

And ChildOf1 should be ChildOf i think.

@szmarczak
Copy link
Author

@kristiker I think you're right, however it doesn't work for StaticComboRule (I guess the generated VFX is invalid):

StaticComboRule( ChildOf( S_SPHERICAL_PROJECTED_ANISOTROPIC_TANGENTS, S_ANISOTROPIC_GLOSS ) );

*** Error! ChildOf is only allowed in FeatureRules! C:\Users\szmar\Downloads\csgo-shader-pipeline-main\compiler\core\shaders\csgo_character.shader

@kristiker
Copy link
Member

Oh interesting, our exporter needs updating then.

@szmarczak
Copy link
Author

When I changed it to uint [manually in the generated shader code] it worked (I mean the could not guess the type errors were gone). Also could be that it's case sensitive (in that case it should be dword but I haven't checked that.

I checked and the types are case-sensitive. The attached compiler does not understand dword, however it understands uint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants