Skip to content

[ZH] Remove the unused WWShade library #596

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

Merged
merged 3 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
#include "GameLogic/TerrainLogic.h"
#include "WW3D2/dx8caps.h"
#include "GameClient/Drawable.h"
#ifdef USE_WWSHADE
#include "wwshade/shdmesh.h"
#include "wwshade/shdsubmesh.h"
#endif

#ifdef _INTERNAL
// for occasional debugging...
Expand Down Expand Up @@ -701,7 +703,7 @@ Int W3DShadowGeometry::initFromHLOD(RenderObjClass *robj)
}


#if (1) //(cnc3)(gth) Support for ShaderMeshes!
#ifdef USE_WWSHADE //(cnc3)(gth) Support for ShaderMeshes!
// I'm coding this as a completely independent block rather than re-factoring the code above
// because it will probably save us pain in future merges.
if (hlod->Peek_Lod_Model(top,i) && hlod->Peek_Lod_Model(top,i)->Class_ID() == RenderObjClass::CLASSID_SHDMESH)
Expand Down
4 changes: 0 additions & 4 deletions GeneralsMD/Code/Libraries/Source/WWVegas/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ target_include_directories(z_wwcommon INTERFACE
WWMath
WWSaveLoad
Wwutil
wwshade
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would a WWShade model look like? Does the WWShade code work in principle? Would it be possible to revive this feature instead of deleting it? Would it be worth it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try building W3DView with USE_WWSHADE on and open these w3ds https://www.moddb.com/games/cc-renegade/addons/cc-renegade-2-model-pack

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would a WWShade model look like? Does the WWShade code work in principle? Would it be possible to revive this feature instead of deleting it? Would it be worth it?

I agree with that, this library although it seems like it has no use, it's quite good starter step for managing the pixel shader 2.0 and 3.0 of dx 9 or later version
I don't agree with removing it, but it can be replaced with something else

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Launching w3dview with USE_WWSHADE crashes:

>	W3DView.exe!ShdHWPixelShader::Create(unsigned long * shader_code_str) Line 355	C++
 	W3DView.exe!Shd8BumpSpecClass::Init() Line 120	C++
 	[Inline Frame] W3DView.exe!ShdRendererClass::Init_Shaders() Line 95	C++
 	W3DView.exe!ShdRendererClass::Init() Line 85	C++
 	[Inline Frame] W3DView.exe!DX8Wrapper::Do_Onetime_Device_Dependent_Inits() Line 383	C++
 	W3DView.exe!DX8Wrapper::Create_Device() Line 616	C++
 	W3DView.exe!DX8Wrapper::Set_Render_Device(int dev, int width, int height, int bits, int windowed, bool resize_window, bool reset_device, bool restore_assets) Line 1076	C++
 	W3DView.exe!WW3D::Set_Render_Device(int dev, int width, int height, int bits, int windowed, bool resize_window, bool reset_device, bool restore_assets) Line 446	C++
 	W3DView.exe!CGraphicView::InitializeGraphicView() Line 209	C++
 	W3DView.exe!CMainFrame::Select_Device(bool show_dlg) Line 2195	C++
 	W3DView.exe!CMainFrame::OnCreateClient(tagCREATESTRUCTA * __formal, CCreateContext * pContext) Line 564	C++

It fails with call to D3DXAssembleShader with shd8bumpspec_psh_code. Then crashes.

The crashes can be avoided. Then all things in Shd8BumpSpecClass::Init fail initialize.

The Ren2 models do open, but I do not know what to look for in regards to wwshade. Considering it fails to initialize shaders, perhaps it will not work anyway.

kirovefih3q45t9g

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, do we remove WWShade, or not? Any opinions?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to run it. Exception states, shader_code is null, while it is -- if I understand correctly -- supposedly to be set by a DirectX API method, but it doesn't. Most documentation I can found refers to DirectX9 for shaders, not DirectX8. Wasn't Renegade 2 in DirectX9? Maybe they were planning to port ZH to DirectX9 but never got to it. Maybe shaders were never properly implemented in DirectX8?

Current models don't have shading and if there are no tools available to add shading to W3D models, then everything we want to with regards to shading needs to be built up from the ground anyways.

From that perspective, I think WWShade is more a liability then an asset and should be removed, including any reference to it. Worst case when it turns out WWShade is the way forward, we can restore it and take the extra work for granted. This PR is clear enough to understand what has been removed and can be easily reverted.

Copy link
Author

@tomsons26 tomsons26 Apr 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is still for DX8
Not all models use the chunks, indeed kirov is one that didn't, examine in wdump which do
Grizzly iirc does

)

add_subdirectory(WWAudio)
Expand All @@ -34,7 +33,6 @@ add_subdirectory(Wwutil)
add_subdirectory(WWSaveLoad)
add_subdirectory(WW3D2)
add_subdirectory(WWDownload)
add_subdirectory(wwshade)

# Helpful interface to bundle the ww modules together.
add_library(z_wwvegas INTERFACE)
Expand All @@ -48,7 +46,6 @@ target_include_directories(z_wwvegas INTERFACE
WWMath
WWSaveLoad
Wwutil
wwshade
)

target_link_libraries(z_wwvegas INTERFACE
Expand All @@ -58,6 +55,5 @@ target_link_libraries(z_wwvegas INTERFACE
z_wwlib
z_wwmath
z_wwsaveload
z_wwshade
z_wwutil
)
3 changes: 3 additions & 0 deletions GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/shdlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
#ifndef SHDLIB_H
#define SHDLIB_H

// TheSuperHackers @compile Removes the unused WWShade code. (#596)
// If there is a desire to revive this, then the WWShade library needs to be re-added.

#ifdef USE_WWSHADE

extern void SHD_Init();
Expand Down
80 changes: 0 additions & 80 deletions GeneralsMD/Code/Libraries/Source/WWVegas/wwshade/CMakeLists.txt

This file was deleted.

238 changes: 0 additions & 238 deletions GeneralsMD/Code/Libraries/Source/WWVegas/wwshade/shd6bumpdiff.cpp

This file was deleted.

Loading