Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9133791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:32:53+00:00 2026-06-17T08:32:53+00:00

I have float alpha texture that contains amplitude values. It is converted to decibels

  • 0

I have float alpha texture that contains amplitude values. It is converted to decibels and displayed in grayscale.

Here is conversation code (C++) :

const float db_min = -100, db_max = 0;
float image[height][width];
for (int y = 0; y<height; ++y) {
  for (int x = 0; x<width; ++x) {
    image[y][x]= 20.f * log(a[i])/log(10.f);
    image[y][x] = (image[y][x]-db_min)/(db_max-db_min);
  }
}

Here is Fragment Shader (GLSL):

#version 120
precision highp float;
varying vec2 texcoord;
uniform sampler2D texture;
void main() {
  float value = texture2D(texture, texcoord).a;
  gl_FragColor = vec4(value, value, value, 0);
}

Here is a screenshot:
enter image description here

Looks perfect! Now, I want to write conversation in Fragment Shader itself, instead of C++:

#version 120
precision highp float;
varying vec2 texcoord;
uniform sampler2D texture;
const float db_min = -100., db_max = 0.;
void main() {
  float value = texture2D(texture, texcoord).a;
  value = 20. * log(value)/log(10.);
  value = (value-db_min)/(db_max-db_min);
  gl_FragColor = vec4(value, value, value, 0);
}

Here is a screenshot:
enter image description here

Why are results different? What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:32:54+00:00Added an answer on June 17, 2026 at 8:32 am

    Limited texel precision – that could be the problem. I can guess you’re keeping your (very-high-range as I understand looking at log) values in a 8-bit per-channel texture(e.g. RGBA8). Then you could use a floating-point format or pack your high-precision/range values to you 4-bytes format(e.g. a fixed point).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that generates circles and makes them float within the boundaries
I have 2 lines that i draw like this: float Alpha = RotDegrees; PointF
When I have a texture that has transparency (and an alpha channel), the transparent
I have two float values, 'a' and 'b' . I need to calculate the
I have two float variables that are equal, I retrieve them by PHP and
I have one texture that has some portions which are transparent transparent I want
Let's say i have a method that get a GLuint texture as a parameter
I'm trying to draw multiple hexagons on the screen that have an alpha channel.
I have a series of OpenGL-ES calls that properly render a triangle and texture
If I have a method called -(void) changeButton:(UIButton *)button andAlpha:(float)alpha andEnabled:(BOOL)enabled { button.alpha =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.