This topic is 3681 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I've been poking this all day and can't figure out for the life of me why this won't work. I have this shader:
texture myTexture;

sampler2D texSampler0 = sampler_state
{
Texture	  = <myTexture>;
};

float4 MyShader( float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 Color;

Color = tex2D( texSampler0, Tex.xy)*10;
return Color;
}

{
pass p0
{
}

}


That is simply suppose to make everything a bit brighter. But the effect isn't doing squat. Here is my code. First I call begin scene, then begin effect, then draw the sprite, then end effect, then end scene. There are no errors when compiling or running. I'm setting the texture to the Texture of the sprite I'm rendering
        public Renderer(Form renderForm)
{
...

}

/// <summary>
/// Clears the buffers and begins the scene.
/// </summary>
public void BeginScene()
{
_device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
_device.BeginScene();
_sprite.Begin(SpriteFlags.AlphaBlend | SpriteFlags.DoNotSaveState);
}

public void beginEffect()
{
_spriteEffect.Begin(FX.None);
_spriteEffect.BeginPass(0);
}

public void endEffect()
{
_spriteEffect.EndPass();
_spriteEffect.End();
}

public void SetEffectTexture(Texture texture)
{
_spriteEffect.SetValue("myTexture", texture);
}

/// <summary>
/// Ends the scene then flips the buffers.
/// </summary>
public void EndScene()
{
_sprite.End();

_device.EndScene();
_device.Present();
}


Any and all help would be greatly appreciated.

Share on other sites
I suspect you have a problem calling sprite.End() after you call effect.End().

The sprite queue isn't submitted to the device until sprite.End() is called.

EDIT: You might try swapping the order of begin's and end's

effect.Begin
sprite.Begin
sprite.Draw
sprite.End
effect.End

or call sprite.Flush before you call effect.End

Share on other sites
Thanks for the tips...but unfortunately it didn't help. I've looked at the SlimDX examples and they are pretty much exactly how I have it. I'm wondering if something isn't wrong with the shader itself. Do I need to have a vertex shader in there as well?

Share on other sites
Why cant i see the first post, only the answer post ?

Is my IE messed up ? or is some nerds actually deleting there initial post(s)

Seem to see this in several posts, pissing me off to be honest.

[Edited by - NightMarez on July 18, 2008 3:01:21 AM]

Share on other sites
Quote:
 Original post by NightMarezWhy cant i see the first post, only the answer post ?Is my IE messed up ? or is some nerds actually deleting there initial post(s)Seem to see this in several posts, pissing me off to be honest.

Theres a fix for that....it's called FireFox :)

Share on other sites
Quote:
 Why cant i see the first post, only the answer post ? ... is some nerds actually deleting there initial post(s)

There are no deleted posts in this thread.

Quote:
 Thanks for the tips...but unfortunately it didn't help. I've looked at the SlimDX examples and they are pretty much exactly how I have it. I'm wondering if something isn't wrong with the shader itself. Do I need to have a vertex shader in there as well?

That depends on the nature of the geometry; if a no-op vertex shader is sufficient to render the geometry, then no vertex shader is equivalent to the no-op shader.

Scaling by 10 in your pixel shader like that is, by the way, going to saturate most colors to white. You background isn't white, is it?

Share on other sites
Quote:
 That depends on the nature of the geometry; if a no-op vertex shader is sufficient to render the geometry, then no vertex shader is equivalent to the no-op shader. Scaling by 10 in your pixel shader like that is, by the way, going to saturate most colors to white. You background isn't white, is it?

Everything appears as if there is no shader at all. If I take out all the _spriteEffect code it would look exactly the same as if I had it in there. And my background is white. The tiles are green.

Share on other sites
It's possible the geometry -- the positions you're using for the sprite -- are in the wrong space or otherwise outside the range of values that would provide sane on-screen values. What to the numbers look like?

Share on other sites
The x,y values go from 0,0 to the width/height of the screen(drawing a tilemap of 32x32 sprites). The z value of the sprites is 0.

Share on other sites
Quote:
Original post by jpetrie
Quote:
 Why cant i see the first post, only the answer post ? ... is some nerds actually deleting there initial post(s)

There are no deleted posts in this thread.

Then my forum is bugged up like hell, total wierdness (sorry for hijacking the post like this, its just very confusing).

I only see 1 post above my other one, i suspect there should be 2 atleast since the post above my first one in this topic looks like a answer post.

1. 1
2. 2
3. 3
4. 4
frob
14
5. 5

• 16
• 13
• 20
• 12
• 19
• Forum Statistics

• Total Topics
632168
• Total Posts
3004544

×