Search Unity

HLSL to Cg

Discussion in 'Shaders' started by Nihil688, Mar 11, 2015.

  1. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    I am trying to convert an small hlsl shader to Cg and use it in Unity, any help would be appreciated:

    Code (CSharp):
    1.  
    2. texture m_MyTexture;
    3. float m_XCenter;
    4. float m_YCenter;
    5.  
    6. sampler2D samplerState = sampler_state
    7.  {
    8. Texture = ;
    9. MinFilter = Point;
    10. MagFilter = Point;
    11. MipFilter = Linear;
    12. AddressU = CLAMP;
    13. AddressV = CLAMP;
    14. };
    15.  
    16. struct VS_OUTPUT
    17. {
    18. float4 Position : POSITION;
    19. float2 TexCoords : TEXCOORD0;
    20. };
    21.  
    22. float4 multiply (VS_OUTPUT Input) : COLOR0
    23. {
    24.  
    25. float4 colour = tex2D(samplerState, Input.TexCoords);
    26.  
    27. return colour;
    28. }
    29.  
    30. technique Main
    31. {
    32. pass P0
    33. {
    34. PixelShader = compile ps_2_0 multiply();
    35. }
    36. }
    PS: If input isn't possible to happen, it's not a problem, it's mainly so I can give it a go at converting it
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  3. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    No, I want to see the differences though in the construction
     
  4. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    any help?
     
  5. Nihil688

    Nihil688

    Joined:
    Mar 12, 2013
    Posts:
    503
    ok i managed to fix it by swapping the sampler part with the normal Properties
     
  6. rimiki

    rimiki

    Joined:
    Dec 30, 2014
    Posts:
    102
    Could any body know how we do adjust for contrast or hue using CG ? thx for any help :)