Shaders’ Outpost

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

the freakythargoids are working but there's no heat glow or cooling effect on the alloys, has the version available to download been updated, you mention v1.69.1 but the one i see available for download is listed as v1.69, that's the one i've got and i downloaded it the day it was first announced
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

1.69.1 was a typo.

Oops, the glowing alloy wasn’t using the final 1.69 syntax; I’ve uploaded a new version.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

bad news i'm afraid, i'm not seeing the heat glow effect in that version either
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

But the Freaky Thargoids (Freaky Thargoids 3.oxp) are animating? How annoyingly inconsistent.

It'd be helpful if you could run with shader debug messages on (press S while paused, before blowing something up to get the fragments, or set ”$shaderDebug” to “yes” in logcontrol.plist) and post the log.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Hi Ahruman, sorry for the delay i wondered off to watch the 'Live Earth' gig. Well this is odd, since i changed my graphics card from an ATI to a nvidia one i've just found out that a lot of the shader stuff i was working on in rendermonkey no longer compile properly giving errors similar to the ones in the log below, this must be the fault of my new graphics card as these were working before. drat, i'll try a different graphics driver (i've got a beta one installed at the moment)

here's the log:-

Code: Select all


2007-07-07 22:48:13.000 oolite.exe[1336] File NSUserDefaults.m: 544. In [NSUserDefaults +standardUserDefaults] Improper installation: No language locale found
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: initialising SDL
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.JoystickHandler]: init: numSticks=1
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: CREATING MODE LIST
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Unknown architecture, defaulting to 1024x768
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 1280 x 1024
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 1152 x 864
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 1024 x 768
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 800 x 600
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 640 x 480
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 512 x 384
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 480 x 360
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 400 x 300
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Added res 320 x 240
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Found mode {Height = 1024; RefreshRate = 0; Width = 1280; }
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: drawRect calling initialiseGLWithSize
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: Creating a new surface of 1280 x 1024
2007-07-07 22:48:13.000 oolite.exe[1336] [unclassified.MyOpenGLView]: no universe, clearning surface
2007-07-07 22:48:13.000 oolite.exe[1336] [cpuInfo.cpuCount]: 2 processors detected.
2007-07-07 22:48:13.000 oolite.exe[1336] [rendering.opengl.version]: OpenGL renderer version: 2.1.1 ("2.1.1")
Vendor: NVIDIA Corporation
Renderer: GeForce 8800 GTS/PCI/SSE2
2007-07-07 22:48:13.000 oolite.exe[1336] [rendering.opengl.extensions]: OpenGL extensions (145):
GL_ARB_color_buffer_float GL_ARB_depth_texture GL_ARB_draw_buffers GL_ARB_fragment_program GL_ARB_fragment_program_shadow GL_ARB_fragment_shader GL_ARB_half_float_pixel GL_ARB_imaging GL_ARB_multisample GL_ARB_multitexture GL_ARB_occlusion_query GL_ARB_pixel_buffer_object GL_ARB_point_parameters GL_ARB_point_sprite GL_ARB_shadow GL_ARB_shader_objects GL_ARB_shading_language_100 GL_ARB_texture_border_clamp GL_ARB_texture_compression GL_ARB_texture_cube_map GL_ARB_texture_env_add GL_ARB_texture_env_combine GL_ARB_texture_env_dot3 GL_ARB_texture_float GL_ARB_texture_mirrored_repeat GL_ARB_texture_non_power_of_two GL_ARB_texture_rectangle GL_ARB_transpose_matrix GL_ARB_vertex_buffer_object GL_ARB_vertex_program GL_ARB_vertex_shader GL_ARB_window_pos GL_ATI_draw_buffers GL_ATI_texture_float GL_ATI_texture_mirror_once GL_S3_s3tc GL_EXT_texture_env_add GL_EXT_abgr GL_EXT_bgra GL_EXT_blend_color GL_EXT_blend_equation_separate GL_EXT_blend_func_separate GL_EXT_blend_minmax GL_EXT_blend_subtract GL_EXT_compiled_vertex_array GL_EXT_Cg_shader GL_EXT_bindable_uniform GL_EXT_depth_bounds_test GL_EXT_draw_buffers2 GL_EXT_draw_instanced GL_EXT_draw_range_elements GL_EXT_fog_coord GL_EXT_framebuffer_blit GL_EXT_framebuffer_multisample GL_EXT_framebuffer_object GL_EXTX_framebuffer_mixed_formats GL_EXT_framebuffer_sRGB GL_EXT_geometry_shader4 GL_EXT_gpu_program_parameters GL_EXT_gpu_shader4 GL_EXT_multi_draw_arrays GL_EXT_packed_depth_stencil GL_EXT_packed_float GL_EXT_packed_pixels GL_EXT_pixel_buffer_object GL_EXT_point_parameters GL_EXT_rescale_normal GL_EXT_secondary_color GL_EXT_separate_specular_color GL_EXT_shadow_funcs GL_EXT_stencil_two_side GL_EXT_stencil_wrap GL_EXT_texture3D GL_EXT_texture_array GL_EXT_texture_buffer_object GL_EXT_texture_compression_latc GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp GL_EXT_texture_env_combine GL_EXT_texture_env_dot3 GL_EXT_texture_filter_anisotropic GL_EXT_texture_integer GL_EXT_texture_lod GL_EXT_texture_lod_bias GL_EXT_texture_mirror_clamp GL_EXT_texture_object GL_EXT_texture_sRGB GL_EXT_texture_shared_exponent GL_EXT_timer_query GL_EXT_vertex_array GL_IBM_rasterpos_clip GL_IBM_texture_mirrored_repeat GL_KTX_buffer_region GL_NV_blend_square GL_NV_copy_depth_to_color GL_NV_depth_buffer_float GL_NV_conditional_render GL_NV_depth_clamp GL_NV_fence GL_NV_float_buffer GL_NV_fog_distance GL_NV_fragment_program GL_NV_fragment_program_option GL_NV_fragment_program2 GL_NV_framebuffer_multisample_coverage GL_NV_geometry_shader4 GL_NV_gpu_program4 GL_NV_half_float GL_NV_light_max_exponent GL_NV_multisample_filter_hint GL_NV_occlusion_query GL_NV_packed_depth_stencil GL_NV_parameter_buffer_object GL_NV_pixel_data_range GL_NV_point_sprite GL_NV_primitive_restart GL_NV_register_combiners GL_NV_register_combiners2 GL_NV_texgen_reflection GL_NV_texture_compression_vtc GL_NV_texture_env_combine4 GL_NV_texture_expand_normal GL_NV_texture_rectangle GL_NV_texture_shader GL_NV_texture_shader2 GL_NV_texture_shader3 GL_NV_transform_feedback GL_NV_vertex_array_range GL_NV_vertex_array_range2 GL_NV_vertex_program GL_NV_vertex_program1_1 GL_NV_vertex_program2 GL_NV_vertex_program2_option GL_NV_vertex_program3 GL_NVX_conditional_render GL_SGIS_generate_mipmap GL_SGIS_texture_lod GL_SGIX_depth_texture GL_SGIX_shadow GL_SUN_slice_accum GL_WIN_swap_hint WGL_EXT_swap_control 
2007-07-07 22:48:13.000 oolite.exe[1336] [dataCache.found]: Found data cache.
2007-07-07 22:48:13.000 oolite.exe[1336] [searchPaths.dumpAll]: ---> OXP search paths:
(oolite.app/Resources, AddOns, "AddOns/Freaky Thargoids 3.oxp", AddOns/glow_alloy_mod.oxp, AddOns/Griff_shaded_cargopod.oxp, AddOns/supercobra.oxp)
2007-07-07 22:48:13.000 oolite.exe[1336] [dataCache.upToDate]: Data cache is up to date.
2007-07-07 22:48:13.000 oolite.exe[1336] [script.load.world.listAll]: Loaded 7 world scripts: "oolite-cloaking-device" 1.69, "oolite-constrictor-hunt" 1.69, "oolite-nova" 1.69, "oolite-thargoid-plans" 1.69, "oolite-trumbles" 1.69, "Spawn-griff_cargopod" 1.0.1, "supercobra_placement"
2007-07-07 22:48:14.000 oolite.exe[1336] [dataCache.willWrite]: About to write data cache.
2007-07-07 22:48:14.000 oolite.exe[1336] [dataCache.write.success]: Wrote data cache.
2007-07-07 22:48:14.000 oolite.exe[1336] [rendering.opengl.error]: OpenGL error: "invalid enumerant" (1280), context: Universe before doing anything
2007-07-07 22:48:20.000 oolite.exe[1336] [testscript.spawn]: Generated 6 griff_cargopod for testing purposes.
2007-07-07 22:48:41.000 oolite.exe[1336] [shader.compile.fragment.failure]: ***** GLSL fragment shader compilation failed:
>>>>> GLSL log:
(78) : error C0000: syntax error, unexpected "+=" at token "+="
(78) : error C0501: type name expected at token "+="
(78) : warning C7022: unrecognized profile specifier "diffuse"
(78) : warning C7528: OpenGL reserves names starting with 'gl_'
(78) : error C1307: non constant expression for array size
(78) : warning C7528: OpenGL reserves names starting with 'gl_'
(78) : error C0000: syntax error, unexpected '.', expecting ';' or ',' at token "."
(78) : error C0501: type name expected at token "."
(78) : error C0000: syntax error, unexpected '(' at token "("
(78) : error C0501: type name expected at token "("
(78) : warning C7022: unrecognized profile specifier "dot"
(78) : error C0000: syntax error, unexpected ')' at token ")"
(78) : error C0501: type name expected at token ")"
(78) : warning C7022: unrecognized profile specifier "lightVector"
(79) : error C1307: non constant expression for array size
(79) : error C0000: syntax error, unexpected '.', expecting ',' or ')' at token "."
(79) : error C0501: type name expected at token "."
(79) : error C0000: syntax error, unexpected '(' at token "("
(79) : error C0501: type name expected at token "("
(79) : warning C7022: unrecognized profile specifier "max"
(79) : error C0000: syntax error, unexpected ',' at token ","
(79) : error C0501: type name expected at token ","
(79) : warning C7022: unrecognized profile specifier "reflection"
(79) : error C1109: function type not allowed for parameter "dot"
(79) : error C0000: syntax error, unexpected floating point constant at token "<undefined>"
(79) : error C0501: type name expected at token "<undefined>"
(79) : error C1109: function type not allowed for parameter "pow"
(84) : error C1109: function type not allowed for parameter "main"
(84) : error C0000: syntax error, unexpected '{', expecting ',' or ')' at token "{"
(84) : error C0501: type name expected at token "{"
(85) : error C0000: syntax error, unexpected '=' at token "="
(85) : error C0501: type name expected at token "="
(85) : warning C7022: unrecognized profile specifier "specular"
(85) : error C1109: function type not allowed for parameter "vec4"
(86) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(86) : error C0501: type name expected at token ";"
(89) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(89) : error C0501: type name expected at token ";"
(90) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(90) : error C0501: type name expected at token ";"
(91) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(91) : error C0501: type name expected at token ";"
(92) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(92) : error C0501: type name expected at token ";"
(93) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(93) : error C0501: type name expected at token ";"
(107) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(107) : error C0501: type name expected at token ";"
(107) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(107) : error C0501: type name expected at token ";"
(110) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(110) : error C0501: type name expected at token ";"
(112) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(112) : error C0501: type name expected at token ";"
(113) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(113) : error C0501: type name expected at token ";"
(115) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(115) : error C0501: type name expected at token ";"
(116) : error C0000: syntax error, unexpected '*' at token "*"
(116) : error C0501: type name expected at token "*"
(116) : warning C7022: unrecognized profile specifier "metalTemperature"
(116) : error C1109: function type not allowed for parameter "MetalGlow"
(119) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(119) : error C0501: type name expected at token ";"
(120) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(120) : error C0501: type name expected at token ";"
(121) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(121) : error C0501: type name expected at token ";"
(122) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(122) : error C0501: type name expected at token ";"
(124) : error C0000: syntax error, unexpected ')' at token ")"
(124) : error C0501: type name expected at token ")"
(124) : warning C7022: unrecognized profile specifier "FinalTemperature"
(126) : error C0000: syntax error, unexpected ';', expecting ',' or ')' at token ";"
(126) : error C0501: type name expected at token ";"


