Author Topic: BassBox SoundscapeGLSL plugin the 1st  (Read 9641 times)

0 Members and 1 Guest are viewing this topic.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
  • User-Rate: +27/-1
    • Charles Pegge
BassBox SoundscapeGLSL plugin the 1st
« on: January 26, 2008, 12:18:06 AM »
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!)
« Last Edit: January 26, 2008, 12:37:17 AM by Charles Pegge »

Offline Kent Sarikaya

  • Full Member
  • ***
  • Posts: 174
  • User-Rate: +8/-4
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #1 on: January 26, 2008, 06:46:55 AM »
Charles, great job, runs very smoothly even fullscreen!!

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
  • User-Rate: +27/-1
    • Charles Pegge
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #2 on: January 26, 2008, 07:36:01 AM »
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.

Offline Petr Schreiber

  • Full Member
  • ***
  • Posts: 183
  • User-Rate: +14/-4
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #3 on: January 26, 2008, 11:18:13 AM »
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

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #4 on: January 26, 2008, 12:31:39 PM »
--Charles

Quote
I 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

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
  • User-Rate: +27/-1
    • Charles Pegge
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #5 on: January 26, 2008, 01:07:59 PM »
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.

Code: [Select]
       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.


Code: [Select]
[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]
« Last Edit: January 26, 2008, 01:10:43 PM by Charles Pegge »

Offline Patrice Terrier

  • ROMs
  • Hero Member
  • *****
  • Posts: 936
  • User-Rate: +62/-1
    • www.zapsolution.com
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #6 on: January 26, 2008, 06:05:20 PM »
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

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 672
  • User-Rate: +27/-1
    • Charles Pegge
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #7 on: January 27, 2008, 11:05:17 AM »
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.

Offline Eros Olmi

  • Full Member
  • ***
  • Posts: 243
  • User-Rate: +18/-7
    • thinBasic
Re: BassBox SoundscapeGLSL plugin the 1st
« Reply #8 on: January 27, 2008, 12:31:32 PM »
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