Author Topic: GLSL - The OpenGL Shader Language: for 2d and 3d SFX  (Read 15346 times)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
They must render the model twice with different shaders then. There's no GLSL extension function hidden that you can't use with GLBasic.

Rendered to backbuffer, then more shaders are reapplied, thats how shaders work.

The first pass.....has 3 shaders
The second has 6 shaders.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
OK, then you must do that manually. But you can.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Do Like this?

X_SETSHADER 1
X_SETSHADER 2
X_SETSHADER 3
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
no. That will exchange the shaders. You only can set one shader per rendering.
X_SETSHADER 1
X_DRAWOBJ
X_SETSHADER 2
X_DRAWOBJ ...

(maybe) I have no idea what RenderMonkey really does.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Ahh, ya that wont work correctly, youll get the surfaces z-fighting.

I have been reading the opengl glsl specifications.

The language links multiple programs (verts and frags).

Get the rendermonkey from AMD.com, its awesome!
Youll certainly be amazed at what opengl is capable of now.
Try the fur project, and the ooze project.....tons of eye candy.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
I can't find _any_ command that enables multiple. Or is it just linking a bunch of "object" files, that produce one shader then?
You only can have _one_ main() for a shader and only one shader per pixel.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
hmmm i checked it out ....

youre right, it is only passing 1 vert and 1 frag.

i was confused by the way the program works, sorry for troubling you.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Here is my current project, as i wait patiently for point sprites :whistle:


First off, I have successfully created a 2d animated background using a shader.
Therefore i am moving on to animation in 3d.

The effect im attempting to achieve is going to have a "flowing fur" effect.

Here is a screenshot showing this in action:




[attachment deleted by admin]
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile

Im trying to load a  "3d texture", it is named NoiseVolume.dds
This format .dds is not glbasic, and it isnt .3dstudio.
I have no clue, i cant find this extension on the search engines.

a 3d texture:
 .dds
8bit L8
and from what i understand,
it is 128x128x128 dimensions, and it has 8 mip map layers.

This file is needs to be loaded using uniform sampler3D filename

The shader needs to read this file in the frag program.
I dont need to render it to the screen, i dont even think it is a regular 3d object, it seems to be "special"

How do i load the sampler3d? x_putshader "sampler3D", filename$   ? ?

Do you think this why the shader fails? Am i not loading it correctly?
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
 :S
I have no idea about 3D textures. Really.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
LOL  :'(


x_putshader "sampler3D", filename$   ? ?

Integer ID ? String$ ID ?

What is the input type?

I need to know what to pass through to load it.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10697
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
I only support "uniform float".
You can't load a shader file within a shader, can you?

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
No it must be a numeric value, i assume an integer, but somehow GLBasic needs to tell the shader what to load.
Its like loading a texture with sampler2d i think.
TextureID1 and TextureID2 i assume are integers, and they are pointing to some file.
I think we need Texture3d1 or something..

These all get loaded the same way i think:

sampler1D
sampler2D
sampler3D
samplerCube
sampler1DShadow
sampler2DShadow

I think we need a naming convention of constants and pointers to files loaded with opengl here:

GLB_sampler1D
GLB_sampler2Da
GLB_sampler2Db
GLB_sampler3D
GLB_samplerCube
GLB_sampler1DShadow
GLB_sampler2DShadow

Quote
4.1.7 Samplers
Sampler types (e.g. sampler2D) are effectively opaque handles to textures. They are used with the builtin
texture functions (described in Section 8.7 “Texture Lookup Functions” ) to specify which texture to
access. They can only be declared as function parameters or uniform variables (see Section 4.3.5
“Uniform” ). Except for array indexing, structure field selection, and parentheses, samplers are not
allowed to be operands in expressions. Samplers cannot be treated as l-values; hence cannot be used as
out or inout function parameters, nor can they be assigned into. As uniforms, they are initialized only
with the OpenGL API; they cannot be declared with an initializer in a shader. As function parameters,
only samplers may be passed to samplers of matching type. This enables consistency checking between
shader texture accesses and OpenGL texture state before a shader is run.
« Last Edit: 2009-Oct-14 by Hemlos »
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1634
  • Particle Hawk
    • View Profile
Sorry it took so long guys...but i finally got the bright shader working proper.
It is the download in the first message of this thread.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)