Page 1 of 1

[2.1] Use only diffuse colour with unlit hlms

Posted: Tue Mar 16, 2021 7:23 pm
by DOS
Hello,

is there a way to only use the diffuse colour for materials made with the default unlit hlms (while completely ignoring the vertex colour)?
When you set a diffuse colour, either by passing in the param "diffuse x y z" when creating the datablock or using SetUseColour and SetColour on the datablock, the template always uses this line from the unlit pixel shader:

@property( hlms_colour && !diffuse_map ) outPs.colour0 = inPs.colour @insertpiece( MultiplyDiffuseConst );@end

So the pixel colour gets mixed with the diffuse colour.
There is this line which looks like it does what I want:

@property( !hlms_colour && diffuse ) outPs.colour0 = material.diffuse;@end

But I don't know what functions to call to have the properties set correctly. hlms_colour seems to be set automatically when adding diffuse colour so this
line is never generated.

Re: [2.1] Use only diffuse colour with unlit hlms

Posted: Tue Mar 16, 2021 9:19 pm
by dark_sylinc
Not out the box.

If you want to ignore vertex colour I suppose you could subclass HlmsUnlit, overload HlmsUnlit::calculateHashForPreCreate and call:

Code: Select all

void HlmsMyVersion::calculateHashForPreCreate( Renderable *renderable, PiecesMap *inOutPieces )
{
    setProperty( HlmsBaseProp::Colour,    0 );
    HlmsUnlit::calculateHashForPreCreate( renderable, inOutPieces );
}
That should give you what you're looking for