Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

HLSL Shader Model 4 Editor

ngon master
Offline / Send Message
radiancef0rge ngon master
So Im looking for a shader editor that supports Shader Model 4 specifically for this command "lt" http://msdn.microsoft.com/en-us/library/windows/desktop/hh447181(v=vs.85).aspx

Unfortunately I dont have access to Visual Studio, and am not keen on using it anyway. The perfect example would be Shazzam - as the shader is a post effect. Any ideas?

Here is the code its from John Hables stuff on photography spec;
  1. float LinearToSrgb(float val)
  2. {
  3. float ret;
  4. if (val <= 0.0)
  5. ret = 0.0f;
  6. else if (val <= 0.0031308f)
  7. ret = 12.92f*val;
  8. else if (val <= 1.0f)
  9. ret = (pow(val, 0.41666)*1.055f)-0.055f;
  10. else
  11. ret = 1.0f;
  12. return ret;
  13. }
  14.  
  15. float SrgbToLinear(float val)
  16. {
  17. float ret;
  18. if (val <= 0.0f)
  19. ret = 0;
  20. else if (val <= 0.04045f)
  21. ret = val / 12.92f;
  22. else if (val <= 1.0f)
  23. ret = pow((val + 0.055f)/1.055f,2.4f);
  24. else
  25. ret = 1.0f;
  26. return ret;
  27. }
  28.  
  29. int g_bSpecOrDiff;
  30.  
  31. float4 ps_main( float2 texCoord : TEXCOORD0 ) : COLOR
  32. {
  33. float3 srcA = tex2D(Texture0, texCoord ).rgb;
  34. float3 srcB = tex2D(Texture1, texCoord ).rgb;
  35. float3 linA = SrgbToLinear(srcA);
  36. float3 linB = SrgbToLinear(srcB);
  37. float3 linDiff = linA*2;
  38. float3 linSpec = linB-linA;
  39. float3 texDiff = LinearToSrgb(linDiff);
  40. float3 texSpec = LinearToSrgb(linSpec);
  41. float3 ret = g_bSpecOrDiff ? texDiff : texSpec;
  42. return ret;
  43. }

Any ideas? Ive tried ShaderFX, Maya '14 and LT, Shazzam, and some random web based or indie editors

Replies

  • equil
    i think you can just replace those "<=" comparisons with "<=". as that documentation page reveals, that's an assembly instruction, and your code isn't assembly so it's sort of useless anyway. what i think has happened is that your code was posted on a website that processes plaintext in a way to make it not interfere with the html. (usually switching <> to the html entities < and >) In some cases the entity still shows up and i guess that's what happened here.

    so essentially: if (val <= 0.0) {} should work
  • radiancef0rge
    Offline / Send Message
    radiancef0rge ngon master
    Sweet thanks man, it worked. I have one issue with a float3 to 4 conversion. Could use some help would be eternally grateful :)
    1. sampler2D Texture0 : register(s0);
    2. sampler2D Texture1 : register(s1);
    3. float LinearToSrgb(float val)
    4. {
    5. float ret;
    6. if (val <= 0.0)
    7. ret = 0.0f;
    8. else if (val <= 0.0031308f)
    9. ret = 12.92f*val;
    10. else if (val <= 1.0f)
    11. ret = (pow(val, 0.41666)*1.055f)-0.055f;
    12. else
    13. ret = 1.0f;
    14. return ret;
    15. }
    16.  
    17. float SrgbToLinear(float val)
    18. {
    19. float ret;
    20. if (val <= 0.0f)
    21. ret = 0;
    22. else if (val <= 0.04045f)
    23. ret = val / 12.92f;
    24. else if (val <= 1.0f)
    25. ret = pow((val + 0.055f)/1.055f,2.4f);
    26. else
    27. ret = 1.0f;
    28. return ret;
    29. }
    30.  
    31. int g_bSpecOrDiff;
    32.  
    33. float4 ps_main( float2 texCoord : TEXCOORD0 ) : COLOR
    34. {
    35. float3 srcA = tex2D(Texture0, texCoord ).rgb;
    36. float3 srcB = tex2D(Texture1, texCoord ).rgb;
    37. float3 linA = SrgbToLinear(srcA);
    38. float3 linB = SrgbToLinear(srcB);
    39. float3 linDiff = linA*2;
    40. float3 linSpec = linB-linA;
    41. float3 texDiff = LinearToSrgb(linDiff);
    42. float3 texSpec = LinearToSrgb(linSpec);
    43. float3 ret = g_bSpecOrDiff ? texDiff : texSpec;
    44. return ret;
    45. }
  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    just have a constant 1.0 for float 4. Not sure on this nomenclature
    1. float3 ret = g_bSpecOrDiff ? texDiff : texSpec;

    but you should be able to append a 1.0 for alpha. Something like

    return float4(ret.xyz,1.0);
Sign In or Register to comment.