>>>>> GLSL source code:
#define OO_ENGINE_LEVEL  1
#define OO_TIME  1
#define OO_ENTITY_PERSONALITY  1
#define OO_TEXTURE_UNIT_COUNT  4
#define OO_HULL_HEAT_LEVEL  1
#define OO_ENTITY_LASER_HEAT_LEVEL  1
#define OO_USER_DEFINED_BINDINGS  1
#define OO_ENTITY_PERSONALITY_INT  1


// Information from Oolite.

uniform sampler2D		tex0;

uniform sampler2D		tex1;



uniform float			time;

uniform float			timeElapsedSinceSpawn;



const float				kInitialHeat = 1.3;

const float				kFadeTime = 5.0;	// seconds



const float				kFadeFactor = kInitialHeat / kFadeTime;



// Information from vertex shader.

varying vec3			v_normal;			// Surface normal

varying vec3			v_pos;				// Vertex/fragment position in eye space





// Calculates the levels of R, G & B that make up the glow effect (MetalGlow), going from black through reddish-brown/dark orange to yellow-white. Red channel in effects map png proportional to level of effect.

vec4 MetalGlow(float level)

{

	vec4 result;

	

	result.r = level;

	result.g = level * level;

	result.b = max(level - 0.55, 0.0) * 2.0;

	result.a = 1.0;

	

	return result;

}



