Multi-Pass

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Multi-Pass

Post 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
Attachments
Fur.jpg
Fur.jpg (12 KiB) Viewed 9985 times
Glow.jpg
Glow.jpg (35.24 KiB) Viewed 9988 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

This is some pretty stuff! Are these GLSL generated graphics?
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post 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
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Spot.jpg
Spot.jpg (10.8 KiB) Viewed 9965 times
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post 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.
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Attachments
Spot.zip
(43.11 KiB) Downloaded 619 times
Fur.zip
(42.97 KiB) Downloaded 620 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

The fur is great! the spots dont seem to work here? see shot.
Attachments
shot.jpg
shot.jpg (11.51 KiB) Viewed 9935 times
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

vol

Post 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!
Attachments
jitter_beam_vol.zip
.zgeproj
(1.28 KiB) Downloaded 478 times
iterationGAMES.com
User avatar
Kjell
Posts: 1876
Joined: Sat Feb 23, 2008 11:15 pm

Post 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
Post Reply