3#include <vtkImageData.h>
4#include <vtkInformation.h>
5#include <vtkObjectFactory.h>
16 return std::string(R
"(
17//VTK::System::Dec // always start with these lines in your FS
18//VTK::Output::Dec // always start with these lines in your FS
20// #extension GL_OES_standard_derivatives : enable
24uniform sampler2D tex0; // color
25uniform sampler2D tex1; // depth
26uniform sampler2D tex2; // ao
28float readDepth( const in vec2 coord ){
29 return texture2D( tex1, coord ).r;
33 vec3 color = texture2D( tex0, vPos.xy ).rgb;
34 float ao = texture2D( tex2, vPos.xy ).r;
35 float depth = readDepth(vPos.xy);
38 vec3 lumcoeff = vec3( 0.299, 0.587, 0.114 );
39 vec3 luminance = vec3( dot( color, lumcoeff ) );
42 vec2 pixelSize = 1./cResolution;
43 vec3 eps = 2.0*vec3( pixelSize.x, pixelSize.y, 0 );
44 float depthN = readDepth(vPos.xy + eps.zy);
45 float depthE = readDepth(vPos.xy + eps.xz);
46 float depthS = readDepth(vPos.xy - eps.zy);
47 float depthW = readDepth(vPos.xy - eps.xz);
49 float dxdz = abs(depthE-depthW);
50 float dydz = abs(depthN-depthS);
51 // float dxdz = dFdx(depth);
52 // float dydz = dFdy(depth);
54 vec3 n = normalize( vec3(dxdz, dydz, 1./cStrength) );
55 vec3 lightPos = vec3(0,0,1);
56 float lightInt = 1.0*dot(n,normalize(lightPos));
58 vec3 outputColor = vec3( color * mix( vec3(ao), vec3(1.0), luminance * cLuminance ) );
60 outputColor = outputColor*cAmbient + outputColor*lightInt;
62 gl_FragColor = vec4(outputColor, depth>0.99 ? 0.0 : 1.0);
68 vtkInformationVector **inputVector,
69 vtkInformationVector *outputVector) {
71 auto inputImage = vtkImageData::GetData(inputVector[0]);
72 auto outputImage = vtkImageData::GetData(outputVector);
73 outputImage->ShallowCopy(inputImage);
88 this->
Render(outputImage,
"IBS");
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
std::string GetFragmentShaderCode() override
~ttkCinemaDarkroomIBS() override
int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override
Base Class for all CinemaDarkroom Shaders.
virtual int Render(vtkImageData *image, const std::string &name)
int InitRenderer(vtkImageData *outputImage)
int AddTexture(vtkImageData *image, int arrayIdx, int textureIdx)
int AddReplacement(const std::string &name, const std::vector< double > &values, const bool &isInt=false)
void setDebugMsgPrefix(const std::string &prefix)
vtkStandardNewMacro(ttkCinemaDarkroomIBS)