ocean beach surface underwater tile - SOLVED

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

ocean beach surface underwater tile - SOLVED

Post 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,
}
Last edited by Drakkan on Sun Jan 11, 2015 3:34 pm, edited 13 times in total.
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: define forest_water tile help pls

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: define forest_water tile help pls

Post 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.
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: define forest_water tile help pls

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: define forest_water tile help pls

Post 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
Breath from the unpromising waters.
Eye of the Atlantis
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: ocean beach surface underwater tile - SOLVED

Post 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".
User avatar
Drakkan
Posts: 1318
Joined: Mon Dec 31, 2012 12:25 am

Re: ocean beach surface underwater tile - SOLVED

Post 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
Breath from the unpromising waters.
Eye of the Atlantis
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: ocean beach surface underwater tile - SOLVED

Post 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.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: ocean beach surface underwater tile - SOLVED

Post by bongobeat »

thanks for sharing that!
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Granamir
Posts: 202
Joined: Wed Jan 07, 2015 7:19 pm

Re: ocean beach surface underwater tile - SOLVED

Post 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
Post Reply