瀏覽代碼

Fixed the pixel shaders to use the correct addressing with registers _sX and it all seems to be ok. Still might be a little problem with the shaders themselves

Kenneth Pouncey 14 年之前
父節點
當前提交
991bad9ddf

+ 41 - 44
Samples/MacOS/NetRumble/BloomPostprocess/BloomComponent.cs

@@ -93,9 +93,6 @@ namespace NetRumble
 			bloomExtractEffect = content.Load<Effect>("Effects/BloomExtract");
 			bloomCombineEffect = content.Load<Effect>("Effects/BloomCombine");
 			gaussianBlurEffect = content.Load<Effect>("Effects/GaussianBlur");
-            //bloomExtractEffect = new BloomExtractEffect(GraphicsDevice);
-            //bloomCombineEffect = new BloomCombineEffect(GraphicsDevice);
-            //gaussianBlurEffect = new GaussianBlurEffect(GraphicsDevice);
 
             // Look up the resolution and format of our main backbuffer.
             PresentationParameters pp = GraphicsDevice.PresentationParameters;
@@ -150,56 +147,56 @@ namespace NetRumble
         /// </summary>
         public override void Draw(GameTime gameTime)
         {
-//            GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
-//
-//            // Pass 1: draw the scene into rendertarget 1, using a
-//            // shader that extracts only the brightest parts of the image.
-//            bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
-//                Settings.BloomThreshold);
-//
-//            DrawFullscreenQuad(sceneRenderTarget, renderTarget1,
-//                               bloomExtractEffect,
-//                               IntermediateBuffer.PreBloom);
-//
-//            // Pass 2: draw from rendertarget 1 into rendertarget 2,
-//            // using a shader to apply a horizontal gaussian blur filter.
-//            //SetBlurEffectParameters(1.0f / (float)renderTarget1.Width, 0);
-//
-//            DrawFullscreenQuad(renderTarget1, renderTarget2,
-//                               gaussianBlurEffect,
-//                               IntermediateBuffer.BlurredHorizontally);
-//
-//            // Pass 3: draw from rendertarget 2 back into rendertarget 1,
-//            // using a shader to apply a vertical gaussian blur filter.
-//            //SetBlurEffectParameters(0, 1.0f / (float)renderTarget1.Height);
-//
-//            DrawFullscreenQuad(renderTarget2, renderTarget1,
-//                               gaussianBlurEffect,
-//                               IntermediateBuffer.BlurredBothWays);
-//
-//            // Pass 4: draw both rendertarget 1 and the original scene
-//            // image back into the main backbuffer, using a shader that
-//            // combines them to produce the final bloomed result.
+            GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
+
+            // Pass 1: draw the scene into rendertarget 1, using a
+            // shader that extracts only the brightest parts of the image.
+            bloomExtractEffect.Parameters["BloomThreshold"].SetValue(
+                Settings.BloomThreshold);
+
+            DrawFullscreenQuad(sceneRenderTarget, renderTarget1,
+                               bloomExtractEffect,
+                               IntermediateBuffer.PreBloom);
+
+            // Pass 2: draw from rendertarget 1 into rendertarget 2,
+            // using a shader to apply a horizontal gaussian blur filter.
+            //SetBlurEffectParameters(1.0f / (float)renderTarget1.Width, 0);
+
+            DrawFullscreenQuad(renderTarget1, renderTarget2,
+                               gaussianBlurEffect,
+                               IntermediateBuffer.BlurredHorizontally);
+
+            // Pass 3: draw from rendertarget 2 back into rendertarget 1,
+            // using a shader to apply a vertical gaussian blur filter.
+            //SetBlurEffectParameters(0, 1.0f / (float)renderTarget1.Height);
+
+            DrawFullscreenQuad(renderTarget2, renderTarget1,
+                               gaussianBlurEffect,
+                               IntermediateBuffer.BlurredBothWays);
+
+            // Pass 4: draw both rendertarget 1 and the original scene
+            // image back into the main backbuffer, using a shader that
+            // combines them to produce the final bloomed result.
             GraphicsDevice.SetRenderTarget(null);
-//
-//            EffectParameterCollection parameters = bloomCombineEffect.Parameters;
-//            parameters["BloomIntensity"].SetValue(Settings.BloomIntensity);
-//            parameters["BaseIntensity"].SetValue(Settings.BaseIntensity);
-//            parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
-//            parameters["BaseSaturation"].SetValue(Settings.BaseSaturation);
+
+            EffectParameterCollection parameters = bloomCombineEffect.Parameters;
+            parameters["BloomIntensity"].SetValue(Settings.BloomIntensity);
+            parameters["BaseIntensity"].SetValue(Settings.BaseIntensity);
+            parameters["BloomSaturation"].SetValue(Settings.BloomSaturation);
+            parameters["BaseSaturation"].SetValue(Settings.BaseSaturation);
 
             GraphicsDevice.Textures[1] = sceneRenderTarget;
 
             Viewport viewport = GraphicsDevice.Viewport;
 
-//            DrawFullscreenQuad(renderTarget1,
+            DrawFullscreenQuad(renderTarget1,
+                               viewport.Width, viewport.Height,
+                               bloomCombineEffect,
+                               IntermediateBuffer.FinalResult);
+//            DrawFullscreenQuad(sceneRenderTarget,
 //                               viewport.Width, viewport.Height,
 //                               bloomCombineEffect,
 //                               IntermediateBuffer.FinalResult);
-            DrawFullscreenQuad(sceneRenderTarget,
-                               viewport.Width, viewport.Height,
-                               bloomCombineEffect,
-                               IntermediateBuffer.FinalResult);			
         }
 
 

