Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

To move from Pixel Shader to Vertex Shader

$
0
0

@Tankerpat wrote:

Hi,

Since few month I use pixel shader on my rendertarget2D and that worked perfectly. Thx to kosmonautgames :wink:

But now I want to draw textured quad with primitives and perspectiveFieldOfView.

To draw my quad I use this method :
https://msdn.microsoft.com/ru-ru/library/bb464051(v=xnagamestudio.31).aspx

I tried to keep my way todo with rendertarget2D. But nothing :frowning:

So I think I need to use vertex shader and pixel shader but it doesn't work too.
Vertex :

 struct VertexIn
{
    float4 Position : SV_POSITION0;
    float4 VertexColor  : COLOR0;
    float2 TexCoord : TEXCOORD0;
};

struct VertexOut
{
    float4 Position : SV_POSITION0;
    float4 VertexColor  : COLOR0;
    float2 TexCoord : TEXCOORD0;
};

VertexOut VS(VertexIn vin)
{
    VertexOut vout;
   // Here I try a lot of thing to test

    float4 worldPosition = mul(vin.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    vout.Position = mul(viewPosition, Projection);
    float4x4 WorldViewProjection = View*Projection;
    vout.Position = vin.Position;// (float4(vin.Position.x, vin.Position.y, 500.0, 1.0));// , WorldViewProjection);
                                                                         //vout.Position = vin.Position;// , WorldViewProjection);
    vout.TexCoord = vin.TexCoord;

    return vout;
}

Pixel :

float4 SimplePointLightPS(float4 Position : SV_Position, float4 Color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 //VertexOut pin) :SV_TARGET//
{       
    float halfMagnitude = length(float3(texCoord.xy,500) - float3(0.5, 0.5,0));// pin.TexCoord.xy

    float alpha = (PointLightZ - 1) - saturate(PointLightPosition.z - halfMagnitude * PointLightPosition.z);

    return float4(GetComputedColor(alpha));


}

Is it possible to draw a textured quad and apply shader effect with Blendstate.Additive?

Thx in advance

Posts: 7

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles