Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Transfer Function Lookup Table Failing

This topic is 1119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys,

 

I created a simple lookup texture to use in my shader, it should act as a transfer function.

 

For a test I used a linear gradient from black to white, the output should equal the input, but it's noticably darker.

 

Here is the code:

 

 
float4 pshader(VS_OUTPUT input) : SV_TARGET
{
 // get the source colour
 float3 smp = Texture0.Sample(Sampler0, input.uv).xyz;
 
 // lookup new intensity - lookup texture is 256 x 8 pixels
 smp.x = Texture1.Sample(Sampler0, float2(smp.x, 0.5f)).x;
 smp.y = Texture1.Sample(Sampler0, float2(smp.y, 0.5f)).x;
 smp.z = Texture1.Sample(Sampler0, float2(smp.z, 0.5f)).x;

 return float4(smp, 1);
}

 

I can't see what I'm doing wrong. Thanks.

 

Share this post


Link to post
Share on other sites
Advertisement

"float2(smp.?, 0.5f)" ? 0.f is the center of the pixel. Also what are you using for Sampler0?

 

Probably because your "v" coord is 0.5, and you have a clamp to border with black you get a darker result?

Edited by imoogiBG

Share this post


Link to post
Share on other sites

Hi, thanks for helping.

 

It turns out that it's Photoshop. A linear gradient is not really linear, at 0.25 instead of the pixel being (64, 64, 64) it's actually (51, 51, 51), at least on my setup.

Share this post


Link to post
Share on other sites
Yeah, Photoshop lying about colour values is a pain in the ass.
You can get it to be truthful in 16bit precision mode, or when working on a 1-channel image, or on an alpha channel.

"float2(smp.?, 0.5f)" ? 0.f is the center of the pixel.
Probably because your "v" coord is 0.5, and you have a clamp to border with black you get a darker result?

v=0.5 is the centre of the image. v=0/1 are the top/bottom edges of the image.

Share this post


Link to post
Share on other sites

"v=0.5 is the centre of the image. v=0/1 are the top/bottom edges of the image." (facepalm) Sure for some reason I was thinking that he has a 1D texture.

Share this post


Link to post
Share on other sites

Hodgman, Photoshop really is a pain. I am noticing lots of things now; for example, I pasted an image into Photoshop that I knew was all (RGB 64, 64, 64) and it became (RGB 65, 64, 64), it added red.

 

For my transfer bitmaps I'm using my own program to save them to disk, eventually I'll generate them at runtime.

 

Be careful with precision work in Photoshop guys.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!