/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != DrawVelocityParticles_LinesGpuTex.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc0));
			// Assign pixel shader textures and samplers
			if ((ic | this.vtc))
			{
				state.SetVertexShaderSamplers(this.vtx, this.vts);
				this.vtc = false;
			}
			if ((this.vreg_change == true))
			{
				DrawVelocityParticles_LinesGpuTex.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref DrawVelocityParticles_LinesGpuTex.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != DepthOutRg.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			this.vbreg_change = (this.vbreg_change | ic);
			this.vireg_change = (this.vireg_change | ic);
			// Set the value for attribute 'cameraNearFar'
			this.vreg_change = (this.vreg_change | state.SetCameraNearFarVector2(ref this.vreg[9], ref this.sc0));
			// Set the value for attribute 'viewDirection'
			this.vreg_change = (this.vreg_change | state.SetViewDirectionVector3(ref this.vreg[7], ref this.sc1));
			// Set the value for attribute 'viewPoint'
			this.vreg_change = (this.vreg_change | state.SetViewPointVector3(ref this.vreg[8], ref this.sc2));
			Microsoft.Xna.Framework.Vector4 unused = new Microsoft.Xna.Framework.Vector4();
			// Set the value for attribute 'worldMatrix'
			this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref unused, ref this.sc3));
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc4));
			if ((this.vreg_change == true))
			{
				DepthOutRg.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending))
			{
				ic = (ic | state.SetBlendMatricesDirect(DepthOutRg.fx.vsb_c, ref this.sc5));
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing))
			{
				this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc6));
				if ((this.vireg_change == true))
				{
					DepthOutRg.fx.vsi_c.SetValue(this.vireg);
					this.vireg_change = false;
					ic = true;
				}
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref DepthOutRg.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != Tutorial16.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			this.preg_change = (this.preg_change | ic);
			this.vbreg_change = (this.vbreg_change | ic);
			this.vireg_change = (this.vireg_change | ic);
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc0));
			// Set the value for global 'colour'
			this.preg_change = (this.preg_change | state.SetGlobalVector4(ref this.preg[0], Tutorial16.gid0, ref this.gc0));
			if ((this.vreg_change == true))
			{
				Tutorial16.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			if ((this.preg_change == true))
			{
				Tutorial16.fx.ps_c.SetValue(this.preg);
				this.preg_change = false;
				ic = true;
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending))
			{
				ic = (ic | state.SetBlendMatricesDirect(Tutorial16.fx.vsb_c, ref this.sc1));
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing))
			{
				this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc2));
				if ((this.vireg_change == true))
				{
					Tutorial16.fx.vsi_c.SetValue(this.vireg);
					this.vireg_change = false;
					ic = true;
				}
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref Tutorial16.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != ShadowShader.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			this.vbreg_change = (this.vbreg_change | ic);
			this.vireg_change = (this.vireg_change | ic);
			// Set the value for attribute 'worldMatrix'
			this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[8], ref this.vreg[9], ref this.vreg[10], ref this.vreg[11], ref this.sc0));
			// Set the value for attribute 'worldViewProjection'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc1));
			// Assign pixel shader textures and samplers
			if ((ic | this.ptc))
			{
				state.SetPixelShaderSamplers(this.ptx, this.pts);
				this.ptc = false;
			}
			if ((this.vreg_change == true))
			{
				ShadowShader.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending))
			{
				ic = (ic | state.SetBlendMatricesDirect(ShadowShader.fx.vsb_c, ref this.sc2));
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing))
			{
				this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc3));
				if ((this.vireg_change == true))
				{
					ShadowShader.fx.vsi_c.SetValue(this.vireg);
					this.vireg_change = false;
					ic = true;
				}
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref ShadowShader.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != DrawVelocityBillboardParticles_GpuTex3D.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			// Set the value for attribute 'viewPoint'
			this.vreg_change = (this.vreg_change | state.SetViewPointVector3(ref this.vreg[7], ref this.sc0));
			Microsoft.Xna.Framework.Vector4 unused = new Microsoft.Xna.Framework.Vector4();
			// Set the value for attribute 'worldMatrix'
			this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref unused, ref this.sc1));
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc2));
			// Assign pixel shader textures and samplers
			if ((ic | this.ptc))
			{
				state.SetPixelShaderSamplers(this.ptx, this.pts);
				this.ptc = false;
			}
			// Assign pixel shader textures and samplers
			if ((ic | this.vtc))
			{
				state.SetVertexShaderSamplers(this.vtx, this.vts);
				this.vtc = false;
			}
			if ((this.vreg_change == true))
			{
				DrawVelocityBillboardParticles_GpuTex3D.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref DrawVelocityBillboardParticles_GpuTex3D.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != ParticleStoreLife128.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			if ((this.vreg_change == true))
			{
				ParticleStoreLife128.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref ParticleStoreLife128.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != DrawGraphLine.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[200], ref this.vreg[201], ref this.vreg[202], ref this.vreg[203], ref this.sc0));
			if ((this.vreg_change == true))
			{
				DrawGraphLine.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref DrawGraphLine.fx, ext);
			}
		}
		/// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
		protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			// if the device changed, call Warm()
			if ((state.DeviceUniqueIndex != RgbmDecode.gd))
			{
				this.WarmShader(state);
				ic = true;
			}
			// Force updating if the instance has changed
			this.vreg_change = (this.vreg_change | ic);
			this.preg_change = (this.preg_change | ic);
			this.vbreg_change = (this.vbreg_change | ic);
			this.vireg_change = (this.vireg_change | ic);
			// Set the value for attribute 'worldViewProj'
			this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.sc0));
			// Set the value for global 'BloomScaleThreshold'
			this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[1], RgbmDecode.gid0, ref this.gc0));
			// Set the value for global 'LensExposure'
			this.preg_change = (this.preg_change | state.SetGlobalSingle(ref this.preg[2], RgbmDecode.gid1, ref this.gc1));
			// Set the value for global 'RgbmImageRenderScale'
			this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[0], RgbmDecode.gid2, ref this.gc2));
			// Assign pixel shader textures and samplers
			if ((ic | this.ptc))
			{
				state.SetPixelShaderSamplers(this.ptx, this.pts);
				this.ptc = false;
			}
			if ((this.vreg_change == true))
			{
				RgbmDecode.fx.vs_c.SetValue(this.vreg);
				this.vreg_change = false;
				ic = true;
			}
			if ((this.preg_change == true))
			{
				RgbmDecode.fx.ps_c.SetValue(this.preg);
				this.preg_change = false;
				ic = true;
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending))
			{
				ic = (ic | state.SetBlendMatricesDirect(RgbmDecode.fx.vsb_c, ref this.sc1));
			}
			if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing))
			{
				this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc2));
				if ((this.vireg_change == true))
				{
					RgbmDecode.fx.vsi_c.SetValue(this.vireg);
					this.vireg_change = false;
					ic = true;
				}
			}
			// Finally, bind the effect
			if ((ic | ec))
			{
				state.SetEffect(this, ref RgbmDecode.fx, ext);
			}
		}
