Hello to everyone!

I'm doing a translation of https://github.com/ZaneDubya/UltimaXNA to MonoGame because this one has a lot of new features (as DirectX and OpenGL support) directly in C# and because XNA is Dead.

However all is working fine but i've a issue about Hue managerment.

This is the pixelshader effect that works with XNA but i've translated it to MonoGame, the language used is HSLS and i'm not good at it.
Code:
float4x4 ProjectionMatrix;
float4x4 WorldMatrix;
float2     Viewport;

float3 lightDirection;
float lightIntensity;

bool DrawLighting;

sampler textureSampler;
sampler hueSampler0;
sampler hueSampler1;

const float HuesPerTexture = 2048;
const float ToGrayScale = 3; // (3.0f * HuesPerRow)

struct VS_INPUT
{
    float4 Position : SV_POSITION;
    float3 Normal    : NORMAL0;
    float3 TexCoord : TEXCOORD0;
    float2 Hue        : TEXCOORD1;
};

struct PS_INPUT
{
    float4 Position : SV_POSITION;
    float3 TexCoord : TEXCOORD0;
    float3 Normal    : TEXCOORD1;
    float2 Hue        : TEXCOORD2;
};

PS_INPUT VertexShaderFunction(VS_INPUT IN)
{
    PS_INPUT OUT;
 
    OUT.Position = mul(mul(IN.Position, WorldMatrix), ProjectionMatrix);
 
    // Half pixel offset for correct texel centering.
    OUT.Position.x -= 0.5 / Viewport.x;
    OUT.Position.y += 0.5 / Viewport.y;

    OUT.TexCoord = IN.TexCoord;
    OUT.Normal = IN.Normal;
    OUT.Hue = IN.Hue;
 
    return OUT;
}

float4 PixelShaderFunction(PS_INPUT IN) : COLOR0
{ 
    // Get the initial pixel and discard it if the alpha == 0
    float4 color = tex2D(textureSampler, IN.TexCoord);

    if (color.a == 0)
    {
        discard;
    }

    // Hue the color if the hue vector y component is greater than 0.
    if (IN.Hue.y > 0)
    {
        // Hue.Y is a bit flag:
        // 0x01 = completely hued
        // 0x02 = partially hued
        // 0x04 = 50% transparent.
        // 0x01 & 0x02 should be mutually exclusive.

        float inHueIndex = ((color.r + color.g + color.b) / 3.0f);
        float4 hueColor;
        if (IN.Hue.x >= HuesPerTexture)
        {
            hueColor = tex2D(hueSampler1, float2(inHueIndex, (IN.Hue.x + HuesPerTexture) / HuesPerTexture));
        }
        else
        {
            hueColor = tex2D(hueSampler0, float2(inHueIndex, IN.Hue.x / HuesPerTexture));
        }
        hueColor.a = color.a;

        if (IN.Hue.y >= 4)
        {
            // 50% transparent
            IN.Hue.y %= 4;
            color *= 0.5f;
        }
        else
        if (IN.Hue.y >= 2)
        {
            // partial hue - map any grayscale pixels to the hue. Colored pixels remain colored.
            //if ((color.r == color.g) && (color.r == color.b))
                //color = hueColor;
        }
        else if (IN.Hue.y >= 1)
        {
            // normal hue - map the hue to the grayscale.
            //color = hueColor;
        }
    }

    // Darken the color based on the ambient lighting and the normal.
    if (DrawLighting)
    {
        float3 light = normalize(lightDirection);
        float3 normal = normalize(IN.Normal);
        float3 nDotL = min(saturate(dot(light, normal)), 1.0f);

        color.rgb = saturate((color.rgb * nDotL * lightIntensity * 0.2f + color.rgb * lightIntensity * 0.8f));
    }

    return color;
}


technique StandardEffect
{
    pass p0
    {
    VertexShader = compile vs_4_0_level_9_1 VertexShaderFunction();
        PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
    }
}

I had to comment the hue color part because it brought each hued color to BLACK #FF000 . Could you help me to solve this issue?

I think that if i can make it refer to UDK, it could be great to have a game who supports even new formats ^^.

Maybe you could be interested to lend me an hand about it ^^.
 
I don't really know anything about the language itself, but if you are trying to render color including adjusting for light and distance, would you need to consider difuse and specular components?
 
The real problem is that the same shader "works" if compiled to XNA.

