Page 1 of 2

ocean beach surface underwater tile - SOLVED

Posted: Sat Jan 10, 2015 8:41 pm
by Drakkan
simple solution (has some slight bugs, like water is clipping with ocean beach...) -
ok solved at the end. in case somebody is interested to have water_surface which will have surface of ocean_beach (you have to add default object) but will be actin like regular underwater tile when jumped inside (test for forest_underweater tile), you need just to move offsets correctly.
what is it for ? you can create really deep beaches not just on the end of the map, you are not limited by shallow water etc...

complicated solution, but should work without bugs, adviced by minmay

Try adding a WaterSurfaceMesh component to ocean_water and using an invisible material for its "material" field. An invisible material would look like this:

Code: Select all

defineMaterial{
   name = "invisible",
   diffuseMap = "mod_assets/textures/invisible.tga", -- a texture with all pixels transparent
   doubleSided = false,
   lighting = false,
   alphaTest = true, -- accounts for the transparency
   blendMode = "Opaque",
   textureAddressMode = "Wrap",
   glossiness = 0,
   depthBias = 0,
}
You can then leave water_surface_underwater as the underwater material. Note that the water shader only works correctly on materials with certain names so you will need to redefine water_surface_underwater if you want it to look more like ocean_water. Also you'll probably want to add fogColor and fogDensity fields to the WaterSurface component, like water_surface and water_surface_underground have.

example:

unlimited beach
Image
underwater
Image

Code: Select all

defineObject{
	name = "water_no_surface",
	baseObject = "base_floor_decoration",
	components = {
		{
			-- updates global reflection and refraction maps
			class = "WaterSurface",
			planeY = -0.4,
			fogColor = vec(0.042, 0.09, 0.26) * 0.5,
			fogDensity = 0.2,
			--planeY = -0.4,
			reflectionColor = vec(0.77, 0.9, 1.0) * 0.9,
			refractionColor = vec(1,1,1),
		},
		{
			-- builds a continuous mesh from underwater tiles
			class = "WaterSurfaceMesh",
			offset = vec(0,-7,0,0),
			material = "water_surface_calm",
			underwaterMaterial = "water_surface_underwater",
			offset = vec(0, -1.25, 0),
		},
	},
	dontAdjustHeight = true,
	editorIcon = 264,
}

Re: define forest_water tile help pls

Posted: Sat Jan 10, 2015 9:22 pm
by minmay
I don't think it's possible to have an underwater tile with no water surface; all tiles with "underwater" set to true will be covered by the water surface mesh.
Unless you mean you don't want the tile to be underwater at all, in which case, just change the "underwater" field from true to false.

Re: define forest_water tile help pls

Posted: Sat Jan 10, 2015 10:04 pm
by Drakkan
minmay wrote:I don't think it's possible to have an underwater tile with no water surface; all tiles with "underwater" set to true will be covered by the water surface mesh.
Unless you mean you don't want the tile to be underwater at all, in which case, just change the "underwater" field from true to false.
actually I need water_surface, which will have surface like ocean beach (just surface), but underwater it will be acting like water_surface (regarding visiblity and color)
.
So I thought that just disabling somehow the regular surface and placing ocean_beach object will be ok. Any ideas how ot accomplish this ?

EDIT: ok first progress, I moved the surface away by offset, so it is not visible. but when I jump into ocean water I have "full" visibility. not sure if this good way to go.

Re: define forest_water tile help pls

Posted: Sat Jan 10, 2015 10:43 pm
by minmay
Drakkan wrote:EDIT: ok first progress, I moved the surface away by offset, so it is not visible. but when I jump into ocean water I have "full" visibility. not sure if this good way to go.
Okay, so you do want the water surface mesh, you just want it to only be visible from underneath. Try adding a WaterSurfaceMesh component to ocean_water and using an invisible material for its "material" field. An invisible material would look like this:

Code: Select all

defineMaterial{
	name = "invisible",
	diffuseMap = "mod_assets/textures/invisible.tga", -- a texture with all pixels transparent
	doubleSided = false,
	lighting = false,
	alphaTest = true, -- accounts for the transparency
	blendMode = "Opaque",
	textureAddressMode = "Wrap",
	glossiness = 0,
	depthBias = 0,
}
You can then leave water_surface_underwater as the underwater material. Note that the water shader only works correctly on materials with certain names so you will need to redefine water_surface_underwater if you want it to look more like ocean_water. Also you'll probably want to add fogColor and fogDensity fields to the WaterSurface component, like water_surface and water_surface_underground have.

Re: define forest_water tile help pls

Posted: Sat Jan 10, 2015 10:49 pm
by Drakkan
minmay wrote:
Drakkan wrote:EDIT: ok first progress, I moved the surface away by offset, so it is not visible. but when I jump into ocean water I have "full" visibility. not sure if this good way to go.
Okay, so you do want the water surface mesh, you just want it to only be visible from underneath. Try adding a WaterSurfaceMesh component to ocean_water and using an invisible material for its "material" field. An invisible material would look like this:

Code: Select all

defineMaterial{
	name = "invisible",
	diffuseMap = "mod_assets/textures/invisible.tga", -- a texture with all pixels transparent
	doubleSided = false,
	lighting = false,
	alphaTest = true, -- accounts for the transparency
	blendMode = "Opaque",
	textureAddressMode = "Wrap",
	glossiness = 0,
	depthBias = 0,
}
You can then leave water_surface_underwater as the underwater material. Note that the water shader only works correctly on materials with certain names so you will need to redefine water_surface_underwater if you want it to look more like ocean_water. Also you'll probably want to add fogColor and fogDensity fields to the WaterSurface component, like water_surface and water_surface_underground have.
hmmm this seems very nice, thanks for another tip minmay ! As my solution is curently working I will probabyl not tryying out, but could be usefull

Re: ocean beach surface underwater tile - SOLVED

Posted: Sat Jan 10, 2015 11:45 pm
by MrChoke
Drakken, did you post your solution? It sounds very interesting. I looked at the code in the 1st post. Its identical to the default, "water_surface".

Re: ocean beach surface underwater tile - SOLVED

Posted: Sat Jan 10, 2015 11:55 pm
by Drakkan
MrChoke wrote:Drakken, did you post your solution? It sounds very interesting. I looked at the code in the 1st post. Its identical to the default, "water_surface".
yes, there are actaully just those two offsets difference, which make it working as I intended

Re: ocean beach surface underwater tile - SOLVED

Posted: Sun Jan 11, 2015 3:00 am
by minmay
You probably want your WaterSurface's planeY (currently -0.4) to be the same as your WaterSurfaceMesh's Y offset (currently -1.25). Otherwise your reflection will be based on a plane that doesn't align with the water surface.
Also I would really recommend making the top water surface invisible like I said. The clipping with the ocean water in that screenshot looks pretty bad and I believe it will improve performance.

Re: ocean beach surface underwater tile - SOLVED

Posted: Thu Jan 15, 2015 7:00 pm
by bongobeat
thanks for sharing that!

Re: ocean beach surface underwater tile - SOLVED

Posted: Fri Jan 23, 2015 9:06 pm
by Granamir
I'm not an expert like you...i understood almost nothing about your solution...is there something like copy-paste solution?
Or can you explain what i have to do considering i'm not an expert?
Thank you very much