#define OO_REDUCED_COMPLEXITY



#ifdef OO_REDUCED_COMPLEXITY 

#define Pulse(v, ts) ((v) * 0.95) 

#else

 

float Pulse(float value, float timeScale) 

{ 

    float t = time * timeScale; // multiplier on end of this line increases the flicker effect  

    

    float s0 = t; 

    s0 -= floor(s0); 

    float sum = abs( s0 - 0.5); 

    

    float s1 = t * 1.7 - 0.05; 

    s1 -= floor(s1); 

    sum += abs(s1 - 0.5); 

    

    float s2 = t * 2.3 - 0.3; 

    s2 -= floor(s2); 

    sum += abs(s2 - 0.5); 

    

    float s3 = t * 5.09; 

    s3 -= floor(s3); 

    sum += abs(s3 - 0.5); 

    

    return (sum * 0.25) * value; 

} 

#endif





// 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(void)

{

	vec4 diffuse = vec4(0.0), specular = vec4(0.0);

	vec3 eyeVector = normalize(-v_pos);

	

	// Load texture data

	vec2 texCoord = gl_TexCoord[0].st;

	vec4 ColorMap = texture2D(tex0, texCoord);

	vec4 EffectsMap = texture2D(tex1, texCoord); // multiplier on the end of this line to intensify the heat effect. Add if range clamped between 0.0 & 1.0 does not produce enough 'heat'

	float specExponent = EffectsMap.b * 200.0 + 1.0;

	float specIntensity = EffectsMap.g * 1.2;

	

	/*  Light 0 is the "showroom" light, used in the demo screen and shipyard.

		Light 0 is currently disabled, because there's no way for the shader

		to know when it's turned off. The solution for this will probably be

		for Oolite to set its diffuse and specular components to black when

		it's not being used. When this is done, Oolite will define

		OO_LIGHT_0_FIX.

		

		Light 1 is the sun.

	*/

#ifdef OO_LIGHT_0_FIX

	LIGHT(0);

#endif

	LIGHT(1);

	

	diffuse += gl_FrontMaterial.ambient * gl_LightModel.ambient; 

	vec4 color = diffuse * ColorMap + specular * specIntensity;

	

	float HeatAlphaR = EffectsMap.r * 2.0; // add a multiplier to this line to intensify the effect

	float HeatAlphaB = EffectsMap.r * 0.05; // add a multiplier to this line to intensify the effect

	

	float metalTemperature = max(0.0, kInitialHeat - kFadeFactor * timeElapsedSinceSpawn);

	color += MetalGlow(metalTemperature * HeatAlphaR + HeatAlphaB);

	

	// ...and heat effects

	float Heat = max(metalTemperature - 0.5, 0.0) * 2.0;

	Heat = Pulse(metalTemperature, 0.1);

	float Heat2 = Pulse(metalTemperature, 0.5); 

	float FinalTemperature = ((Heat + metalTemperature * HeatAlphaR) * HeatAlphaB) + ((Heat2 + metalTemperature * HeatAlphaB) * HeatAlphaR);  // put a "/ HeatAlphaR" at end of this line, makes a coole effect (originally it was "* HeatAlphaR" 

	

	color += MetalGlow(FinalTemperature);

	

	gl_FragColor = vec4(color.rgb, 1.0);

}

That's only part of the log, i was using a cargo canister with a death action to spawn 6 alloys and the above was repeated in the log for each spawned alloy, i guess you only need to see the error for one.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

how odd, ahruman i've got it to work, i had to remove the blank line from this part of the fragment shader code, the one just before the diffuse += gl....etc line that was appearing in the error log, how crazy is that?

Code: Select all

// 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); \
   }

User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

It’s not crazy at all, that’s a bona fide syntax error. (Fixed version uploaded.) It would also be valid if you put a \ at the end of the blank line (with no spaces after). So, does the fading-out alloy work now?
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

yeah, it works great! i'll update the oxp version that includes A_H's debris models so it uses your new bindings & shader code. I'll also write out a quick tutorial for the use of the shader and post in in this thread for other oxp-ers to use as a reference.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Oh, good.

I’ll leave the old parameter system in place in 1.69.1, but if there’s a 1.69.2 it will be gone there.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

I've added some of Arexack_Heretic debris models & Ahrumans new shaders into a glowing alloys.oxp. You can find it here:-
http://www.box.net/shared/ha4vs8ntkb
You'll need to be running Oolite v1.69 (or higher) for it to work. This version features gradually cooling heat effects!
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

Here's a shader with an animated mask effect to control glow map intensity, unfortunately the animating part isn't happening, at least not in oolite, it looks ok in Rendermonkey for some mad reason.

Edit: Fixed by Ahrumans mighty brain. Working version now uploaded


The vertex shader is using 'time' bound to the 'universalTime' property to scroll the UV coordinates in along in x

Code: Select all

varying vec3         v_normal;      // Surface normal
varying vec3         v_pos;      // Vertex/fragment position in eye space
varying vec2  vTexCoordShifted;
uniform float time;

void main()
{
   v_normal = normalize(gl_NormalMatrix * gl_Normal);
   v_pos = vec3(gl_ModelViewMatrix * gl_Vertex);
   
   gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
   
   // shift the texture coordinate for the animated mask object:
   vTexCoordShifted.x = gl_MultiTexCoord0.x - time / (10.0);  // (10.0) sets scroll speed
   vTexCoordShifted.y = gl_MultiTexCoord0.y;  
   
}
Image

I've put a billboard and an add from Dr. Nils oxp as an example, hope he doesn't mind, but the shader could also be used to get lights running along ship hulls, docking bays etc flying saucer effects

http://www.box.net/shared/2nktar35b7 160KB
Last edited by Griff on Sat Aug 11, 2007 10:40 pm, edited 4 times in total.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

The problem is that you haven’t set the effect map to repeat (Oolite defaults to clamping). This can be done in shipdata.plist as follows:

Code: Select all

textures = ("griff_bb_diffuse.png", "griff_bb_glow.png", {name = "griff_bb_eff.png"; repeat_s = "yes";});
Incidentally, Freaky Thargoids demonstrates another way to achieve a similar effect. :-)

I really should finish my illuminated billboard example.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

Said and done: Shady Billboards OXP.

This is my previously sneak-peaked “electronic billboard” shader. There are two variants included; one uses 256x128 pixel (Your Ad Here-compatible) adverts, the other uses 128x64 pixel ones to better show off the structure of the “electronic billboard”. The shader is somewhat unfinished; the most important thing that needs to be done is to reduce (but not eliminate) interference effects when viewing from a distance. A sensible decision about what advert resolution to use can’t really be made until that’s done. There’s room for performance improvements, and I’d like to add occasional dead pixels. But since I haven’t worked on it for a few months, I wanted to get it out there.

Advert textures nicked from Your Ad Here.
User avatar
Griff
Oolite 2 Art Director
Oolite 2 Art Director
Posts: 2476
Joined: Fri Jul 14, 2006 12:29 pm
Location: Probably hugging his Air Fryer

Post by Griff »

wow, that is very, very cool!
Thanks for fixing my billboard shader ahruman, but it looks like a total croc of crap next to your one :)
*peeks at fragment shader* i think my brain just keeled over
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

There is an error in the posted version: the included ahruman-billboard-pixel-mask.png has no alpha channel, which spoils the specular highlight effect. Get a fixed one here, then look at a black section of a screen (the book) at a suitable reflection angle. :-)

Oh, as I mentioned when I first previewed it, I got the idea from this tutorial.
Post Reply