Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/testing/tests.features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ f3d_test(NAME TestFinalShaderNegative DATA cow.vtp ARGS --final-shader "vec4 pix
f3d_test(NAME TestFinalShaderNegativeFileName DATA cow.vtp ARGS --filename --final-shader "vec4 pixel(vec2 uv){return vec4(vec3(1.0) - texture(source, uv).rgb, 1.0)\\\\\\\;}" UI)
f3d_test(NAME TestFinalShaderUndefined DATA cow.vtp ARGS --final-shader "undefined" REGEXP "Final shader must define a function" NO_BASELINE)
f3d_test(NAME TestFinalShaderCompilationFailure DATA cow.vtp ARGS --final-shader "vec4 pixel(vec2 uv){}" --verbose REGEXP " build the shader program" NO_BASELINE)
f3d_test(NAME TestFinalShaderTimeUniform DATA cow.vtp ARGS --final-shader "vec4 pixel(vec2 uv){return vec4(texture(source, uv).rgb * (0.5 + 0.5*cos(time+uv.xyx+vec3(0,2,4))), 1.0)\\\\\\\;}")
Comment thread
mwestphal marked this conversation as resolved.

## Command Script
f3d_test(NAME TestCommandScriptBasic SCRIPT DATA dragon.vtu) # roll_camera 90;toggle ui.scalar_bar;print_scene_info;increase_light_intensity
Expand Down
3 changes: 3 additions & 0 deletions testing/baselines/TestFinalShaderTimeUniform.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions vtkext/private/module/vtkF3DUserRenderPass.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "vtkF3DUserRenderPass.h"

#include "vtkF3DRenderer.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLError.h"
#include "vtkOpenGLFramebufferObject.h"
Expand All @@ -25,6 +26,7 @@ void vtkF3DUserRenderPass::Render(const vtkRenderState* s)
vtkRenderer* r = s->GetRenderer();
Comment thread
mwestphal marked this conversation as resolved.
vtkOpenGLRenderWindow* renWin = static_cast<vtkOpenGLRenderWindow*>(r->GetRenderWindow());
vtkOpenGLState* ostate = renWin->GetState();
vtkF3DRenderer* ren = vtkF3DRenderer::SafeDownCast(r);
Comment thread
mwestphal marked this conversation as resolved.

vtkOpenGLState::ScopedglEnableDisable bsaver(ostate, GL_BLEND);
vtkOpenGLState::ScopedglEnableDisable dsaver(ostate, GL_DEPTH_TEST);
Expand Down Expand Up @@ -71,6 +73,7 @@ void vtkF3DUserRenderPass::Render(const vtkRenderState* s)
vtkShaderProgram::Substitute(FSSource, "//VTK::FSQ::Decl",
"uniform sampler2D source;\n"
"uniform ivec2 resolution;\n"
"uniform float time;\n"
"//VTK::FSQ::Decl");

vtkShaderProgram::Substitute(FSSource, "//VTK::FSQ::Decl", this->UserShader);
Expand All @@ -97,6 +100,15 @@ void vtkF3DUserRenderPass::Render(const vtkRenderState* s)
this->QuadHelper->Program->SetUniformi("source", this->ColorTexture->GetTextureUnit());
this->QuadHelper->Program->SetUniform2i("resolution", size);

if (!ren)
{
this->QuadHelper->Program->SetUniformf("time", 0);
}
else
{
this->QuadHelper->Program->SetUniformf("time", ren->GetTotalTime());
}

ostate->vtkglDisable(GL_BLEND);
ostate->vtkglDisable(GL_DEPTH_TEST);
ostate->vtkglClear(GL_DEPTH_BUFFER_BIT);
Expand Down
Loading