Phyronnaz / HLSLMaterial

HLSL Material for Unreal Engine
MIT License
490 stars 67 forks source link

Added support for structs. #7

Closed qwe321 closed 2 years ago

qwe321 commented 2 years ago

At the current state adding structs to the code breaks parsing, especially structs with functions which is the only easy way of adding non-material function "libraries" to the code node in UE4, i.e:

struct Functions 
{
    float4 SomeLocalFunction(float4 A, float4 B)
    {
        return lerp(A, B, 0.25);
    } 
};

void MaterialFunc(
    float4 A,
    float4 B
    out float4 Color)
{
    Functions fun;

    Color = fun.SomeLocalFunction(A, B);
}

If file contains multiple material functions, structs will be added to all of the code nodes.

Phyronnaz commented 2 years ago

Thanks! Sorry it took this long - I've manually merged it here with a few minor changes: https://github.com/Phyronnaz/HLSLMaterial/commit/91d4593dde61f9a941dfae6a54a93d5f02f0701a