texture unit luminance

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
jordiperezarti
Halfling
Posts: 44
Joined: Sun Sep 01, 2024 7:50 pm

texture unit luminance

Post by jordiperezarti »

Code: Select all

                texture_unit
		{
		    texture floor.jpg
		}

		texture_unit
		{
		    texture floor_luminance.jpg
		    colour_op_ex modulate_x2 src_current src_texture
                }

In the second texture unit, is possible to obtain the luminance from the floor.jpg texture?
now i am adding the second texure file floor_luminance.jpg, but is possible to obtain this luminance from script?

rpgplayerrobin
Orc Shaman
Posts: 788
Joined: Wed Mar 18, 2009 3:03 am
x 447

Re: texture unit luminance

Post by rpgplayerrobin »

Yes, in hlsl it looks like this to convert from an RGB texture to a luminance value:

float3 albedo = tex2D(AlbedoMap, uv).xyz;
float luminance = pow(dot(albedo, float3(0.2126, 0.7152, 0.0722)), 1); // Change the "1" to any value to control the luminance

User avatar
jordiperezarti
Halfling
Posts: 44
Joined: Sun Sep 01, 2024 7:50 pm

Re: texture unit luminance

Post by jordiperezarti »

this is going down to the shader code, but is possible to got it from the material script?