Posted: Tue Oct 16, 2007 5:40 pm
Too retro?
For information and discussion about Oolite.
https://bb.oolite.space/
Code: Select all
shaders =
{
"yah03.png" =
{
vertex_shader = "animatedandnon-animatedwithspec.vertex";
fragment_shader = "animatedandnon-animatedwithspec.fragment";
textures = ("yah03a.png", "yah03.png");
uniforms =
{
uTime = "timeElapsedSinceSpawn";
};
};
};
Code: Select all
// Information from Oolite.
uniform sampler2D tex0; // Animated Map
uniform sampler2D tex1; // Non-animated Map
uniform float uTime;
// Control factors.
const float kTimePerFrame = 0.8;
const float kFrameCount = 2.0;
const float specExponent = 5.0;
const float specIntensity = 0.5;
// Derived constants.
const float kAnimCycleTime = kTimePerFrame * kFrameCount;
// Information from vertex shader.
varying vec3 v_normal; // Surface normal
varying vec3 v_pos; // Vertex/fragment position in eye space
// Calculate the contribution of a single light. Ought to be a function, but OS X's GLSlang implementation isn't sufficiently clever.
#define LIGHT(idx) \
{ \
vec3 lightVector = normalize(gl_LightSource[idx].position.xyz); \
vec3 reflection = normalize(-reflect(lightVector, v_normal)); \
diffuse += gl_FrontMaterial.diffuse * gl_LightSource[idx].diffuse * max(dot(v_normal, lightVector), 0.0); \
specular += gl_LightSource[idx].diffuse * pow(max(dot(reflection, eyeVector), 0.0), specExponent); \
}
void main()
{
vec4 diffuse = vec4(0.0), specular = vec4(0.0);
vec3 eyeVector = normalize(-v_pos);
// Load texture data
vec2 fixedcoord = gl_TexCoord[0].st;
vec2 animatedcoord = fixedcoord;
// Do Maths stuff on animatedcoord to select an animation frame.
animatedcoord.t += floor(mod(uTime, kAnimCycleTime) / kTimePerFrame);
// Scale texture co-ordinates to 0..1
animatedcoord.t /= kFrameCount;
vec4 animatedMap = texture2D(tex0, animatedcoord);
vec4 nonanimatedMap = texture2D(tex1, fixedcoord);
/* Light 0 is the "showroom" light, used in the demo screen and shipyard.
Light 1 is the sun.
*/
#ifdef OO_LIGHT_0_FIX
LIGHT(0);
#endif
LIGHT(1);
diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient;
vec4 color = animatedMap;
color += nonanimatedMap;
gl_FragColor = color + specular * specIntensity;
}
Code: Select all
// Information from Oolite.
varying vec3 v_normal; // Surface normal
varying vec3 v_pos; // Vertex/fragment position in eye space
void main(void)
{
v_normal = normalize(gl_NormalMatrix * gl_Normal);
v_pos = vec3(gl_ModelViewMatrix * gl_Vertex);
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}
You might recall that the animated shader is a spin-off of my Shady Billboards shader. Which has advanced significantly, and basically hasn’t been released for ages because I wanted to comment the shader code extensively, and also wanted to try some optimizations, but haven’t bothered to get around to finishing it. So here it is anyway:Arexack_Heretic wrote:It would be entirely possible.
Although I suggest leaving the neon signs for what they are and concentrate on the TV-projection aspect.
Use Griff's latest 'monster'shader.
pro:
-it has a bright background texture + animated textures projected on top.
con:
-It requires v1.69+ to work smoothly.
-animated billboards are more than double the work.
Well... I can't think of a backstory. It just seemed like a good idea at the time. I really wanted to find a picture of a woman looking horrified and -- most importantly -- up and back, as if she's being attacked by Godzilla (or a giant tulip), but the only one I could get was black and white and searching for pictures of women on the the internet gets pretty depressing, pretty fast... so I thought "she'll do", coloured her purple and stuck her on. It's called "the creative process".Arexack_Heretic wrote:What are those?
the botanical equivalent of a bombletter?
she's screaming and turned all purple,
secondly the logo looks like a guy doing a sidekick.
So... instead of singing telegram this delivery guy kicks you in the reproductive organs, then shoves a bunch of poisonous photosynthetic-species' equivalents of said organs in your face?
That will teach her to think we are figments of her imagination!
darn solipsists.
Or, for that matter, he. This is indeed a disturbing universe.Disembodied wrote:In retrospect, it's possible that she's a blue bony humanoid from Enrienge, and that's what they look like when aroused by the thoughtfulness and spending power of a prospective mate.
True enough... here's another hairy individual of indeterminate gender:Ahruman wrote:Or, for that matter, he. This is indeed a disturbing universe.
I just thought of another problem: ahruman-billboard-bsod.fragment hasn’t been updated to match ahruman-billboard.fragment. Oh, and the use of fwidth() to interpolate between the fancy screen effect and a scaled texture (to reduce aliasing effects) doesn’t work properly in the OS X software renderer, which suggests it may have problems with some hardware.Ahruman wrote:…Shady Billboards shader. Which has advanced significantly, and basically hasn’t been released for ages because I wanted to comment the shader code extensively, and also wanted to try some optimizations, but haven’t bothered to get around to finishing it.
Disembodied wrote:searching for pictures of women on the the internet gets pretty depressing, pretty fast...
Not in suits, no, not that I could find anyway. Although that's not to say there might not be at some point in the future: they'd be easier to fiddle with the colours...Arexack_Heretic wrote:no orange furry humanoids?