07-12-2015, 07:31 PM
![[Image: Oiu0Roi.gif]](http://i.imgur.com/Oiu0Roi.gif)
I also plan on making it do something with that chemical canister when its defeated, but scuttles are a group, so i wanted to code the basic movement AI first. Im going in now to code the various subtypes.
(07-16-2015, 09:27 PM)Quirby64 Wrote: [ -> ]I just went swimming today and I looked underwater a lot, I should be helpful here iguess
The blue filter is realistically correct - looking underwater without goggles things have a bit of a blue tint.
Also, instead of putting it into code, why not make a something percent transparency tile, and place it over the regular light blue water tile?
As in like 50% grey or something
(07-16-2015, 09:29 PM)Bombshell93 Wrote: [ -> ]you could pull a sonic 3, upon entering the water a splash graphic is shown, which is just a clever way to mask the changing of the sprite, to a different palette, you could simply make alternative versions of the sprites with a new palette for all sprites relevant to water (jumping and falling for entering and exiting the water, swim, maybe run if you want to run on the underwater floor, etc.) you can use that as a chance to make a palette not so washed out.
(07-16-2015, 10:57 PM)TheShyGuy Wrote: [ -> ]But you can do palettes (as in specifying an alternate color palette instead of manually recoloring everything) in GM since GM supports pixel (fragment) shaders. I've even done it for Neweegee already. Let me see if I can find the necessary code.
Edit:....I'm looking....
(07-17-2015, 12:22 AM)TheShyGuy Wrote: [ -> ]...I just found it too =/. Well, if you ever move to studio, heres some important code:I'd more readily move to studio if some of the scripts i use werent completely incompatible with it. ;-;
//
// Simple passthrough vertex shader
//
attribute vec3 in_Position; // (x,y,z)
//attribute vec3 in_Normal; // (x,y,z) unused in this shader.
attribute vec4 in_Colour; // (r,g,b,a)
attribute vec2 in_TextureCoord; // (u,v)
varying vec2Texcoord;
varying vec4Colour;
void main()
{
vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
Colour = in_Colour;
Texcoord = in_TextureCoord;
}Notes:
// Simple passthrough fragment shader
//
varying vec2Texcoord;
varying vec4Colour;
uniform sampler2D Palette;
//size of palette image, in pixels.
uniform vec2 PaletteImageSize;
void main()
{
//Use 255 if not intel.
//texture2D() returns colors in range [0,1]. Put them back into the range[0,255],
//where the value refers to the exact pixel X,Y.
vec4 indexPixel = texture2D( gm_BaseTexture,Texcoord) * vec4(256);
//Comment out these conditionals if not intel.
if(indexPixel.r >= 128.0)indexPixel.r--;
if(indexPixel.g >= 128.0)indexPixel.g--;
if(indexPixel.b >= 128.0)indexPixel.b--;
if(indexPixel.a >= 128.0)indexPixel.a--;
//convert the pixel coords into UV coords in the range [0,1],
// as expected by texture2D()
vec2 paletteCoords = vec2(indexPixel.x,indexPixel.y) / PaletteImageSize;
//issue: gamemaker stores all images into a "Texture page",
//thus, the above coords are incorrect.
//fix: externally loaded palette images
gl_FragColor = texture2D( Palette, paletteCoords);
}
gm_BaseTexture and Palette refer to sampler textures that are externally loaded sprites since GM will auto batch sprites into a "Texture Page". When that happens, GM will change the UV coords to something unexpected. But, I need to know the exact UV coords of the palette image, so instead I externally load sprites to reserves the original UV coords.
The drawn sprite (gm_BaseTexture) is an indexed sprite, where each pixel's color.r (indexPixel.x) refers to the x coordinate of the correct color within the palette (domain [0,255]) and color.g (indexPixel.y) refers to the y coordinate of the correct color within the palette (domain [0,255]).
___
I'm just typing this up for other people and for my own reference. If you ever move to GM Studio or any other graphics library (OpenGL, Direct X), you can still refer to the above to draw sprites with arbitrary palettes.
int paletteIndex = int(textureSample.w * PALETTE_COLOR_COUNT); //probably going 16 colors in the palette would work fine
vec3 paletteColor = uniformPalette[paletteIndex];
(07-17-2015, 06:27 AM)Bombshell93 Wrote: [ -> ]game maker has always had terrible compatibility issues from version to version, the change so much in gml a lot with no reason whatsoever.
also a note, you're probably better off in a palette swapper passing in a group of vec3's as palette and determine the colour by the w component, which you can decompose and edit in pretty much any good image editing program.
(07-17-2015, 06:27 AM)Bombshell93 Wrote: [ -> ]back on topic, how many animations are you looking to use underwater? because you have a lot more freedom with textures than you'd think, adding a new set wouldn't be much of a cost short of HD spritesoff the top of my head:
(07-17-2015, 09:01 AM)Bombshell93 Wrote: [ -> ]so basicly your whole sprite set and then some, if your really not liking how the colour wash out looks, your only 2 options short of upgrading to GM:studio would be, play around with blend modes (I always had trouble wrapping my head around it, but it'd add a bit more flexibility than flat changing colour) or the new sprite sheet with a new palette