Code:
 hueColor = tex2D(hueSampler1, float2(inHueIndex, (IN.Hue.x + HuesPerTexture) / HuesPerTexture));

and
Code:
 hueColor = tex2D(hueSampler0, float2(inHueIndex, IN.Hue.x / HuesPerTexture));

returns black always (so 0). That's the real problem else it could be a good basis for a very fast map/items renderer ._."
 
yay! I've been saying and hoping for over a year that xna should be 'upgraded' to monogames! Best of luck!
http://www.monogame.net/ (for anyone not familiar, Monogame is one of the offsprings of xna after it 'died')

Do you have a github I can follow?
 
nope, because i've just downloaded sources and putted them in a MonoGame folder but if you want i can give you my compiled FX files ^^".

However i was thinging about proposing to the community to spend time and using http://paradox3d.net/ but i'm a noob in graphical stuff so i want to ask to the community if more experienced people thinks it could be a good idea or a total waste of time ^^.
 
Last edited:
Hi guys... I work with the MonoGame and your thread showed up on a regular google search..

There's nothing obvious in that shader that shouldn't work - especially if you are running on windows. But there are a few tweaks you sometimes have to make. If you have a github or a zip file I'll take a look and see if I can debug it for you.

Do you know if the original author is interested in porting to MonoGame - we're always looking for bigger projects to demonstrate how well it works and how easy it is to port.
 
Hi guys... I work with the MonoGame and your thread showed up on a regular google search..

There's nothing obvious in that shader that shouldn't work - especially if you are running on windows. But there are a few tweaks you sometimes have to make. If you have a github or a zip file I'll take a look and see if I can debug it for you.

Do you know if the original author is interested in porting to MonoGame - we're always looking for bigger projects to demonstrate how well it works and how easy it is to port.


Authors officially declared they won't take part in any porting.

https://github.com/ZaneDubya/UltimaXNA/wiki/FAQ

2.4 Will UltimaXNA run on any platform other than Windows?

No. UltimaXNA is built with DotNet and XNA, thus making it exclusively available to Windows users. There are no plans, current or future, to port UltimaXNA to MonoGame, Linux, the XBox 360, or any other platform. Since the entire UltimaXNA codebase is open source, you are free to port it yourself. However, we will not support any efforts to port the client.

and this is the original github https://github.com/ZaneDubya/UltimaXNA

just tell me if you need something else
 
it should work ^^, ther's for DirectX and for OpenGL
 

Attachments

  • EssenceUDK_2015-05-03 16-32-00Z.zip
    5 MB · Views: 24
I don't want to spend the time porting UltimaXNA to another framework before it is feature complete, even if the time involved with the port would be negligible. After the client is feature complete, my interest in porting the project would be directly correlated with how much would need to be changed. I've heard from advocates for porting to MonoGame, SharpDX, and Paradox3D. Everyone has their platform of choice. I just want to get it done. :)

XNA, although no longer under development, is still a viable development target that works on Windows Desktop from XP to 10. And I know that it works, without problems, on any machine that supports XNA4's minimal reach target (and I've tested it on some truly minimal machines!). As Xen's experience bears out, even a port as straightforward as XNA to MonoGame might create edge cases that would require bug fixing. This would require time that would be better spent adding features and making sure that the client's behavior conforms to the legacy client.

That said, let me know when you've completed the MonoGame port, as I'd like to take a look at it! You might also want to consider forking the project on github so that people can follow your progress.
 
Paradox3d is a better choice for porting in my opinion. The author of that platform is the creator of SharpDX, which is the same platform MonoGame uses under the hood. Paradox3d runs circles around MonoGame in performance, has a much better API for rendering and mostly conforms to XNAs framework API so porting isnt to difficult. Also, Paradox3d has a lot of their API written for the new .Net functionality like TPL, await async, etc. MonoGame was written to conform to an old obsolete API that was discontinued by Microsoft because it could not be easily ported to DX10+ without breaking old games. Paradox3d out of the box supports all platforms, windows/store/android/ios/linux/osx/etc.

Ya, im a fanboi ;) but with good reason ;)
 
Last edited:
@pinguini - I don't believe Xen is working on it at present.

Hopefully, at some point, I'll get the xna client working, and then I might turn my attention to cross platform compatibility. But I have to finish the xna client first. School is taking up my attention at the moment, so there's not a lot of movement on that front.
 
Back