+ 4 - 4
Samples/MacOS/NetRumble/Content/BloomPostprocess/Effects/BloomCombine.fsh

@@ -1,5 +1,5 @@
-uniform sampler2D BloomSampler;
-uniform sampler2D BaseSampler;
+uniform sampler2D BloomSampler_s0;
+uniform sampler2D BaseSampler_s1;
 
 uniform float BloomIntensity;
 uniform float BaseIntensity;
@@ -25,8 +25,8 @@ vec4 AdjustSaturation(vec4 color, float saturation)
 void main()
 {
 	// Look up the bloom and original base image colors.
-	vec4 bloom = gl_Color * texture2D(BloomSampler, gl_TexCoord[0].xy);
-	vec4 base = gl_Color * texture2D(BaseSampler, gl_TexCoord[0].xy);	
+	vec4 bloom = gl_Color * texture2D(BloomSampler_s0, gl_TexCoord[0].xy);
+	vec4 base = gl_Color * texture2D(BaseSampler_s1, gl_TexCoord[0].xy);	
 	// Adjust color saturation and intensity.
 	bloom = AdjustSaturation(bloom, BloomSaturation) * BloomIntensity;
 	base = AdjustSaturation(base, BaseSaturation) * BaseIntensity;

+ 2 - 2
Samples/MacOS/NetRumble/Content/BloomPostprocess/Effects/BloomExtract.fsh

@@ -1,9 +1,9 @@
-uniform sampler2D TextureSampler;
+uniform sampler2D TextureSampler_s0;
 uniform float BloomThreshold;
 
 void main()
 {
-  vec4 c = texture2D(TextureSampler, gl_TexCoord[0].xy);
+  vec4 c = texture2D(TextureSampler_s0, gl_TexCoord[0].xy);
   gl_FragColor = clamp((c - BloomThreshold )/ (1.0-BloomThreshold),0.0, 1.0);
 }
 

+ 3 - 3
Samples/MacOS/NetRumble/Content/BloomPostprocess/Effects/GaussianBlur.fsh

@@ -1,7 +1,7 @@
 // Pixel shader applies a one dimensional gaussian blur filter.
 // This is used twice by the bloom postprocess, first to
 // blur horizontally, and then again to blur vertically.
-uniform sampler2D TextureSampler;
+uniform sampler2D TextureSampler_s0;
 uniform vec2 SampleOffsets[15];
 uniform float SampleWeights[15];
 
@@ -9,9 +9,9 @@ uniform float SampleWeights[15];
 void main()
 {
      vec4 c = vec4(0);
-     for(int i=0; i < 1; i++) 
+     for(int i=0; i < 15; i++) 
      {
-          c += texture2D(TextureSampler, gl_TexCoord[0].xy + SampleOffsets[i]) * SampleWeights[i];
+          c += texture2D(TextureSampler_s0, gl_TexCoord[0].xy + SampleOffsets[i]) * SampleWeights[i];
      }
 	 gl_FragColor = c;
 }

+ 6 - 6
Samples/MacOS/NetRumble/NetRumble.csproj

@@ -158,12 +158,6 @@
     <Compile Include="Effects\BloomExtractEffect.cs" />
     <Compile Include="Effects\GaussianBlurEffect.cs" />
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\..\..\MonoGame.Framework\MonoGame.Framework.MacOS.csproj">
-      <Project>{36C538E6-C32A-4A8D-A39C-566173D7118E}</Project>
-      <Name>MonoGame.Framework.MacOS</Name>
-    </ProjectReference>
-  </ItemGroup>
   <ItemGroup>
     <Content Include="Content\Fonts\MenuFont.xnb" />
     <Content Include="Content\Fonts\MessageBox.xnb" />
@@ -235,4 +229,10 @@
   <ItemGroup>
     <Folder Include="Effects\" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.MacOS.csproj">
+      <Project>{36C538E6-C32A-4A8D-A39C-566173D7118E}</Project>
+      <Name>MonoGame.Framework.MacOS</Name>
+    </ProjectReference>
+  </ItemGroup>
 </Project>

+ 4 - 10
Samples/MacOS/NetRumble/NetRumble.sln

@@ -3,11 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 11.00
 # Visual Studio 2010
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetRumble", "NetRumble.csproj", "{52735207-2136-433B-A3E4-4C082728EED8}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network", "..\..\..\..\..\..\..\Users\Jimmy\Public\Share\MonoMacSource\kjpgit\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.csproj", "{AE483C29-042E-4226-BA52-D247CE7676DA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network.MacOS", "..\..\..\..\MonoGame\ThirdParty\Lidgren.Network\Lidgren.Network.MacOS.csproj", "{AE483C29-042E-4226-BA52-D247CE7676DA}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Framework.MacOS", "..\..\..\..\..\..\..\Users\Jimmy\Public\Share\MonoMacSource\kjpgit\MonoGame\MonoGame.Framework\MonoGame.Framework.MacOS.csproj", "{36C538E6-C32A-4A8D-A39C-566173D7118E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpriteEffects", "..\..\..\..\..\..\..\Users\Jimmy\Public\Share\MonoMacSource\kjpgit\MonoGame\Samples\MacOS\SpriteEffects\SpriteEffects.csproj", "{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Framework.MacOS", "..\..\..\..\MonoGame\MonoGame.Framework\MonoGame.Framework.MacOS.csproj", "{36C538E6-C32A-4A8D-A39C-566173D7118E}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -22,18 +20,14 @@ Global
 		{36C538E6-C32A-4A8D-A39C-566173D7118E}.Distribution|Any CPU.Build.0 = Distribution|Any CPU
 		{36C538E6-C32A-4A8D-A39C-566173D7118E}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{36C538E6-C32A-4A8D-A39C-566173D7118E}.Release|Any CPU.Build.0 = Release|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Distribution|Any CPU.ActiveCfg = Debug|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Distribution|Any CPU.Build.0 = Debug|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{3B9ABB34-4D0F-4CFD-A02D-30D5569A060B}.Release|Any CPU.Build.0 = Release|Any CPU
 		{52735207-2136-433B-A3E4-4C082728EED8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{52735207-2136-433B-A3E4-4C082728EED8}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{52735207-2136-433B-A3E4-4C082728EED8}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{52735207-2136-433B-A3E4-4C082728EED8}.Release|Any CPU.Build.0 = Release|Any CPU
 		{AE483C29-042E-4226-BA52-D247CE7676DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{AE483C29-042E-4226-BA52-D247CE7676DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{AE483C29-042E-4226-BA52-D247CE7676DA}.Distribution|Any CPU.ActiveCfg = Debug|Any CPU
+		{AE483C29-042E-4226-BA52-D247CE7676DA}.Distribution|Any CPU.Build.0 = Debug|Any CPU
 		{AE483C29-042E-4226-BA52-D247CE7676DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{AE483C29-042E-4226-BA52-D247CE7676DA}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection