Troubleshooting this TutorialSometimes, even though you try hard to understand the information in a tutorial, things don't work out quite like you want it to. This page is here to help you resolve any problems you might be having with the tutorial on creating post processing effects. The Common Mistakes section describes common problems that people have when doing the things in this tutorial, and how to resolve them. The Frequently Asked Questions section describes questions that people have that aren't related to mistakes, but rather, trying to understand the stuff better or exploring how it can be used. If your problem or concern isn't addressed here, feel free to add a comment below, so that I know where you're having trouble. I like to keep these pages fairly clean, so I may remove comments that I felt like have been addressed. If I remove your comment and you don't feel like the problem has been fixed, repost the question and we'll take another look at it. If a tutorial has a mistake in it, I will fix the mistake and reply to the comment with a brief explanation. However, after a couple of weeks I'll likely go back and remove the original comment as well as my reply, because, hopefully, the problem will have been fixed, and it won't be a concern any more. |
Common MistakesNone listed yet… |
Frequently Asked QuestionsNone listed yet… |
Hi, I have done everything as a lesson, but get a different result. Do I with the help of monogamy 3.5.1. I get a colored square if the shader apply. (RenderToTexture)
Sorry for my English ) .
Hello,
I have just tried the first plain shader, and only got the texture of the helicopter as a result; this is because you have to get the screen as your texture. (And not the texture of the helicopter; in my case, this is caused by the homonymous name texture from a former tutorial.)
The tutorial does not seem to say it, but you have to write some C# to achieve this; you can still find the relevant code by clicking on ‘view source code’. Look for function DrawSceneToTexture.
PS: I am now getting to the ‘2 - Rendering to a Texture’ tutorial from the ‘Advanced XNA Tutorials’ list, and realize this is exactly what is needed here! I guess it would be an extremely good idea to hyperlink to it in the present tutorial.
(remove space)
rbwhitaker.wikidot.com /render-to-texture
I understand. That work shader "A Sepia Tone Shader" . (3.5.1)
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif
#include "Macros.fxh"
------ TEXTURE PROPERTIES -----—-
This is the texture that SpriteBatch will try to set before drawing
texture ScreenTexture;
// Our sampler for the texture, which is just going to be pretty simple
sampler TextureSampler = sampler_state
{
Texture = <ScreenTexture>;
};
----— PIXEL SHADER --------—
This pixel shader will simply look up the color of the texture at the
// requested point
float4 PixelShaderFunction(float4 position : POSITION0,
float4 color : COLOR0,
float2 texCoord : TEXCOORD0) : SV_Target0
{
float4 colorRGB = tex2D(TextureSampler, texCoord);
//float4 color = SAMPLE_TEXTURE(Texture, input.texCoord) * input.color;
float4 outputColor = color;
outputColor.r = (colorRGB.r * 0.393) + (colorRGB.g * 0.769) + (colorRGB.b * 0.189);
outputColor.g = (colorRGB.r * 0.349) + (colorRGB.g * 0.686) + (colorRGB.b * 0.168);
outputColor.b = (colorRGB.r * 0.272) + (colorRGB.g * 0.534) + (colorRGB.b * 0.131);
return outputColor;
//return color;
}
technique Plain
{
pass P0
{
//VertexShader = compile VS_SHADERMODEL VertexShaderFunction();
PixelShader = compile PS_SHADERMODEL PixelShaderFunction();
}
};
Post preview:
Close preview