Home Technical Talk

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;
float LinearToSrgb(float val)
{
   float ret;
   if (val <= 0.0)
      ret = 0.0f;
   else if (val <= 0.0031308f)
      ret = 12.92f*val;
   else if (val <= 1.0f)
      ret = (pow(val, 0.41666)*1.055f)-0.055f;
   else
      ret = 1.0f;
   return ret;
}

float SrgbToLinear(float val)
{
   float ret;
   if (val <= 0.0f)
      ret = 0;
   else if (val <= 0.04045f)
      ret = val / 12.92f;
   else if (val <= 1.0f)
      ret = pow((val + 0.055f)/1.055f,2.4f);
   else
      ret = 1.0f;
   return ret;
}

int g_bSpecOrDiff;

float4 ps_main( float2 texCoord  : TEXCOORD0 ) : COLOR
{
   float3 srcA = tex2D(Texture0, texCoord ).rgb;
   float3 srcB = tex2D(Texture1, texCoord ).rgb;
   float3 linA = SrgbToLinear(srcA);
   float3 linB = SrgbToLinear(srcB);
   float3 linDiff = linA*2;
   float3 linSpec = linB-linA;
   float3 texDiff = LinearToSrgb(linDiff);
   float3 texSpec = LinearToSrgb(linSpec);
   float3 ret = g_bSpecOrDiff ? texDiff : texSpec;
   return ret;
}

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

Replies

  • equil
    Options
    Offline / Send Message
    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
    Options
    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 :)
    sampler2D Texture0 : register(s0);
    sampler2D Texture1 : register(s1);
    float LinearToSrgb(float val)
    {
       float ret;
       if (val <= 0.0)
          ret = 0.0f;
       else if (val <= 0.0031308f)
          ret = 12.92f*val;
       else if (val <= 1.0f)
          ret = (pow(val, 0.41666)*1.055f)-0.055f;
       else
          ret = 1.0f;
       return ret;
    }
    
    float SrgbToLinear(float val)
    {
       float ret;
       if (val <= 0.0f)
          ret = 0;
       else if (val <= 0.04045f)
          ret = val / 12.92f;
       else if (val <= 1.0f)
          ret = pow((val + 0.055f)/1.055f,2.4f);
       else
          ret = 1.0f;
       return ret;
    }
    
    int g_bSpecOrDiff;
    
    float4 ps_main( float2 texCoord  : TEXCOORD0 ) : COLOR
    {
       float3 srcA = tex2D(Texture0, texCoord ).rgb;
       float3 srcB = tex2D(Texture1, texCoord ).rgb;
       float3 linA = SrgbToLinear(srcA);
       float3 linB = SrgbToLinear(srcB);
       float3 linDiff = linA*2;
       float3 linSpec = linB-linA;
       float3 texDiff = LinearToSrgb(linDiff);
       float3 texSpec = LinearToSrgb(linSpec);
       float3 ret = g_bSpecOrDiff ? texDiff : texSpec;
       return ret;
    }
    
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    just have a constant 1.0 for float 4. Not sure on this nomenclature
    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.