HoD is a first person point-and-click adventure set in a steampunk environment. You will have to unravel the mystery of the airship, you will find yourself in, where nothing is what it seems.

Report RSS Dynamic light in a dark world

Purpose built lighting effects done cheap. Light shining through an open door using a simple shader.

Posted by on - Basic Animation

As I am targeting low end PCs and mobile devices, using real-time lighting and shadow casting is not an option in my game.

One purpose build lighting effect is the door light. When the door opens or closes, the light from the room of the opposite side will illuminate the floor on the other side. The light cone will change during the transition.

door light animation

To achieve this effect, I’m using a light cone shaped mesh. During the transition the outer vertices move in- and out-wards, masked by a second UV set.

mesh

// float property to control the transition
Properties {
	_doorOpen ("Door open", Range (0, 1)) = 0
}

// vertext shader
VertOut vertShader(VertIn input) {
	VertOut output;
	// offset to move the vertices on X, multiplied with the mask-uv
	// using uv.y to pin the mesh to the left corner of the opening
	float open = (input.texcoord1.x*_doorOpen) + (_doorOpen*0.5*(1.0-input.texcoord1.y));
	// adding it to the vertex positon
	output.position = mul(UNITY_MATRIX_MVP,float4(input.vertex.x + open,input.vertex.y,input.vertex.z,input.vertex.w));
	return output;
}

The output color of the shader is a simple white gradient with a falloff.

To increase the brightness and intensity of the floor, I’m using a special blend mode.

SubShader {
		// blending
		Blend DstColor One	
}

Source * Destination + Destination * 1

It will multiply the white light cone with the floor and adds it to the floor color already in the frame buffer.

Simple as that. It's a nice effect without any extraordinary performance impact.
I'm using this for other objects as well, like laser beams hitting a surface.

Thanks for reading.


Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Report Profile
Icon
Harvester of Dreams : Episode 1
Platforms
Windows, Linux, Android
Creator
ChristianW
Engine
Unity
Contact
Send Message
Release date
Game watch
Follow
Tutorial
Browse
Tutorials
Report
Report
Views
27 (1 today)
Share
Related Games
Related Engines
Unity
Unity Commercial