Page 1 of 1

Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 5:38 am
by C..
Since animMap shaders are bugged, (server uptime >24h == animMaps are static), it makes them pretty useless.
However, an animated shader can often make things more fancy.
I was busy creating an animated shader that does not use animMap at all, but is still animated.

It is possible to use up to 8 render-passes in a shader.
My example shader has 1 base texture + 7 animation frames.
All frames of the animation are packed into 1 texture. (The texture is included in the pk3. The pk3 was made for ET.. but shaders should be useful for Q3 also.)

The shader itself does a lot of number fiddling, it might need some explaining..
* "tcMod transform" is used to get one of the 7 images of the texture. (the T coordinate is transformed so it starts at the "Y"-position of each sub-texture).
* alphaGen is used to alternate the texture translucency
* rgbGen is used to make the texture colors alternate black/normal
* blendfunc add is used, in the example case, to add the texture to the screen. Blending a black texture this way will have no visual effect, a normal colored texture will be seen on screen..

By choosing the correct intervals at which alpha-values and rgb-colors are changing, You can make only 1 of the 7 images be visible at a time..

In the example i use "wave sine" because it looked well on the caustic effect. When using "wave Square" the transition is immediate.

I prepared a little pk3 for download..
(You can put it in etmain and run the map.. The map is called "anim_shader_demo")

The pk3 includes 4 demo shaders:

Three caustics shader variations:
* 8 frames no lightmap,
* 7 frames + lightmap,
* 7 frames animation + extra tcmod

One special shader that displays the current framenumber of the shader at a low frequency. (So You can clearly see it is really displaying 7 seperate images in an animated sequence (+ a lightmap))..

-------------------------------------------------------------------------------------------------------------------------------
Here is the download link: http://members.home.nl/core/ETpro/anim_shader_demo.pk3
-------------------------------------------------------------------------------------------------------------------------------

Image

Greetings,
C..

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 7:00 am
by obsidian
The rather big footnote here should be that because it uses 8 rendering passes, it could be a rather large performance hit. Might be useful for some people, though.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 8:53 am
by Eraser
Should this be in LEM?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 12:38 pm
by Bliccer
Could someone post a youtube movie, since I don't have q3a here, right now, but I am very eager to see it.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 12:51 pm
by Eraser
While I haven't actually seen it, I imagine it's just an animated texture, nothing special to see. It's the underlying method that makes it interesting, amirite?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 2:29 pm
by VolumetricSteve
I tried recompiling and switching things around to make this work in quake 3, I got kinda close.

http://sirventolin.webs.com/shaderdemo.jpg

