[Guide] How to Make Outdoor Areas

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!
minmay
Posts: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: Re:

Post by minmay »

Isaac wrote:Is it interactive, or decorative? This is news to me; and sounds neat.
The ocean water is at a different height from the rest of the water in the game.
Isaac wrote:The reflection shader ~for me, cuts off once the party drops below elevation zero.
https://www.dropbox.com/s/sx9kejg4mn91l ... r.avi?dl=0
Since that video is so low-resolution, I can't actually tell for sure, but it looks like you didn't adjust the planeY value of your WaterSurfaceComponent. It should be the same height as your water mesh.
Isaac wrote:(Too bad it doesn't move the water mesh.)
I'm pretty sure you should only move the mesh (Component:setOffset()) and change the planeY value of the WaterSurfaceComponent instead of moving the object with the WaterSurfaceComponent.
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
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Re:

Post by Isaac »

minmay wrote:Since that video is so low-resolution, I can't actually tell for sure, but it looks like you didn't adjust the planeY value of your WaterSurfaceComponent. It should be the same height as your water mesh.
That makes a world of difference. 8-)
So adjusting planeY does allow the reflection to function as intended.
Isaac wrote:(Too bad it doesn't move the water mesh.)
I'm pretty sure you should only move the mesh (Component:setOffset()) and change the planeY value of the WaterSurfaceComponent instead of moving the object with the WaterSurfaceComponent.
So far, I have only managed to adjust the water mesh height using the to setWorldPosition/PositionY functions on the water_surface mesh.
minmay
Posts: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: Re:

Post by minmay »

Look at the asset pack definitions. You can use the offset property of the WaterSurfaceMeshComponent to change the height of the mesh. The planeY field of the WaterSurfaceComponent is the height of the plane that stuff is reflected across, so generally you want it to align with the mesh.
You can also use water materials on your own meshes, of course, even animated ones - there's nothing special about the ocean_water model. I can't think of any rendering limitations on dynamically changing water height while the party is above. The "problem" is that the party's underwater-ness is tied to tile and elevation. (You can hack around move sounds with a PartyComponent.onMove hook.) You could probably get around that by changing the elevation of all the objects on the level but that is a really bad idea for other reasons.
Also you can't dynamically change the level's reflection map obviously, but you could use ModelComponent:setReflection() to mostly get around that performance issue.
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
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: [Guide] How to Make Outdoor Areas

Post by THOM »

Mm - when I try to alter the heightness of a waterlevel, I get this:

https://www.dropbox.com/s/uengqqy8yyo2j ... 1.jpg?dl=0

Code: Select all

defineObject{
	name = "voodooswamp_water",
	baseObject = "base_floor_decoration",
	components = {
		{
			-- updates global reflection and refraction maps
			class = "WaterSurface",
			planeY = 1.2,
			fogColor = vec(0.5, 0.35, 0.1) * 0.3,
			fogDensity = 0.3,
			reflectionColor = vec(0.5, 0.5, 0.5),
			refractionColor = vec(0.1, 0.2, 0.1) * 0.5,
		},

		{
			-- builds a continuous mesh from underwater tiles
			class = "WaterSurfaceMesh",
			material = "water_surface_calm",
			underwaterMaterial = "water_surface_underwater",
			offset = vec(0, 1.2, 0),
		},
	},
	tags = { "THOM" },
	dontAdjustHeight = true,
	editorIcon = 264,
}
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: [Guide] How to Make Outdoor Areas

Post by THOM »

Does anyone has an idea whats going on on my screenshot?
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Guide] How to Make Outdoor Areas

Post by Isaac »

THOM wrote:Does anyone has an idea whats going on on my screenshot?
What I would suggest, is to place a script that (on load) applies an adjusted water_surface material to the water surface object. Redefine the water_surface_calm material with a smaller wave amplitude. (say... 0.25, instead of 2)

Apply the altered copied material.

Code: Select all

--Example script
function setWater()
water_surface_underground_1.watersurfacemesh:setMaterial("water_surface_adjusted")
end
delayedCallself.go.id, 0.001, "setWater")
This works ~~with side effects. Though I would love to learn a better way to manage it.
minmay
Posts: 2788
Joined: Mon Sep 23, 2013 2:24 am

