I tried something that didn't work but maybe if I post it here someone may be able to point out some mistakes.
Textures first
Code: Select all
texture2D PaletteDay
<
string ResourceName="PaletteDay.bmp";
>; //ENB Palette Day
texture2D PaletteNight
<
string ResourceName="PaletteNight.bmp";
>; //ENB Palette Night
texture2D PaletteInterior
<
string ResourceName="PaletteInterior.bmp";
>; //ENB PaletteInterior
sampler2D SamplerPaletteDayTexture = sampler_state
{
Texture = <PaletteDay>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture = FALSE;
MaxMipLevel = 0;
MipMapLodBias = 0;
};
sampler2D SamplerPaletteNightTexture = sampler_state
{
Texture = <PaletteNight>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture = FALSE;
MaxMipLevel = 0;
MipMapLodBias = 0;
};
sampler2D SamplerPaletteInteriorTexture = sampler_state
{
Texture = <PaletteInterior>;
MinFilter = LINEAR;
MagFilter = LINEAR;
MipFilter = NONE;
AddressU = Wrap;
AddressV = Wrap;
SRGBTexture = FALSE;
MaxMipLevel = 0;
MipMapLodBias = 0;
};
Code: Select all
#if (ENightDayFactor == 1 & EInteriorFactor == 0)
float3 palette;
color.rgb = saturate(color.rgb);
float3 brightness = Adaptation.xyz; //tex2D(_s4, 0.5);//adaptation luminance
brightness = (brightness/(brightness+1.0)); //new version
brightness = max(brightness.x, max(brightness.y, brightness.z)); //new version
float4 uvsrc = 0.0;
uvsrc.y = brightness.r;
uvsrc.x = color.r;
palette.r = tex2Dlod(SamplerPaletteDayTexture, uvsrc).r;
uvsrc.x = color.g;
uvsrc.y = brightness.g;
palette.g = tex2Dlod(SamplerPaletteDayTexture, uvsrc).g;
uvsrc.x = color.b;
uvsrc.y = brightness.b;
palette.b = tex2Dlod(SamplerPaletteDayTexture, uvsrc).b;
color.rgb = palette.rgb;
#elif (ENightDayFactor == 0 & EInteriorFactor == 0)
float3 palette;
color.rgb = saturate(color.rgb);
float3 brightness = Adaptation.xyz; //tex2D(_s4, 0.5);//adaptation luminance
brightness = (brightness/(brightness+1.0)); //new version
brightness = max(brightness.x, max(brightness.y, brightness.z)); //new version
float4 uvsrc = 0.0;
uvsrc.y = brightness.r;
uvsrc.x = color.r;
palette.r = tex2Dlod(SamplerPaletteNightTexture, uvsrc).r;
uvsrc.x = color.g;
uvsrc.y = brightness.g;
palette.g = tex2Dlod(SamplerPaletteNightTexture, uvsrc).g;
uvsrc.x = color.b;
uvsrc.y = brightness.b;
palette.b = tex2Dlod(SamplerPaletteNightTexture, uvsrc).b;
color.rgb = palette.rgb;
#elif (ENightDayFactor == 1 & EInteriorFactor == 1)
float3 palette;
color.rgb = saturate(color.rgb);
float3 brightness = Adaptation.xyz; //tex2D(_s4, 0.5);//adaptation luminance
brightness = (brightness/(brightness+1.0)); //new version
brightness = max(brightness.x, max(brightness.y, brightness.z)); //new version
float4 uvsrc = 0.0;
uvsrc.y = brightness.r;
uvsrc.x = color.r;
palette.r = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).r;
uvsrc.x = color.g;
uvsrc.y = brightness.g;
palette.g = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).g;
uvsrc.x = color.b;
uvsrc.y = brightness.b;
palette.b = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).b;
color.rgb = palette.rgb;
#elif (ENightDayFactor == 0 & EInteriorFactor == 1)
float3 palette;
color.rgb = saturate(color.rgb);
float3 brightness = Adaptation.xyz; //tex2D(_s4, 0.5);//adaptation luminance
brightness = (brightness/(brightness+1.0)); //new version
brightness = max(brightness.x, max(brightness.y, brightness.z)); //new version
float4 uvsrc = 0.0;
uvsrc.y = brightness.r;
uvsrc.x = color.r;
palette.r = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).r;
uvsrc.x = color.g;
uvsrc.y = brightness.g;
palette.g = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).g;
uvsrc.x = color.b;
uvsrc.y = brightness.b;
palette.b = tex2Dlod(SamplerPaletteInteriorTexture, uvsrc).b;
color.rgb = palette.rgb;
#endif