|
||
|
|||||||
| XNA Tutorials and support for game development using Microsoft's XNA Game Studio framework. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Newbie
Join Date: Nov 2007
Age: 22
Posts: 63
|
I never knew this and it always drove me crazy why a simple shader wouldn't give me the same results as a SpriteBatch, well finally I found out why. You have to subtract half a pixel from the x/y of a vertex. Who would have thought...
Code:
float light = 1.0f;
sampler textureSampler;
float4x4 worldViewProj : WORLDVIEWPROJ;
struct PositionTexCoord
{
float4 Position : POSITION0;
float2 TexCoord : TEXCOORD0;
};
float4 PS_Process(PositionTexCoord IN) : COLOR
{
return tex2D(textureSampler, IN.TexCoord) * light;
}
void VS_Process(in PositionTexCoord IN, out PositionTexCoord OUT)
{
float4 position = IN.Position;
position.x -= 0.5f;
position.y -= 0.5f;
OUT.Position = mul(position, worldViewProj);
OUT.TexCoord = IN.TexCoord;
}
technique Baisc
{
pass p0
{
vertexshader = compile vs_2_0 VS_Process();
pixelshader = compile ps_2_0 PS_Process();
}
}
|
|
|
|
|
|
#2 (permalink) | |
|
ConnectUO Creator
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,763
|
Quote:
__________________
Jeff Boulanger ConnectUO - Core Developer Want to help make ConnectUO better? Click here to submit your ideas/requests Use your talent to compete against other community members in RunUO hosted coding competitions If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team. Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|