<commit_before>//
//	Copyright (c) 2014 <NAME>, sansumbrella.com
//	All rights reserved.
//
//	Velocity buffer blur sample application.
//	Motion blur based on the following NVIDIA papers:
//	http://graphics.cs.williams.edu/papers/MotionBlurI3D12/
//	http://graphics.cs.williams.edu/papers/MotionBlur13/
//
//	Author: <NAME>
//	License: BSD Simplified
//

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"

#include "cinder/gl/gl.h"
#include "cinder/gl/Texture.h"
#include "cinder/gl/VboMesh.h"
#include "cinder/gl/Fbo.h"
#include "cinder/gl/GlslProg.h"
#include "cinder/gl/Context.h"
#include "cinder/gl/Query.h"

#include "cinder/GeomIo.h"
#include "cinder/Rand.h"

#include "cinder/Log.h"
#include "cinder/params/Params.h"

#include "BlurrableThings.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class MotionBlurVelocityBufferApp : public App {
  public:
	void setup() override;
	void keyDown( KeyEvent event ) override;
	void update() override;
	void draw() override;

	void createGeometry();
	void createBuffers();
	void loadShaders();

	// Render color and velocity into GBuffer FBO.
	void fillGBuffer();
	// Dilate velocity into VelocityDilationBuffer for use by blur shader.
	void dilateVelocity();
	// Draw final blurred content to screen.
	void drawBlurredContent();
	// Draw velocity buffers to screen for debugging/look under the hood.
	void drawVelocityBuffers();

  private:
	gl::TextureRef					mBackground;
	std::vector<BlurrableMeshRef>	mMeshes;

	gl::GlslProgRef	mVelocityProg;		// Renders RGBA color and screen-space velocity.
	gl::GlslProgRef	mTileProg;			// Downsamples velocity, preserving local maxima
	gl::GlslProgRef	mNeighborProg;		// Finds dominant velocities in downsampled map
	gl::GlslProgRef	mMotionBlurProg;	// Generates final image from color and velocity buffers

	gl::GlslProgRef	mVelocityRenderProg;		// Debug rendering of velocity to screen.

	gl::FboRef		mGBuffer;					// Full-resolution RGBA color and velocity.
	gl::FboRef		mVelocityDilationBuffer;	// Dilated, downsampled velocity and dominant region velocities.
	// Name our framebuffer attachment points.
	const GLenum G_COLOR			        = GL_COLOR_ATTACHMENT0;
	const GLenum G_VELOCITY		        = GL_COLOR_ATTACHMENT1;
	const GLenum DILATE_TILE_MAX		  = GL_COLOR_ATTACHMENT0;
	const GLenum DILATE_NEIGHBOR_MAX	= GL_COLOR_ATTACHMENT1;

	gl::QueryTimeSwappedRef mGpuTimer;
	Timer					mCpuTimer;
	float					mAverageGpuTime = 0.0f;
	float					mAverageCpuTime = 0.0f;

	params::InterfaceGlRef	mParams;
	int						mTileSize = 20;		// TileMax program samples a TileSize x TileSize region of pixels for each of its output pixels.
	int						mSampleCount = 31;	// Number of samples used when calculating motion blur. Low-movement areas skip calculation.
	float					mAnimationSpeed = 1.0f;
	float					mBlurNoise = 0.0f;
	bool					mBlurEnabled = true;
	bool					mPaused = false;
	bool					mDisplayVelocityBuffers = true;
};

void MotionBlurVelocityBufferApp::setup()
{
	mBackground = gl::Texture::create( loadImage( loadAsset( "background.jpg" ) ) );<commit_msg>Fix tab/space confusion from editing on PC.<commit_after>//
//	Copyright (c) 2014 <NAME>, sansumbrella.com
//	All rights reserved.
//
//	Velocity buffer blur sample application.
//	Motion blur based on the following NVIDIA papers:
//	http://graphics.cs.williams.edu/papers/MotionBlurI3D12/
//	http://graphics.cs.williams.edu/papers/MotionBlur13/
//
//	Author: <NAME>
//	License: BSD Simplified
//

#include "cinder/app/App.h"
#include "cinder/app/RendererGl.h"

#include "cinder/gl/gl.h"
#include "cinder/gl/Texture.h"
#include "cinder/gl/VboMesh.h"
#include "cinder/gl/Fbo.h"
#include "cinder/gl/GlslProg.h"
#include "cinder/gl/Context.h"
#include "cinder/gl/Query.h"

#include "cinder/GeomIo.h"
#include "cinder/Rand.h"

#include "cinder/Log.h"
#include "cinder/params/Params.h"

#include "BlurrableThings.h"

using namespace ci;
using namespace ci::app;
using namespace std;

class MotionBlurVelocityBufferApp : public App {
  public:
	void setup() override;
	void keyDown( KeyEvent event ) override;
	void update() override;
	void draw() override;

	void createGeometry();
	void createBuffers();
	void loadShaders();

	// Render color and velocity into GBuffer FBO.
	void fillGBuffer();
	// Dilate velocity into VelocityDilationBuffer for use by blur shader.
	void dilateVelocity();
	// Draw final blurred content to screen.
	void drawBlurredContent();
	// Draw velocity buffers to screen for debugging/look under the hood.
	void drawVelocityBuffers();

  private:
	gl::TextureRef					mBackground;
	std::vector<BlurrableMeshRef>	mMeshes;

	gl::GlslProgRef	mVelocityProg;		// Renders RGBA color and screen-space velocity.
	gl::GlslProgRef	mTileProg;			// Downsamples velocity, preserving local maxima
	gl::GlslProgRef	mNeighborProg;		// Finds dominant velocities in downsampled map
	gl::GlslProgRef	mMotionBlurProg;	// Generates final image from color and velocity buffers

	gl::GlslProgRef	mVelocityRenderProg;		// Debug rendering of velocity to screen.

	gl::FboRef		mGBuffer;					// Full-resolution RGBA color and velocity.
	gl::FboRef		mVelocityDilationBuffer;	// Dilated, downsampled velocity and dominant region velocities.
	// Name our framebuffer attachment points.
	const GLenum G_COLOR				= GL_COLOR_ATTACHMENT0;
	const GLenum G_VELOCITY				= GL_COLOR_ATTACHMENT1;
	const GLenum DILATE_TILE_MAX		= GL_COLOR_ATTACHMENT0;
	const GLenum DILATE_NEIGHBOR_MAX	= GL_COLOR_ATTACHMENT1;

	gl::QueryTimeSwappedRef mGpuTimer;
	Timer					mCpuTimer;
	float					mAverageGpuTime = 0.0f;
	float					mAverageCpuTime = 0.0f;

	params::InterfaceGlRef	mParams;
	int						mTileSize = 20;		// TileMax program samples a TileSize x TileSize region of pixels for each of its output pixels.
	int						mSampleCount = 31;	// Number of samples used when calculating motion blur. Low-movement areas skip calculation.
	float					mAnimationSpeed = 1.0f;
	float					mBlurNoise = 0.0f;
	bool					mBlurEnabled = true;
	bool					mPaused = false;
	bool					mDisplayVelocityBuffers = true;
};

void MotionBlurVelocityBufferApp::setup()
{
	mBackground = gl::Texture::create( loadImage( loadAsset( "background.jpg" ) ) );
{'fraction_non_alphanumeric': 0.10173335493277175, 'fraction_numerical': 0.008099789405475458, 'mean_word_length': 4.179530201342282, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3230911', 'n_tokens_mistral': 2327, 'n_tokens_neox': 2144, 'n_words': 570}