Skip to content

ShaderGen refactor #1372

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

Open
wants to merge 7 commits into
base: development
Choose a base branch
from

Conversation

marauder2k7
Copy link
Contributor

@marauder2k7 marauder2k7 commented Jan 28, 2025

allows passing a struct to a shaderGen feature.

Usage Example:

// register feature with create function
FEATUREMGR->registerFeature(SNF_TextureFeature, new TextureFeatureHLSL, TextureFeatureHLSL::createFunction);

// create a struct for the feature
struct TextureFeatureParams
{
   String samplerName;
   String uvName;
   String uvType;

   TextureFeatureParams()
   {
      uvName = "texCoord";
   }
};

class TextureFeatureHLSL : public ShaderFeatureHLSL
{
private:
   /// Parameters that this feature can use to change the shadergen output.
   TextureFeatureParams* params;
public:
   /// default constructor
   NodeTextureFeatureHLSL()
   {
      params = new NodeTextureFeatureParams();
   }
   /// Constructor that takes params as an argument
   TextureFeatureHLSL(TextureFeatureParams* inParams)
   {
      params = inParams;
   }
  // create a static function on the feature class
  static ShaderFeature* createFunction(void* args)
  {
     TextureFeatureParams* params = static_cast<TextureFeatureParams*>(args);
      return new TextureFeatureHLSL(params);
  } 

   String getName() override
   {
      return "Texture Sampler";
   }
}

@marauder2k7 marauder2k7 force-pushed the ShaderGen-FeatureArguments branch from 957b400 to 9a7fa96 Compare March 23, 2025 17:25
@marauder2k7 marauder2k7 changed the title Shader gen feature arguments ShaderGen refactor Mar 24, 2025
Added ability to shader features and shaderGen to create multiple instances of the same feature with the option of calling a static creation function that can take arguments in the form of a struct.

FEATUREMGR now has createFeature to take advantage of this.

The node editor requires this ability as the same node could be used multiple times with different arguments so in its update function we will be calling

```FEATUREMGR->registerFeature(feature_type, (optional default constructor), createFunction);```

then adding it to the feature set with the required arguments to build the shader feature.
```FeatureSet->add(feature_type, index, ParameterStruct);```
review: revert to full black background for material preview window
use top level shaderFeature getVertTexCoord
added op for attribute
remove getVertTexCoord from everywhere else that it is not needed
move expandNormalMap to shaderFeature
remove it from other places.
@marauder2k7 marauder2k7 force-pushed the ShaderGen-FeatureArguments branch from 782c310 to f7025e6 Compare March 25, 2025 20:53
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.

1 participant