Page 1 of 1

Multi-Pass

Posted: Sat Jul 04, 2009 7:38 am
by Kjell
:?

The multi-pass shader "trick" I recently mentioned appears to only work in the Editor. Uniform shader variables aren't updated more then once in standalone builds. Now I don't know what the correct behavior is, but it would be nice if it was consistent between Preview and Build.

Attached - Some screenshots from the Editor.

K

Posted: Sun Jul 05, 2009 2:31 pm
by jph_wacheski
This is some pretty stuff! Are these GLSL generated graphics?

Posted: Sun Jul 05, 2009 2:37 pm
by Kjell
Yes sir :)

Plain screenshots taken from the preview window showing some simple multi-pass GLSL shaders without the use of FBO's ..

.. although FBO's would dramatically increase the potential of shaders in ZGE obviously.

K

Posted: Sun Jul 05, 2009 3:24 pm
by VilleK
I agree, this looks great.

I updated the beta today with a fix to the problem with updating uniform variables. If you set the new property "UpdateVarsOnEachUse" on the shader then the variables will be updated between models. You still need the trick of switching to another material though.

According to a discussion I found on a forum updating uniforms variables can sometimes be slow so it is not a recommended technique for updating hundreds of models every frame.

http://www.opengl.org/discussion_boards ... 667&page=1

Posted: Sun Jul 05, 2009 3:32 pm
by Kjell
Cool,

That did the trick, with the "UpdateVarsOnEachUse" box ticked on the Shaders also render properly in stand-alone builds :) Thanks ~

Another example .. ( fake ) volumetric spot lights.

K

Posted: Sun Jul 05, 2009 3:40 pm
by VilleK
Yup, I meant "between each use" regardless of it is the same model or not.

The default in ZGE is to update shader-variables once every frame but there was an ifdef in the code that updated on every use when in the designer. It should behave consistent now.

Please post an exe if you get it working Kjell, I'd love to see those graphics in motion.

Posted: Sun Jul 05, 2009 3:44 pm
by Kjell
Voila,

A build of the fur shader. Doesn't have any dynamics ( wind, gravity etc. ) .. so it looks a little static and spiky. The artifacts when looking through hairs on the edge of the object towards others is caused by the lack of Z-Sorting ( on mesh level ).

Plus a build of the volumetric spot light shader in action.

K

Posted: Sun Jul 05, 2009 6:02 pm
by jph_wacheski
The fur is great! the spots dont seem to work here? see shot.

Posted: Sun Jul 05, 2009 6:40 pm
by Kjell
Hi jph,

Turned out the spot shader didn't work on my laptop either :? Something to do with unrolling computed assignments to uniform vectors. Anyway, try downloading the re-uploaded Spot.zip from my previous post again, it should work now.

K

vol

Posted: Sun Jul 05, 2009 8:07 pm
by jph_wacheski
Yeah that works great,. and it looks very cool. So this 'fake' volumetric system, is it a series of progressively larger vesions of a light flare faceing the camera?

Somewhat like this (attached)? only sine I lack a 'face towards camera' function,. i am just adding a bunch of random jitter,. this experiment will make for a cool effect to be sure.., probably to be added to The Opium Wallpaper Wars.. , thanks Kj for the insperation!

Oh use the mouse to rotate!

Posted: Sun Jul 05, 2009 8:40 pm
by Kjell
Hi jph,

Basically yes .. it's a similar technique as the fur shader actually.

And here's a cheap "spherical" billboard shader for sprites :wink:

Code: Select all

uniform float angle;
uniform float ratio;

void main()
{  
  vec2 center;
  
  float rx = gl_Vertex.x * cos(angle) + gl_Vertex.y * sin(angle);
  float ry = gl_Vertex.y * cos(angle) - gl_Vertex.x * sin(angle);
  
  center.x = gl_ModelViewProjectionMatrix[3][0]/gl_ModelViewProjectionMatrix[3][3];
  center.y = gl_ModelViewProjectionMatrix[3][1]/gl_ModelViewProjectionMatrix[3][3];
  
  gl_Position.x = center.x + rx/gl_ModelViewProjectionMatrix[3][3];
  gl_Position.y = center.y + ry/gl_ModelViewProjectionMatrix[3][3]*ratio;
}
K