//**************************************************************************/ // Copyright (c) 2012 Autodesk, Inc. // All rights reserved. // // These coded instructions, statements, and computer programs contain // unpublished proprietary information written by Autodesk, Inc., and are // protected by Federal copyright law. They may not be disclosed to third // parties or copied or duplicated in any form, in whole or in part, without // the prior written consent of Autodesk, Inc. //**************************************************************************/ // // Compiled Fragment: mayaLinearMotionBlur___ambientShader_distantLight // ////////////////////// // mayaLinearMotionBlur___ambientShader_distantLight_VS struct vertexInS { float3 Pm : POSITION; float2 u0 : TEXCOORD0; }; // Declarations struct vertexOutS { float4 Pc : POSITION; float3 u0 : TEXCOORD0; }; struct fragInS { float4 Pc : POSITION; float3 u0 : TEXCOORD0; }; // Globals //uniform float DepthPriority : depthpriority; uniform float4x4 WorldViewProj : worldviewprojection; // Fragments float4 iPcQuad( float3 pm, /*float depthPriority,*/ float4x4 worldViewProjectionC ) { float4 Pc = mul( worldViewProjectionC, float4(pm, 1.0f) ); return Pc; //float3 P = 2.0f * pm - 1.0f; //return float4(P, 1.0f); } float3 iU0( float2 u0 ) { return float3(u0, 0); } // Vertex Shader vertexOutS mayaLinearMotionBlur___ambientShader_distantLight_VS( vertexInS inputs ) { // ShaderBody vertexOutS s_fragInS1641; s_fragInS1641.Pc = iPcQuad ( inputs.Pm, /*DepthPriority,*/ WorldViewProj ); s_fragInS1641.u0 = iU0 ( inputs.u0 ); return s_fragInS1641; } ////////////////////// // mayaLinearMotionBlur___ambientShader_distantLight // Globals //uniform float3 u0 : u0; uniform texture2D currentScene; uniform sampler2D currentSceneSampler = sampler_state { Texture = ; }; uniform texture2D currentVelocity; uniform sampler2D currentVelocitySampler = sampler_state { Texture = ; }; uniform texture2D previousScene; uniform sampler2D previousSceneSampler = sampler_state { Texture = ; }; uniform float shutterOpenFraction = 1.000000; uniform float zThreshold = 0.100000; uniform int blurStepCount = 16; uniform float motionFadeAmt = 0.0; uniform float motionFadeEmphasis = 0.0; uniform float4 motionFadeTint = (float4)1; // Fragments float4 mayaMotionFade( float amt, float emphasis, float4 tint, float t ) { return (float4)1; // uses emphasis [-1..+1] as slope, centered about 0.5. this computes both a & b. //float2 ab = 0.5 + emphasis * float2( 0.5, -0.5 ); // get the weight & the tint by smoothstep //float st = smoothstep( 0, 1, t ); //float4 s = lerp( float4(1,1,1,ab.x), float4( tint.xyz, ab.y ), st ); // blend between no-fade & computed fade color & weight to get final multiplier //return lerp( (float4)1, float4(s.w * s.xyz, s.w), amt ); } float4 mayaLinearMotionBlur( float3 pixelUV, sampler2D curSceneSamp, texture2D curScene, sampler2D curVelocitySamp, texture2D curVel, sampler2D prevSceneSamp, texture2D prevScene, float shutterOpen, float zThreshold, int nBlurSteps, float fadeAmt, float fadeEmphasis, float4 fadeTint ) { float4 V0 = tex2D( curVelocitySamp, pixelUV.xy ); float4 bg = (V0.w > 0)? tex2D( prevSceneSamp, pixelUV.xy ) : tex2D( curSceneSamp, pixelUV.xy ); float z0 = V0.z; float2 dUV = V0.xy * shutterOpen / (float)nBlurSteps; float4 clr = (float4)0; for( int n = 0; n < nBlurSteps; ++n ) { float2 sampleUV = pixelUV.xy + n * dUV; float4 Vn = tex2D( curVelocitySamp, sampleUV ); float4 fg = tex2D( curSceneSamp, sampleUV ); bool includeSample = (Vn.w > 0); // && (abs(z0-Vn.z) < zThreshold); clr += includeSample ? fg : bg; } return clr / (float)nBlurSteps; } // Pixel Shader float4 mayaLinearMotionBlur___ambientShader_distantLight( fragInS inputs ) : COLOR0 { // ShaderBody float4 v_mayaLinearMotionBlur1639 = mayaLinearMotionBlur( inputs.u0, currentSceneSampler, currentScene, currentVelocitySampler, currentVelocity, previousSceneSampler, previousScene, shutterOpenFraction, zThreshold, blurStepCount, motionFadeAmt, motionFadeEmphasis, motionFadeTint ); return v_mayaLinearMotionBlur1639; } /////////////////////// Techniques /////// technique main { pass P0 { VertexProgram = compile glslv mayaLinearMotionBlur___ambientShader_distantLight_VS(); FragmentProgram = compile glslf mayaLinearMotionBlur___ambientShader_distantLight(); } }