Re: [Guide] How to Make Outdoor Areas

Post by minmay »

Isaac wrote:
THOM wrote:Does anyone has an idea whats going on on my screenshot?
What I would suggest, is to place a script that (on load) applies an adjusted water_surface material to the water surface object. Redefine the water_surface_calm material with a smaller wave amplitude. (say... 0.25, instead of 2)

Apply the altered copied material.

Code: Select all

--Example script
function setWater()
water_surface_underground_1.watersurfacemesh:setMaterial("water_surface_adjusted")
end
delayedCallself.go.id, 0.001, "setWater")
The water shader only works on materials named "ocean_water", "water_surface_calm", and "water_surface_underwater". If you want more than 3 water materials you should take advantage of the onUpdate hook to change the materials' properties when needed.
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
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: [Guide] How to Make Outdoor Areas

Post by Isaac »

minmay wrote:The water shader only works on materials named "ocean_water", "water_surface_calm", and "water_surface_underwater". If you want more than 3 water materials you should take advantage of the onUpdate hook to change the materials' properties when needed.
That sounds cool. Currently I've [as mentioned above] defined a copy of water_surface_calm, and applied it upon load; with the water surface raised just slightly above 0 elevation. To appear like a foot of flood water in the tunnels. I'd seen it of course, but I hadn't actually used the onUpdate hook yet.

Code: Select all

defineMaterial{
	name = "water_surface_adjusted",
	shader = "ocean_water",
	diffuseMap = "assets/textures/env/ocean_foam_dif.tga",
	normalMap = "assets/textures/env/ocean_normal.tga",
	displacementMap = "assets/textures/env/ocean_disp.tga",
	doubleSided = true,
	lighting = true,
	alphaTest = false,
	blendMode = "Translucent",
	textureAddressMode = "Wrap",
	glossiness = 80,
	depthBias = 0,
	texOffset = 0,
	foamOffset = 0,
	foamAmount = 0,
	waveAmplitude = 0.25,  --=------[changed from 2 to .25]
	onUpdate = function(self, time)
		self:setParam("texOffset", time*0.15)
	end,	
}	
I'm not happy with the final effect ~yet; but it does change that to this:
Image

And can be seen here in-game: https://www.dropbox.com/s/0bhn1if7mq7po ... l.avi?dl=0
User avatar
Duncan1246
Posts: 404
Joined: Mon Jan 19, 2015 7:42 pm

Re: [Guide] How to Make Outdoor Areas

Post by Duncan1246 »

minmay wrote:
Isaac wrote:
THOM wrote:Does anyone has an idea whats going on on my screenshot?
What I would suggest, is to place a script that (on load) applies an adjusted water_surface material to the water surface object. Redefine the water_surface_calm material with a smaller wave amplitude. (say... 0.25, instead of 2)

Apply the altered copied material.

Code: Select all

--Example script
function setWater()
water_surface_underground_1.watersurfacemesh:setMaterial("water_surface_adjusted")
end
delayedCallself.go.id, 0.001, "setWater")
The water shader only works on materials named "ocean_water", "water_surface_calm", and "water_surface_underwater". If you want more than 3 water materials you should take advantage of the onUpdate hook to change the materials' properties when needed.
Your reflexions and solutions are very interesting for many modders, but I think a specific thread is necessary. Find this in "How to make outdoors areas" thread is a bit weird...
Anyway, If I understand, to obtain a flood effect, it's necessary to load the new material for the mesh in init.lua to override water_surface_underwater and create a water_surface_underground object with planeY and mesh offset adapted to the modder purpose (0.2 in your exemple). If it's correct, to modify in game the level of the water, like in the video, you call setWorldPositionY() but on that? on water_surface_underground? And how you manage the party_underwater issue?
Duncan
The Blue Monastery (LOG1)
download at:http://www.nexusmods.com/grimrock/mods/399/?

Finisterrae(LOG2)
download at:http://www.nexusmods.com/legendofgrimrock2/mods/61/?
BlankGame
Posts: 2
Joined: Thu Dec 01, 2016 7:06 pm

Re: [Guide] How to Make Outdoor Areas

Post by BlankGame »

So i have made a ladder that i can get up successfully BUT i can not get down ... how do i fix this (without code)
Post Reply