I could force all that to work, I'm sure....in fact, the ability to do this could be useful to my future quake 3 maps, but you really should post a video somewhere that walks through the code and demonstrates the working process of what you've done.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 4:35 pm
by C..
The rather big footnote here should be that because it uses 8 rendering passes, it could be a rather large performance hit
Very true..
It's the underlying method that makes it interesting
That is the only thing i want to illustrate. The technique of using alphaGen,rgbGen & wave functions to make a certain shader-stage be displayed at a calculated time and for a calculated duration..
I never meant to show a fancy looking shader. The aesthetic value of the demo shader is just a side issue..
The same technique could be used for just 1 frame, (which wouldn't be a big performance hit).. perhaps to make blinking control-lights for a shader of some electrical device.

Link to the original topic: http://www.splashdamage.com/forums/show ... hp?t=22485

^^in that link i displayed some ASCII-"art" image of the alphaGen & rgbGen blockwaves, but when i think about it, the description is not entirely correct.

Code: Select all

  ___     ___
 |   |   |   |
_|   |___|   |___    alphaGen
     ___     ___
    |   |   |   |
   _|   |___|   |___ rgbGen

     #       #       frame displayed when alpha && rgb are both at max.
By shifting the phase of the rgbGen wave a bit to the right,
the duration at which both waves are at max. will be shorter..
Changing the rgbGen phase determines the duration of a frame being visible.
The (same) frequency of both waves determine the speed at which the animation starts a new loop.

..

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Mon Nov 29, 2010 4:44 pm
by Bliccer
Hm. Why not use a roq video file for such a thing? Size I guess...
And I've never seen it, but you say that if the server is up more than 24h then the animmap texture doesn't move a bit anymore, right? Also if you switch the maps?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Tue Nov 30, 2010 8:17 am
by Eraser
Bliccer wrote:Hm. Why not use a roq video file for such a thing? Size I guess...
ROQ video is heavily compressed. You'd see massive compression artifacts in your texture. It's also possibly an even bigger performance hit than an 8 stage shader.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Tue Nov 30, 2010 3:56 pm
by obsidian
ROQ is probably more processor and memory intensive, 8 stages is heavier on GPU.

I've never heard of this bug and the OP never answered if this bug affects a server or map with 24 hour up time. If the latter, this almost never happens with Q3 since servers usually cycle between maps.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Tue Nov 30, 2010 6:22 pm
by VolumetricSteve
That sounds true, considering the time Quake 3 was programed in. What was the original goal of this project, C..? Are you just trying to circumvent the bug you found? Or are you doing this mostly for funzies? I'm a funzies kind of person myself, but considering it's 2010, aren't we talking about how Quake 3 (probably ioquake3) will perform on computers that are easily ten times faster than the computers we had when quake 3 was being built? It's still a valid point of consideration if you want everything to be a certain way, but is the issue at hand really still an issue?
obsidian wrote:I've never heard of this bug and the OP never answered if this bug affects a server or map with 24 hour up time. If the latter, this almost never happens with Q3 since servers usually cycle between maps.
(comment directed at C.. but in reference to what obsidian said)
And about that bug, I've never seen it myself, nor have I heard of it until now, perhaps ioquake3 fixes that bug that may have been present in q3-1.32c?

...Do RoQ files take lightmaps? I've never seen a "video screen" in quake 3 that looked like the environment effected it, which might be a good reason to try to rig up 8 shader passes IF the animmap bug is something that can be clearly demonstrated.

Practical or not, it's still kinda neat that 8 shader passes can be done and figuring it out this way must have taken some elbow grease.

Hypothetically, how far could this be pushed? is 8 where it kinda maxes out?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Wed Dec 01, 2010 5:13 am
by C..
What was the original goal of this project, C..? Are you just trying to circumvent the bug you found? Or are you doing this mostly for funzies?
Well,.. for both reasons actually.
I must mention that i never played Quake, ioq, or anything else.. i played Wolfenstein ET. That game still uses old old code.
In ET there is no fancy new engine (which is noticale sometimes.. renderspeed is relatively low in comparison to today's games, because old techniques are used and less HW-support).
ET code (and all the mods) is still full of old bugs.. :S the animMap is just one of them.

offtopic: The bug was not found by me. Perhaps the games You people play don't even have the bug.. i simply don't know.
I do know that in ET, it causes the animMaps to stop working and become static images..
I found a link to a forum explaining exactly what bug i was telling about. They even show the fix:
h t t p : / / forums.wireheadstudios.org/index.php?act=ST&f=11&t=2749
(i cannot see the content of the forum, unless i register.. so i did. I must only wait for the admin to reply, before i can crawl the forum..)

It was only my intension to show a creative use of alpgaGen & rgbGen. How one can make a shader-stage display its image at a calculated moment, for a calculated duration.
Creating animations with the technique is just another use of it.. combining several of those alpha/rgbGen passes, all with a different phase.
It's not my taste of shader, if You ask me, because of obvious reasons mentioned before.
I can imagine for people that can use animMaps without any trouble, the topic-title is not much appealing.. (why do so much trouble in a shader if it can be done easily with an animMap?).
To make it more interesting for those: It might be possible to make a shader with multiple stages, and have an animMap in every stage. Then use the alphaGen/rgbGen to display only 1 of the stages at a time. This way You can make a very long animMap.
how far could this be pushed? is 8 where it kinda maxes out?
I tried it in ET. 8 render-passes appeared to be the max (which is already insane).
Never before have i tested howmany shader-stages can use an animMap, nor howmany frames/images a single animMap supports.
My guess is, it'll work. But it would really be extreme.. but fun.

..

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Wed Dec 01, 2010 7:13 am
by mrd
Cool stuff, C..

Your use of phase shifting to achieve a desired output reminds me of audio engineering, which is my home turf. In audio, it's generally the opposite, though. You tweak phases to cut out certain frequencies. Either way, interesting read. And interesting that this kind of stuff is still coming out of the woodwork, almost 12 years later!

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Wed Dec 01, 2010 7:55 am
by Eraser
I know about the frozen animMaps thing. We had a Freeze Tag server running ages ago which had this problem. I'm not sure if a map change fixed it, I think it didn't actually. Maybe id Software fixed it in one of the point releases though?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Fri Dec 03, 2010 10:14 pm
by TTI
obsidian wrote:ROQ is probably more processor and memory intensive, 8 stages is heavier on GPU.
Also, Q3 can decode only one ROQ at a time, which means bye bye to videoMap TV screens, if you're going to use them simultaneously with the ROQ flames, or whatever you use them for.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Sat Dec 04, 2010 7:17 am
by Theftbot
Use multiple architecture&triggerable shaders.

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Thu Dec 09, 2010 12:17 pm
by Quack
I've never seen this bug myself so I'm not sure if this would work. If you use a triggerable shader and change to a shader with an animMap, the animMap will reset to the first frame of the animMap's sequence. If you make the level reset the animMap's shader with a triggerable shader when the level restarts or loads, would this possibly fix the problem of static animMaps after 24h of uptime?

Re: Up to 8 frames animated shaders, without using animMap..

Posted: Fri Dec 10, 2010 10:02 pm
by monaster
Holy... It's Quack! Hi there!