BassBox SoundscapeGLSL plugin the 1st

Started by Charles Pegge, January 26, 2008, 12:18:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Charles Pegge

This is my first attempt at using GLSL. Getting it operational has been quite an intricate process but once it is  set up, creating alternative landscapes with Shader programs is quite easy - tweaking the built-in variables.

The zip file below cpntains the most recent SoundscapeA and SoundscapeGLSL which is derived from it. There is also a folder called 'Shader' which contains the Shader program source: 'ShaderA.txt'. If there are any shader compile errors the shader will not be generated and the errors will be reported in 'shader_errors.txt', also within this fplder. 'shader_errors.txt' will not be deleted if the subsequent compiles are okay. Debugging is easy if you make alterations one at a time. If the shader fails to compile then the scene will be identical to SoundscapeA. If the scene looks weird or is not what you expected then you are at least error free as far as GLSL is concerned.

Shader compilation automatically takes place when the Plugin is started. To recompile the shader it is only necessary to select an adjacent plugin then reselect the SoundscapeGLSL plugin to restart it. The shader source code is very short so Notepad is fine for editing.

If your video system does not support all the functions required to implement the shader from Opengl then all the shader code will be bypassed and you will only see the SoundscapeA scene.

To install to Bassbox drop the files and the shader folder into the BassBox\BBPlugin folder as usual.


PS: Plugged a hole for systems not supporting GLSL (would cause a GPF!)

Kent Sarikaya

Charles, great job, runs very smoothly even fullscreen!!

Charles Pegge

I am glad it works well on your system Kent. I remember you have a card similar to my NVIDIA 7600. ATI cards should have no problems with it either but I doubt that most laptops will have shader language support, with their minmised GPU hardware.

Petr Schreiber

Hi Charles,

fantastic! It runs at 66 FPS both in "fullscreen" and windowed mode.
I got just one warning:
Quote
(18) : warning C7011: implicit cast from "int" to "float"

But it ran. Interesting "GLSL Validator" was quite angry on the fragment shader:
Quote
ERROR: 0:17: '*' :  wrong operand types  no operation '*' exists that takes a left-hand operand of type '4-component vector of float' and a right operand of type 'const int' (or there is no acceptable conversion)

But as I said - driver had no problems with it :) I have GeForce 6150.


Bye,
Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Patrice Terrier

--Charles

QuoteI doubt that most laptops will have shader language support
It works perfectly well on my VISTA laptop, and without sound distortion even in full screen.

The only problem i found is the culling one, already reported, related to the depth of the shaded pyramide (see the enclosed screen shot).
Rather than using a pyramide i suggest the use of a gradiant ARGB texture drawn in the first plan. (I can do the ARGB texture for you if you want).

...


Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Charles Pegge

#5
Petr, using the glslValidator tool (very useful), I found the cure for the irritation was to change the 6 to 6.0. or more formally: float(6). The spec requires casting to be very specific.

Patrice, It's those Benassi peaks again! If you look at the vertext shader you will see that I sneaked in some vertex magnification in the y axis but obviously failed to get away with it. But I am delighted it works on your Vista laptop. I infer that shaders are part of the Vista hardware spec.

The best solution will be to dispense with the blue tinting pyramid entirely and generate the shading of the landscape entirely within GLSL . I use the uniform variable 'univar' to pass distance information into the shader. On the Client side, This value is passed from variable 'ds', just before each strip of land is called.


       a.y = a.y * 1.2;



In the fragment shader the // commented out lines are earlier types of shading I tried, so you can see how the final expression evolved.

Thank you both for the feedback.



[VERTEX SHADER]

uniform float univar;


varying vec4 vColor;
varying vec4 vVertex;
varying vec4 vTexCoord;

void main(void)
    {
       vTexCoord = gl_MultiTexCoord0;
       float mm = univar;
       vColor = gl_Color;
       vVertex = gl_Vertex;
       vec4 a = gl_Vertex;
       //a.x = a.x * (mm+0.1); // *(univar+0.1);
       a.y = a.y * 1.2;
       gl_Position = gl_ModelViewProjectionMatrix * a;
    }

[END VERTEX SHADER]


[FRAGMENT SHADER]


uniform float univar;
uniform sampler2D myTexture;

varying vec4 vColor;
varying vec4 vVertex;
varying vec2 vTexCoord;

    void main (void)
    {
      //gl_FragColor = vec4(1.0, 1.0, 0.0, .4);
      //gl_FragColor = vColor*.5;
      //gl_FragColor = vColor*vec4(1,1,vVertex.y+.2,vVertex.y+.2);
      //gl_FragColor = vColor*.2 +vec4(-vVertex.y+.2, -vVertex.y+.5, vVertex.y+.2, .5);
      //gl_FragColor = vColor*.2 +vec4(vVertex.x*.1+.1, -vVertex.y+.5, vVertex.y+.2, vVertex.y+0.1);

      gl_FragColor = vColor*.2 +vec4(vVertex.x*.1+.1, -vVertex.y+.5, vVertex.y+.2, vVertex.y+0.1)
      * univar * 6.0 * texture2D(myTexture, vTexCoord).bgra;
    }

[END FRAGMENT SHADER]

Patrice Terrier

If you read french, here is an excellent GLSL tutorial  :)

GLSL tutorial en français

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Charles Pegge

That was an excellent French tutorial Patrice. :) It is quite a different experience from 'La Plume de ma tante' school French that we had to endure, and I can refer to it whenever I need to understand French computer terminology. The way in which it gradually introduces GLSL concepts with some levity is very good.

Eros Olmi

66 FPS on a laptop both normal window or fullscreen.
thinBasic Script Interpreter - www.thinbasic.com | www.thinbasic.com/community
Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB