Author Topic: How to access the alpha channel for texture lookup?  (Read 3527 times)

0 Members and 1 Guest are viewing this topic.

colac

  • Associate
  • Posts: 8
How to access the alpha channel for texture lookup?
« on: October 01, 2006, 08:35:00 PM »
Hi,
Could someone tell me how to use the alpha channel for texture loopup?
For example, in my program, I use the description to load texture file =>
<texture name= "rockwall_normal_tex" filename="textures/collage/collage_step.png" pixel_format="RGBA_32F" filtering_mode="NONE"/>
And in shader program, I use =>
vec4 t=texture2D(heightMap, texCoord.xy);

But I can't read anything in t.a or t.w.

Do I miss anything about it?
Hope someone could help me, thx.

colac

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
How to access the alpha channel for texture lookup?
« Reply #1 on: October 02, 2006, 05:15:18 PM »
Hello,

floating point textures behave differently if you have an ati or nvidia cg.
With nVidia gpus, you have to use texture rectangle to init floating point buffer. You can init this kind of texture like this with Hyperion:

Code: [Select]

<texture type="TEXTURE_RECTANGLE_2D" pixel_format="RGBA_32F" >
...
</texture>


On ati's board, your code should run. Maybe, try to use power of two texture.
Keep us informed!

colac

  • Associate
  • Posts: 8
How to access the alpha channel for texture lookup?
« Reply #2 on: October 03, 2006, 07:32:47 PM »
Thanks for your words.
I just use general texture image such as *.tga, and I don't know how to define its pixel_format such that I can use the alpha channel.
For example, I use pixel_format="RGB" to access the rgb channel. It's OK.
But now I want to access alpha channel for a normal 32bits texture that each channel forms a byte. My problem is how should I define the pixel_format, is it pixel_format = "RGBA"? I try to use some combinations but in vain... Sorry I don't find the document which describes how to define it. thx

colac

colac

  • Associate
  • Posts: 8
How to access the alpha channel for texture lookup?
« Reply #3 on: October 03, 2006, 07:49:23 PM »
Quote from: "JeGX"
Hello,

floating point textures behave differently if you have an ati or nvidia cg.
With nVidia gpus, you have to use texture rectangle to init floating point buffer. You can init this kind of texture like this with Hyperion:

Code: [Select]

<texture type="TEXTURE_RECTANGLE_2D" pixel_format="RGBA_32F" >
...
</texture>


On ati's board, your code should run. Maybe, try to use power of two texture.
Keep us informed!


I could simply reads the data from t.r or t.g or t.b, but I can't read t.a/t.w.

colac

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
How to access the alpha channel for texture lookup?
« Reply #4 on: October 04, 2006, 12:35:37 PM »
I added a new code sample that shows how to access to the alpha channel in the pixel shader to perform alpha testing:
Code Sample 112

The thing to know is that hyperion does not read the alpha channel of a tga texture. So you have to provide the base and the alpha maps separately and combine them with hyperion.

colac

  • Associate
  • Posts: 8
How to access the alpha channel for texture lookup?
« Reply #5 on: October 04, 2006, 02:12:50 PM »
Quote from: "JeGX"
I added a new code sample that shows how to access to the alpha channel in the pixel shader to perform alpha testing:
Code Sample 112

The thing to know is that hyperion does not read the alpha channel of a tga texture. So you have to provide the base and the alpha maps separately and combine them with hyperion.


Hi,
The link seems fail.
I got the message => Unknown ERROR - Please Try Again...
thx

colac

JeGX

  • Global Moderator
  • Capo Crimine
  • *****
  • Posts: 2357
    • oZone3D.Net
How to access the alpha channel for texture lookup?
« Reply #6 on: October 04, 2006, 02:17:45 PM »
It's fixed now!