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/objects.shader

69 lines
1.6 KiB
Plaintext

13 years ago
#include "core.h"
13 years ago
#define FOG @shPropertyBool(fog)
#define MRT @shPropertyNotBool(is_transparent)
#if MRT
#define NEED_DEPTH
#endif
#if FOG
#define NEED_DEPTH
#endif
13 years ago
#ifdef SH_VERTEX_SHADER
SH_BEGIN_PROGRAM
shUniform(float4x4 wvp) @shAutoConstant(wvp, worldviewproj_matrix)
shInput(float2, uv0)
shOutput(float2, UV)
13 years ago
shNormalInput(float4)
shOutput(float4, normalPassthrough)
13 years ago
#ifdef NEED_DEPTH
13 years ago
shOutput(float, depthPassthrough)
13 years ago
#endif
13 years ago
SH_START_PROGRAM
{
shOutputPosition = shMatrixMult(wvp, shInputPosition);
UV = uv0;
13 years ago
normalPassthrough = normal;
13 years ago
#ifdef NEED_DEPTH
13 years ago
depthPassthrough = shOutputPosition.z;
13 years ago
#endif
13 years ago
}
#else
SH_BEGIN_PROGRAM
shSampler2D(diffuseMap)
shInput(float2, UV)
13 years ago
shDeclareMrtOutput(1)
shInput(float4, normalPassthrough)
13 years ago
13 years ago
#ifdef NEED_DEPTH
13 years ago
shInput(float, depthPassthrough)
13 years ago
#endif
13 years ago
shUniform(float far) @shAutoConstant(far, far_clip_distance)
#if FOG
shUniform(float3 fogColor) @shAutoConstant(fogColor, fog_colour)
shUniform(float4 fogParams) @shAutoConstant(fogParams, fog_params)
#endif
13 years ago
SH_START_PROGRAM
{
13 years ago
//shOutputColor(0) = float4((normalize(normalPassthrough.xyz)+float3(1.0,1.0,1.0)) / 2.f, 1.0);
shOutputColor(0) = shSample(diffuseMap, UV);
#if FOG
float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w);
shOutputColor(0).xyz = shLerp (shOutputColor(0).xyz, fogColor, fogValue);
#endif
shOutputColor(1) = float4(depthPassthrough / far,1,1,1);
13 years ago
}
#endif