Files
OCCT/src/Shaders/RaytraceSmooth.fs
ski ee5befae97 0027258: Configuration - generate built-in replacement for mandatory resource files
Generation of header files from resource files was added to CMake and genproj procedures.

Message_MsgFile has been extended with new method ::LoadFromString()
for loading messages from embedded resources.
Message_MsgFile::LoadFromString() is now a preferred way
for loading message resources by application
as alternative to environment variables.

TObje/TObj.msg is now embedded into TObj_Application.cxx.
TObj_Application now loads its global messages
on instantiation of the first class instance.

UnitsAPI/Lexi_Expr.dat now completely embedded into Units_Lexicon.cxx.
UnitsAPI/Units.dat now embedded into Units_UnitsDictionary.cxx
but can be regenerated from resource file.
The definition of the following units have been removed:
benne à charbon, calorie (diététique).

Unused message files XSMessage/IGES.us and IGES.fr have been removed.
Related code IGESData.cxx has been removed as well.

XSMessage/XSTEP.us is now embedded into Interface_StaticStandards.cxx
and used for fallback initialization in case when file resources
defined by CSF_XSMessage environment variable are missing.

SHMessage/SHAPE.us is now embedded into ShapeExtend.cxx
and used for fallback initialization in case when file resources
defined by CSF_XHMessage environment variable are missing.
Duplicating code has been removed from ShapeProcess_OperLibrary.cxx.

Shaders/Declarations.glsl and Shaders/DeclarationsImpl.glsl
are now embedded into OpenGl_ShaderProgram.cxx.
CSF_ShadersDirectory is no more required for using OCCT 3D Viewer.

Ray-Tracing GLSL programs from Shaders are now embedded into OpenGl_View_Raytrace.cxx.
File resources are still used instead of embedded programs
when CSF_ShadersDirectory is defined, but this functionality
is intended for OCCT development.

Enumeration Graphic3d_ShaderProgram::ShaderName_Phong
demonstrating custom GLSL program usage has been removed.
2016-10-28 14:30:28 +03:00

81 lines
3.0 KiB
GLSL

//! Input ray-traced image.
uniform sampler2D uFSAAInputTexture;
//! Number of accumulated FSAA samples.
uniform int uSamples;
//! Output pixel color.
out vec4 OutColor;
#define LUM_DIFFERENCE 0.085f
// =======================================================================
// function : main
// purpose :
// =======================================================================
void main (void)
{
#ifndef PATH_TRACING
int aPixelX = int (gl_FragCoord.x);
int aPixelY = int (gl_FragCoord.y);
// Adjust FLIPTRI pattern used for adaptive FSAA
float anOffsetX = mix (uOffsetX, -uOffsetX, float (aPixelX % 2));
float anOffsetY = mix (uOffsetY, -uOffsetY, float (aPixelY % 2));
vec4 aClr0 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 0, aPixelY + 0), 0);
vec4 aClr1 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 0, aPixelY - 1), 0);
vec4 aClr2 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 0, aPixelY + 1), 0);
vec4 aClr3 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 1, aPixelY + 0), 0);
vec4 aClr4 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 1, aPixelY - 1), 0);
vec4 aClr5 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX + 1, aPixelY + 1), 0);
vec4 aClr6 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX - 1, aPixelY + 0), 0);
vec4 aClr7 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX - 1, aPixelY - 1), 0);
vec4 aClr8 = texelFetch (uFSAAInputTexture, ivec2 (aPixelX - 1, aPixelY + 1), 0);
float aLum = dot (LUMA, aClr0.xyz);
bool aRender = abs (aClr1.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr2.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr3.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr4.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr5.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr6.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr7.w - aClr0.w) > LUM_DIFFERENCE ||
abs (aClr8.w - aClr0.w) > LUM_DIFFERENCE;
if (!aRender)
{
aRender = abs (dot (LUMA, aClr1.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr2.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr3.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr4.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr5.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr6.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr7.xyz) - aLum) > LUM_DIFFERENCE ||
abs (dot (LUMA, aClr8.xyz) - aLum) > LUM_DIFFERENCE;
}
vec4 aColor = aClr0;
if (aRender)
{
SRay aRay = GenerateRay (vPixel + vec2 (anOffsetX, anOffsetY));
vec3 aInvDirect = 1.f / max (abs (aRay.Direct), SMALL);
aInvDirect = vec3 (aRay.Direct.x < 0.f ? -aInvDirect.x : aInvDirect.x,
aRay.Direct.y < 0.f ? -aInvDirect.y : aInvDirect.y,
aRay.Direct.z < 0.f ? -aInvDirect.z : aInvDirect.z);
aColor = mix (aClr0, clamp (Radiance (aRay, aInvDirect), 0.f, 1.f), 1.f / uSamples);
}
OutColor = aColor;
#endif
}