You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw-tes3mp/files/materials/terrain.shader

83 lines
1.7 KiB
Plaintext

13 years ago
#include "core.h"
#define FOG @shGlobalSettingBool(fog)
13 years ago
#define MRT @shGlobalSettingBool(mrt_output)
13 years ago
#define COLOUR_MAP @shPropertyBool(colour_map)
13 years ago
@shAllocatePassthrough(1, depth)
13 years ago
@shAllocatePassthrough(2, UV)
13 years ago
#ifdef SH_VERTEX_SHADER
SH_BEGIN_PROGRAM
shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix)
shUniform(float4x4, viewProjMatrix) @shAutoConstant(viewProjMatrix, viewproj_matrix)
shInput(float2, uv0)
@shPassthroughVertexOutputs
SH_START_PROGRAM
{
float4 worldPos = shMatrixMult(worldMatrix, shInputPosition);
shOutputPosition = shMatrixMult(viewProjMatrix, worldPos);
@shPassthroughAssign(depth, shOutputPosition.z);
13 years ago
@shPassthroughAssign(UV, uv0);
13 years ago
}
#else
SH_BEGIN_PROGRAM
13 years ago
#if COLOUR_MAP
shSampler2D(colourMap)
#endif
#if FOG
shUniform(float3, fogColor) @shAutoConstant(fogColor, fog_colour)
shUniform(float4, fogParams) @shAutoConstant(fogParams, fog_params)
#endif
13 years ago
@shPassthroughFragmentInputs
#if MRT
shDeclareMrtOutput(1)
13 years ago
shUniform(float, far) @shAutoConstant(far, far_clip_distance)
13 years ago
#endif
SH_START_PROGRAM
{
float depth = @shPassthroughReceive(depth);
13 years ago
float2 UV = @shPassthroughReceive(UV);
shOutputColour(0) = float4(1,0,0,1);
13 years ago
#if COLOUR_MAP
shOutputColour(0).rgb *= shSample(colourMap, UV).rgb;
#endif
#if FOG
float fogValue = shSaturate((depth - fogParams.y) * fogParams.w);
shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, fogColor, fogValue);
#endif
13 years ago
#if MRT
13 years ago
shOutputColour(1) = float4(depth / far,1,1,1);
13 years ago
#endif
}
#endif