Esempio n. 9
0
 /// <summary>Bind the shader, 'ic' indicates the shader instance has changed and 'ec' indicates the extension has changed.</summary><param name="state"/><param name="ic"/><param name="ec"/><param name="ext"/>
 protected override void BeginImpl(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
 {
     // if the device changed, call Warm()
     if ((state.DeviceUniqueIndex != Character.gd))
     {
         this.WarmShader(state);
         ic = true;
     }
     // Force updating if the instance has changed
     this.vreg_change = (this.vreg_change | ic);
     this.preg_change = (this.preg_change | ic);
     this.vbreg_change = (this.vbreg_change | ic);
     this.vireg_change = (this.vireg_change | ic);
     // Set the value for attribute 'viewPoint'
     this.vreg_change = (this.vreg_change | state.SetViewPointVector4(ref this.vreg[12], ref this.sc0));
     // Set the value for attribute 'world'
     this.vreg_change = (this.vreg_change | state.SetWorldMatrix(ref this.vreg[8], ref this.vreg[9], ref this.vreg[10], ref this.vreg[11], ref this.sc1));
     // Set the value for attribute 'worldViewProj'
     this.vreg_change = (this.vreg_change | state.SetWorldViewProjectionMatrix(ref this.vreg[4], ref this.vreg[5], ref this.vreg[6], ref this.vreg[7], ref this.sc2));
     // Set the value for global 'ShadowMapProjection'
     this.vreg_change = (this.vreg_change | state.SetGlobalMatrix4(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], Character.gid0, ref this.gc0));
     // Set the value for global 'AmbientDiffuseSpecularScale'
     this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[15], Character.gid1, ref this.gc1));
     // Set the value for global 'EnvironmentSH'
     this.preg_change = (this.preg_change | state.SetGlobalVector4(this.preg, 0, 9, Character.gid2, ref this.gc2));
     // Set the value for global 'RgbmImageRenderScale'
     this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[9], Character.gid3, ref this.gc3));
     // Set the value for global 'ShadowMapSize'
     this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[10], Character.gid4, ref this.gc4));
     // Set the value for global 'SkinLightScatter'
     this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[11], Character.gid5, ref this.gc5));
     // Set the value for global 'SunDirection'
     this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[13], Character.gid6, ref this.gc6));
     // Set the value for global 'SunRgbIntensity'
     this.preg_change = (this.preg_change | state.SetGlobalVector4(ref this.preg[12], Character.gid7, ref this.gc7));
     // Set the value for global 'SunSpecularPowerIntensity'
     this.preg_change = (this.preg_change | state.SetGlobalVector2(ref this.preg[14], Character.gid8, ref this.gc8));
     // Set the value for global 'UseAlbedoOcclusionShadow'
     this.preg_change = (this.preg_change | state.SetGlobalVector3(ref this.preg[16], Character.gid9, ref this.gc9));
     // Assign global textures
     this.CubeRgbmTexture = state.GetGlobalTextureCube(Character.tid0);
     this.ShadowTexture = state.GetGlobalTexture2D(Character.tid1);
     // Assign pixel shader textures and samplers
     if ((ic | this.ptc))
     {
         state.SetPixelShaderSamplers(this.ptx, this.pts);
         this.ptc = false;
     }
     if ((this.vreg_change == true))
     {
         Character.fx.vs_c.SetValue(this.vreg);
         this.vreg_change = false;
         ic = true;
     }
     if ((this.preg_change == true))
     {
         Character.fx.ps_c.SetValue(this.preg);
         this.preg_change = false;
         ic = true;
     }
     if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Blending))
     {
         ic = (ic | state.SetBlendMatricesDirect(Character.fx.vsb_c, ref this.sc3));
     }
     if ((ext == Xen.Graphics.ShaderSystem.ShaderExtension.Instancing))
     {
         this.vireg_change = (this.vireg_change | state.SetViewProjectionMatrix(ref this.vireg[0], ref this.vireg[1], ref this.vireg[2], ref this.vireg[3], ref this.sc4));
         if ((this.vireg_change == true))
         {
             Character.fx.vsi_c.SetValue(this.vireg);
             this.vireg_change = false;
             ic = true;
         }
     }
     // Finally, bind the effect
     if ((ic | ec))
     {
         state.SetEffect(this, ref Character.fx, ext);
     }
 }
		public void Begin(Xen.Graphics.ShaderSystem.ShaderSystemBase state, bool ic, bool ec, Xen.Graphics.ShaderSystem.ShaderExtension ext)
		{
			if (device != state.DeviceUniqueIndex)
			{
				device = state.DeviceUniqueIndex;

				fx.Dispose();
				state.CreateEffect(out fx, fxb, 0, 0);
			}

			float randX = (float)(random.NextDouble());
			float randY = (float)(random.NextDouble());

			this.psConstants[4].Z = randX;
			this.psConstants[4].W = randY;

			//random texture is limited in size, so randomly offset by a tiny amount
			randX = (float)((random.NextDouble() * 2 - 1) / 256.0);
			randY = (float)((random.NextDouble() * 2 - 1) / 256.0);

			this.psConstants[5].X = randX;
			this.psConstants[5].Y = randY;

			TextureSamplerState point = TextureSamplerState.PointFiltering;

			Xen.Graphics.ShaderSystem.ShaderSystemBase shaderSystem = (Xen.Graphics.ShaderSystem.ShaderSystemBase)state;
			shaderSystem.SetPixelShaderSampler(0, randTexture, point);

			if (positionSize != null)
				shaderSystem.SetPixelShaderSampler(1, positionSize, point);
			if (velocityRotation != null)
				shaderSystem.SetPixelShaderSampler(2, velocityRotation, point);
			
			if (this.colourSamplerIndex != -1)
				shaderSystem.SetPixelShaderSampler(this.colourSamplerIndex, colourValues, point);
			
			if (this.userSamplerIndex != -1)
				shaderSystem.SetPixelShaderSampler(this.userSamplerIndex, userValues, point);

			if (this.lifeSamplerIndex != -1)
				shaderSystem.SetPixelShaderSampler(this.lifeSamplerIndex, lifeTexture, point);


			state.SetWorldViewProjectionMatrix(ref this.vreg[0], ref this.vreg[1], ref this.vreg[2], ref this.vreg[3], ref this.world);

			const float randTextureSize = (float)RandomValueTexture.Resolution;
			const float invRandTextureSize = 1.0f / randTextureSize; 

			if (enabledMoveVS || enabledAddVS)
			{
				for (int i = 0; i < 4; i++) //copy the WVP matrix
					this.vsMoveConstants[i] = this.vreg[i];

				vsMoveConstants[6] = new Vector4(randTextureSize, invRandTextureSize, 0, 0);
				
				fx.vs_c.SetValue(this.vsMoveConstants);
				fx.ps_c.SetValue(psConstants);
			}
			else
			{
				state.SetWindowSizeVector2(ref this.vreg[4], ref this.viewsize);
				this.vreg[6] = new Vector4(randTextureSize, invRandTextureSize, 0, 0);
				
				fx.vs_c.SetValue(this.vreg);
				fx.ps_c.SetValue(psConstants);
			}

			state.SetEffect(this, ref fx, Xen.Graphics.ShaderSystem.ShaderExtension.None);
		}