[2.1] Use only diffuse colour with unlit hlms

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
DOS
Gnoblar
Posts: 19
Joined: Tue Oct 27, 2020 5:34 pm

[2.1] Use only diffuse colour with unlit hlms

Post 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.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

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

Post 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
Post Reply