Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Unless you have a pretty old graphics-card, it's surprising that you don't have fragment-shader support. I'd suggest you try double-checking using <a href="http://www.realtech-vr.com/glview/" rel="nofollow noreferrer">this</a>.</p> <p>Also, are you sure you want anything above the max value to be 0? Perhaps you meant 1? If you did mean 1 and not 0 then are quite long-winded ways to do what you're asking. </p> <p>The condensed answer is that you use multiple rendering-passes. First you render the image at normal intensity. Then you use subtractive blending (look up glBlendEquation) to subtract your minimum value. Then you use additive blending to multiply everything up by 1/(max-min) (which may need multiple passes).</p> <p>If you really want to do this, please post back the <code>GL_VENDOR</code> and <code>GL_RENDERER</code> for your graphics-card.</p> <p><strong>Edit:</strong> Hmm. Intel 945G don't have <code>ARB_fragment_shader</code>, but it does have <code>ARB_fragment_program</code> which will also do the trick.</p> <p>Your fragment-code should look something like this (but it's been a while since I wrote any so it's probably bugged)</p> <pre><code>!!ARBfp1.0 ATTRIB tex = fragment.texcoord[0] PARAM cbias = program.local[0] PARAM cscale = program.local[1] OUTPUT cout = result.color TEMP tmp TXP tmp, tex, texture[0], 2D SUB tmp, tmp, cbias MUL cout, tmp, cscale END </code></pre> <p>You load this into OpenGL like so:</p> <pre><code>GLuint prog; glEnable(GL_FRAGMENT_PROGRAM_ARB); glGenProgramsARB(1, &amp;prog); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog); glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(src), src); glDisable(GL_FRAGMENT_PROGRAM_ARB); </code></pre> <p>Then, before rendering your geometry, you do this:</p> <pre><code>glEnable(GL_FRAGMENT_PROGRAM_ARB); glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prog); colour4f cbias = cmin; colour4f cscale = 1.0f / (cmax-cmin); glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0, cbias.r, cbias.g, cbias.b, cbias.a); glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1, cscale.r, cscale.g, cscale.b, cscale.a); //Draw your textured geometry glDisable(GL_FRAGMENT_PROGRAM_ARB); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload