GLSL Shader 笔记
float EncodeShadingModelIdAndSelectiveOutputMask(uint ShadingModelId, uint SelectiveOutputMask) { uint Value = (ShadingModelId & SHADINGMODELID_MASK) | SelectiveOutputMask; return (float)Value / (float)0xFF; } uint DecodeShadingModelId(float InPackedChannel) { return ((uint)round(InPackedChannel * (float)0xFF)) & SHADINGMODELID_MASK; } uint DecodeSelectiveOutputMask(float InPackedChannel) { return ((uint)round(InPackedChannel * (float)0xFF)) & ~SHADINGMODELID_MASK; }
UE4的把float 转uint,或者uint转float代码
float Luminance(vec3 color) { return dot(color,vec3(0.299f, 0.587f, 0.114f)); }
这是神秘海域的tonemap公式: vec3 ACESFilm(vec3 x ) { float a = 2.51f; float b = 0.03f; float c = 2.43f; float d = 0.59f; float e = 0.14f; return saturate((x*(a*x+b))/(x*(c*x+d)+e)); }