mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-16 10:04:28 +02:00
fix D3D9 version
add oblique projection matrix support instead of clipping planes for D3D NDC
This commit is contained in:
@@ -580,11 +580,13 @@ struct Camera : ICamera {
|
||||
q.z = -1.0f;
|
||||
q.w = (1.0f + Core::mProj.e22) / Core::mProj.e23;
|
||||
|
||||
vec4 c = p * (2.0f / p.dot(q));
|
||||
float f = GAPI::getProjRange() == mat4::PROJ_NEG_POS ? 2.0f : 1.0f;
|
||||
|
||||
vec4 c = p * (f / p.dot(q));
|
||||
|
||||
Core::mProj.e20 = c.x;
|
||||
Core::mProj.e21 = c.y;
|
||||
Core::mProj.e22 = c.z + 1.0f;
|
||||
Core::mProj.e22 = c.z + (f - 1.0f);
|
||||
Core::mProj.e23 = c.w;
|
||||
}
|
||||
|
||||
|
@@ -509,16 +509,20 @@ namespace GAPI {
|
||||
C3D_Fini();
|
||||
gfxExit();
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_NEG_ZERO;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_NEG_ZERO, l, r, b, t, znear, zfar, true);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar, true);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_NEG_ZERO, fov, aspect, znear, zfar, eye, true);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye, true);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@@ -187,6 +187,7 @@ namespace GAPI {
|
||||
case 1 : SHADER ( filter_downsample, v ); SHADER ( filter_downsample, f ); break;
|
||||
case 3 : SHADER ( filter_grayscale, v ); SHADER ( filter_grayscale, f ); break;
|
||||
case 4 : SHADER ( filter_blur, v ); SHADER ( filter_blur, f ); break;
|
||||
case 5 : SHADER ( filter_blur, v ); SHADER ( filter_blur, f ); break; // TODO anaglyph
|
||||
default : ASSERT(false);
|
||||
}
|
||||
break;
|
||||
@@ -606,7 +607,6 @@ namespace GAPI {
|
||||
support.texHalfLinear = true;
|
||||
support.texHalf = true;
|
||||
support.tex3D = true;
|
||||
support.clipDist = true;
|
||||
|
||||
#ifdef PROFILE
|
||||
support.profMarker = false;
|
||||
@@ -717,15 +717,19 @@ namespace GAPI {
|
||||
}
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_ZERO_POS;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar, eye);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@@ -195,6 +195,7 @@ namespace GAPI {
|
||||
case 1 : vSrc = SHADER ( filter_downsample, v ); fSrc = SHADER ( filter_downsample, f ); break;
|
||||
case 3 : vSrc = SHADER ( filter_grayscale, v ); fSrc = SHADER ( filter_grayscale, f ); break;
|
||||
case 4 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break;
|
||||
case 5 : vSrc = SHADER ( filter_blur, v ); fSrc = SHADER ( filter_blur, f ); break; // TODO anaglyph
|
||||
default : ASSERT(false);
|
||||
}
|
||||
break;
|
||||
@@ -249,6 +250,7 @@ namespace GAPI {
|
||||
int width, height, depth, origWidth, origHeight, origDepth;
|
||||
TexFormat fmt;
|
||||
uint32 opt;
|
||||
D3DFORMAT d3dformat;
|
||||
|
||||
Texture(int width, int height, int depth, uint32 opt) : tex2D(NULL), texCube(NULL), width(width), height(height), depth(depth), origWidth(width), origHeight(height), origDepth(depth), fmt(FMT_RGBA), opt(opt) {}
|
||||
|
||||
@@ -283,6 +285,8 @@ namespace GAPI {
|
||||
|
||||
D3DPOOL pool = (isTarget || isDepth) ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
|
||||
|
||||
d3dformat = desc.format;
|
||||
|
||||
if (cube) {
|
||||
D3DCHECK(device->CreateCubeTexture(width, 1, usage, desc.format, pool, &texCube, NULL));
|
||||
} else {
|
||||
@@ -290,14 +294,18 @@ namespace GAPI {
|
||||
if (data && !isTarget) {
|
||||
D3DLOCKED_RECT rect;
|
||||
D3DCHECK(tex2D->LockRect(0, &rect, NULL, 0));
|
||||
if (width != origWidth || height != origHeight) {
|
||||
memset(rect.pBits, 0, width * height * (desc.bpp / 8));
|
||||
if (fmt == FMT_RGBA) {
|
||||
uint8 *dst = (uint8*)rect.pBits;
|
||||
uint8 *src = (uint8*)data;
|
||||
for (int y = 0; y < origHeight; y++) {
|
||||
memcpy(dst, src, origWidth * (desc.bpp / 8));
|
||||
src += origWidth * (desc.bpp / 8);
|
||||
dst += width * (desc.bpp / 8);
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
dst[0] = src[2];
|
||||
dst[1] = src[1];
|
||||
dst[2] = src[0];
|
||||
dst[3] = src[3];
|
||||
dst += 4;
|
||||
src += 4;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memcpy(rect.pBits, data, width * height * (desc.bpp / 8));
|
||||
@@ -473,7 +481,6 @@ namespace GAPI {
|
||||
support.texFloat = true;
|
||||
support.texHalfLinear = true;
|
||||
support.texHalf = true;
|
||||
support.clipDist = true;
|
||||
|
||||
#ifdef PROFILE
|
||||
support.profMarker = false;
|
||||
@@ -484,8 +491,8 @@ namespace GAPI {
|
||||
{0, OFFSETOF(Vertex, coord), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, // aCoord
|
||||
{0, OFFSETOF(Vertex, normal), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0}, // aNormal
|
||||
{0, OFFSETOF(Vertex, texCoord), D3DDECLTYPE_SHORT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0}, // aTexCoord
|
||||
{0, OFFSETOF(Vertex, color), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, // aColor
|
||||
{0, OFFSETOF(Vertex, light), D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, // aLight
|
||||
{0, OFFSETOF(Vertex, color), D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0}, // aColor
|
||||
{0, OFFSETOF(Vertex, light), D3DDECLTYPE_UBYTE4N, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 1}, // aLight
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
@@ -539,15 +546,19 @@ namespace GAPI {
|
||||
}
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_ZERO_POS;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar, eye);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye);
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -764,7 +775,7 @@ namespace GAPI {
|
||||
|
||||
LPDIRECT3DSURFACE9 surface, texSurface;
|
||||
D3DCHECK(t->tex2D->GetSurfaceLevel(0, &texSurface));
|
||||
D3DCHECK(device->CreateOffscreenPlainSurface(t->width, t->height, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &surface, NULL));
|
||||
D3DCHECK(device->CreateOffscreenPlainSurface(t->width, t->height, t->d3dformat, D3DPOOL_SYSTEMMEM, &surface, NULL));
|
||||
D3DCHECK(device->GetRenderTargetData(texSurface, surface));
|
||||
|
||||
RECT r = { x, y, x + 1, y + 1 };
|
||||
|
@@ -1337,15 +1337,19 @@ namespace GAPI {
|
||||
}
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_NEG_POS;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar, eye);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@@ -295,15 +295,19 @@ namespace GAPI {
|
||||
delete[] cmdBuf;
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_NEG_POS;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_NEG_POS, l, r, b, t, znear, zfar);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_NEG_POS, fov, aspect, znear, zfar, eye);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@@ -1205,15 +1205,19 @@ namespace GAPI {
|
||||
sceGxmTerminate();
|
||||
}
|
||||
|
||||
inline mat4::ProjRange getProjRange() {
|
||||
return mat4::PROJ_ZERO_POS;
|
||||
}
|
||||
|
||||
mat4 ortho(float l, float r, float b, float t, float znear, float zfar) {
|
||||
mat4 m;
|
||||
m.ortho(mat4::PROJ_ZERO_POS, l, r, b, t, znear, zfar);
|
||||
m.ortho(getProjRange(), l, r, b, t, znear, zfar);
|
||||
return m;
|
||||
}
|
||||
|
||||
mat4 perspective(float fov, float aspect, float znear, float zfar, float eye) {
|
||||
mat4 m;
|
||||
m.perspective(mat4::PROJ_ZERO_POS, fov, aspect, znear, zfar, eye);
|
||||
m.perspective(getProjRange(), fov, aspect, znear, zfar, eye);
|
||||
return m;
|
||||
}
|
||||
|
||||
|
@@ -5,10 +5,6 @@
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Editor|Win32">
|
||||
<Configuration>Editor</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Profile|Win32">
|
||||
<Configuration>Profile</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
@@ -31,12 +27,6 @@
|
||||
<PlatformToolset>v141_xp</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120_xp</PlatformToolset>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
@@ -57,9 +47,6 @@
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
@@ -73,11 +60,6 @@
|
||||
<IncludePath>..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
|
||||
<LibraryPath>..\..\libs\openvr\;$(VC_LibraryPath_x86);$(WindowsSdk_71A_LibraryPath_x86);</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>..\..\..\bin\</OutDir>
|
||||
<IncludePath>..\..\;$(VC_IncludePath);$(WindowsSdk_71A_IncludePath);</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>..\..\..\bin\</OutDir>
|
||||
@@ -109,23 +91,6 @@
|
||||
<AdditionalDependencies>wsock32.lib;d3d9.lib;d3d11.lib;opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Editor|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>LEVEL_EDITOR;STB_VORBIS_NO_STDIO;NOMINMAX;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Strict</FloatingPointModel>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>opengl32.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
@@ -179,7 +144,7 @@
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>wcrt.lib;wsock32.lib;openvr_api.lib;opengl32.lib;d3d11.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>wcrt.lib;wsock32.lib;opengl32.lib;d3d11.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
|
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
|
@@ -24,10 +24,6 @@ static const float3 SHADOW_TEXEL = float3(1.0 / SHADOW_SIZE, 1.0 / SHADOW_SIZE,
|
||||
#define FLAGS_TYPE float4
|
||||
#endif
|
||||
|
||||
#ifndef _GAPI_GXM
|
||||
#define CLIP_PLANE
|
||||
#endif
|
||||
|
||||
struct VS_INPUT {
|
||||
int4 aCoord : POSITION;
|
||||
int4 aNormal : NORMAL;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "common.hlsl"
|
||||
|
||||
// ALPHA_TEST, UNDERWATER, CLIP_PLANE (D3D9 only), OPT_SHADOW, OPT_CAUSTICS, OPT_AMBIENT
|
||||
// ALPHA_TEST, UNDERWATER, OPT_SHADOW, OPT_CAUSTICS, OPT_AMBIENT
|
||||
|
||||
struct VS_OUTPUT {
|
||||
float4 pos : POSITION;
|
||||
@@ -12,9 +12,6 @@ struct VS_OUTPUT {
|
||||
float3 ambient : TEXCOORD5;
|
||||
float4 light : TEXCOORD6;
|
||||
float4 lightProj : TEXCOORD7;
|
||||
#ifdef _GAPI_GXM
|
||||
float clipDist : CLP0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef VERTEX
|
||||
@@ -76,10 +73,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w));
|
||||
Out.lightProj = mul(uLightProj, float4(Out.coord, 1.0));
|
||||
|
||||
#ifdef _GAPI_GXM
|
||||
Out.clipDist = Out.viewVec.w;
|
||||
#endif
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -92,10 +85,6 @@ float4 main(VS_OUTPUT In) : COLOR0 {
|
||||
clip(color.w - ALPHA_REF);
|
||||
#endif
|
||||
|
||||
#ifdef CLIP_PLANE
|
||||
clip(In.viewVec.w);
|
||||
#endif
|
||||
|
||||
color *= In.diffuse;
|
||||
|
||||
float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w;
|
||||
|
@@ -1,16 +1,9 @@
|
||||
#include "common.hlsl"
|
||||
|
||||
// CLIP_PLANE (D3D9 only)
|
||||
|
||||
struct VS_OUTPUT {
|
||||
float4 pos : POSITION;
|
||||
float4 texCoord : TEXCOORD0;
|
||||
float3 diffuse : TEXCOORD1;
|
||||
#ifdef _GAPI_GXM
|
||||
float clipDist : CLP0;
|
||||
#else
|
||||
float clipDist : TEXCOORD2;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef VERTEX
|
||||
@@ -28,8 +21,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
Out.diffuse = In.aColor.rgb * (uMaterial.x * 1.8) + uMaterial.w;
|
||||
Out.texCoord = In.aTexCoord * (1.0 / 32767.0);
|
||||
Out.texCoord.xy *= Out.texCoord.zw;
|
||||
|
||||
Out.clipDist = uParam.w - coord.y * uParam.z;
|
||||
|
||||
return Out;
|
||||
}
|
||||
@@ -39,10 +30,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
float4 main(VS_OUTPUT In) : COLOR0 {
|
||||
float4 color = SAMPLE_2D(sDiffuse, In.texCoord.xy / In.texCoord.zw);
|
||||
|
||||
#ifdef CLIP_PLANE
|
||||
clip(In.clipDist);
|
||||
#endif
|
||||
|
||||
color.xyz *= In.diffuse.xyz;
|
||||
return color;
|
||||
}
|
||||
|
@@ -1,14 +1,9 @@
|
||||
#include "common.hlsl"
|
||||
|
||||
// CLIP_PLANE (D3D9 only)
|
||||
|
||||
struct VS_OUTPUT {
|
||||
float4 pos : POSITION;
|
||||
float4 viewVec : TEXCOORD0;
|
||||
float4 normal : TEXCOORD1;
|
||||
#ifdef _GAPI_GXM
|
||||
float clipDist : CLP0;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef VERTEX
|
||||
@@ -28,10 +23,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
Out.normal.w = saturate(1.0 / exp(length(Out.viewVec.xyz)));
|
||||
|
||||
Out.pos = mul(uViewProj, float4(coord, rBasisPos.w));
|
||||
|
||||
#ifdef _GAPI_GXM
|
||||
Out.clipDist = Out.viewVec.w;
|
||||
#endif
|
||||
|
||||
return Out;
|
||||
}
|
||||
@@ -42,10 +33,6 @@ float4 main(VS_OUTPUT In) : COLOR0 {
|
||||
float3 rv = reflect(-In.viewVec.xyz, In.normal.xyz);
|
||||
float4 color = SAMPLE_CUBE(sEnvironment, normalize(rv));
|
||||
|
||||
#ifdef CLIP_PLANE
|
||||
clip(In.viewVec.w);
|
||||
#endif
|
||||
|
||||
color *= uMaterial;
|
||||
color.xyz = saturate(color.xyz);
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "common.hlsl"
|
||||
|
||||
// ALPHA_TEST, UNDERWATER, CLIP_PLANE (D3D9 only), OPT_SHADOW, OPT_CAUSTICS, OPT_CONTACT
|
||||
// ALPHA_TEST, UNDERWATER, OPT_SHADOW, OPT_CAUSTICS, OPT_CONTACT
|
||||
|
||||
struct VS_OUTPUT {
|
||||
float4 pos : POSITION;
|
||||
@@ -12,11 +12,6 @@ struct VS_OUTPUT {
|
||||
float3 lightMap : TEXCOORD5;
|
||||
float4 light : TEXCOORD6;
|
||||
float4 lightProj : TEXCOORD7;
|
||||
#ifdef _GAPI_GXM
|
||||
float clipDist : CLP0;
|
||||
#else
|
||||
float clipDist : TEXCOORD8;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef VERTEX
|
||||
@@ -31,7 +26,7 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
Out.coord = mulBasis(rBasisRot, rBasisPos.xyz, In.aCoord.xyz);
|
||||
Out.texCoord.xy *= Out.texCoord.zw;
|
||||
|
||||
Out.normal.xyz = mulQuat(rBasisRot, normalize(In.aNormal.xyz));
|
||||
Out.normal.xyz = normalize(In.aNormal.xyz);
|
||||
|
||||
float3 lv1 = (uLightPos[1].xyz - Out.coord) * uLightColor[1].w;
|
||||
float3 lv2 = (uLightPos[2].xyz - Out.coord) * uLightColor[2].w;
|
||||
@@ -74,8 +69,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w));
|
||||
Out.lightProj = mul(uLightProj, float4(Out.coord, 1.0));
|
||||
|
||||
Out.clipDist = uParam.w - Out.coord.y * uParam.z;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -88,10 +81,6 @@ float4 main(VS_OUTPUT In) : COLOR0 {
|
||||
clip(color.w - ALPHA_REF);
|
||||
#endif
|
||||
|
||||
#ifdef CLIP_PLANE
|
||||
clip(In.clipDist);
|
||||
#endif
|
||||
|
||||
color *= In.diffuse;
|
||||
|
||||
float3 lightVec = (uLightPos[0].xyz - In.coord) * uLightColor[0].w;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include "common.hlsl"
|
||||
|
||||
// ALPHA_TEST, UNDERWATER, OPT_CAUSTICS, CLIP_PLANE (D3D9 only)
|
||||
// ALPHA_TEST, UNDERWATER, OPT_CAUSTICS
|
||||
|
||||
struct VS_OUTPUT {
|
||||
float4 pos : POSITION;
|
||||
@@ -9,11 +9,6 @@ struct VS_OUTPUT {
|
||||
float4 normal : TEXCOORD2;
|
||||
float4 diffuse : TEXCOORD3;
|
||||
float4 light : TEXCOORD4;
|
||||
#ifdef _GAPI_GXM
|
||||
float clipDist : CLP0;
|
||||
#else
|
||||
float clipDist : TEXCOORD5;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef VERTEX
|
||||
@@ -64,8 +59,6 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
|
||||
Out.pos = mul(uViewProj, float4(Out.coord, rBasisPos.w));
|
||||
|
||||
Out.clipDist = uParam.w - Out.coord.y * uParam.z;
|
||||
|
||||
return Out;
|
||||
}
|
||||
|
||||
@@ -78,10 +71,6 @@ float4 main(VS_OUTPUT In) : COLOR0 {
|
||||
clip(color.w - ALPHA_REF);
|
||||
#endif
|
||||
|
||||
#ifdef CLIP_PLANE
|
||||
clip(In.clipDist);
|
||||
#endif
|
||||
|
||||
color *= In.diffuse;
|
||||
|
||||
float3 normal = normalize(In.normal.xyz);
|
||||
|
@@ -229,7 +229,7 @@ vec3 calcNormal(vec2 tc, float base) {
|
||||
vec2 tc = vProjCoord.xy / vProjCoord.w * 0.5 + 0.5;
|
||||
|
||||
vec4 refrA = texture2D(sDiffuse, uParam.xy * clamp(tc + dudv * uParam.z, 0.0, 0.999) );
|
||||
vec4 refrB = texture2D(sDiffuse, uParam.xy * tc );
|
||||
vec4 refrB = texture2D(sDiffuse, uParam.xy * tc);
|
||||
vec4 refr = vec4(mix(refrA.xyz, refrB.xyz, refrA.w), 1.0);
|
||||
vec4 refl = texture2D(sReflect, vec2(tc.x, 1.0 - tc.y) + dudv * uParam.w);
|
||||
|
||||
|
@@ -20,10 +20,10 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
float4 uv = float4(coord.x, coord.y, coord.x, -coord.y) * 0.5 + 0.5;
|
||||
Out.maskCoord = uv.xy * uRoomSize.zw;
|
||||
Out.texCoord = uv.zw * uTexParam.zw;
|
||||
#ifndef _GAPI_GXM
|
||||
#ifdef _GAPI_D3D9
|
||||
Out.texCoord += 0.5 * uTexParam.xy;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
coord = float3(coord.x, 0.0, coord.y) * uPosScale[1].xyz + uPosScale[0].xyz;
|
||||
|
||||
Out.pos = mul(uViewProj, float4(coord, 1.0));
|
||||
@@ -45,28 +45,28 @@ VS_OUTPUT main(VS_INPUT In) {
|
||||
|
||||
half4 main(VS_OUTPUT In) : COLOR0 {
|
||||
float3 viewVec = normalize(In.viewVec.xyz);
|
||||
|
||||
float base = SAMPLE_2D_LINEAR(sNormal, In.texCoord).x;
|
||||
float3 normal = calcHeightMapNormal(In.texCoordR, In.texCoordB, base);
|
||||
|
||||
float2 dudv = mul(uViewProj, float4(normal.x, 0.0, normal.z, 0.0)).xy * uParam.z;
|
||||
|
||||
float value = SAMPLE_2D_LINEAR(sNormal, In.texCoord).x;
|
||||
float3 normal = calcHeightMapNormal(In.texCoordR, In.texCoordB, value);
|
||||
|
||||
float2 dudv = mul(uViewProj, float4(normal.x, 0.0, normal.z, 0.0)).xy;
|
||||
float3 rv = reflect(-viewVec, normal);
|
||||
float3 lv = normalize(In.lightVec);
|
||||
|
||||
half specular = pow(max(0.0, dot(rv, lv)), 64.0) * 0.75;
|
||||
half spec = pow(max(0.0, dot(rv, lv)), 64.0) * 0.5;
|
||||
|
||||
float2 tc = In.hpos.xy / In.hpos.z * 0.5 + 0.5;
|
||||
|
||||
half4 refrA = SAMPLE_2D_LINEAR(sDiffuse, tc - dudv);
|
||||
half4 refrA = SAMPLE_2D_LINEAR(sDiffuse, clamp(tc + dudv * uParam.z, 0.0, 0.999));
|
||||
half4 refrB = SAMPLE_2D_POINT(sDiffuse, tc);
|
||||
half3 refr = lerp(refrA.xyz, refrB.xyz, refrA.w);
|
||||
half3 refl = SAMPLE_2D_LINEAR(sReflect, tc + dudv).xyz;
|
||||
half3 refl = SAMPLE_2D_LINEAR(sReflect, float2(tc.x, tc.y) + dudv * uParam.w).xyz;
|
||||
|
||||
half fresnel = calcFresnel(max(0.0, dot(normal, viewVec)), 0.12);
|
||||
|
||||
half mask = SAMPLE_2D_POINT(sMask, In.maskCoord).a;
|
||||
half4 color = half4(lerp(refr, refl, fresnel), mask);
|
||||
color.xyz += specular;
|
||||
color.xyz += spec * 1.5;
|
||||
|
||||
float dist = (In.viewVec.y / viewVec.y) * In.viewVec.w;
|
||||
color.xyz *= lerp((half3)1.0, UNDERWATER_COLOR_H, (half)clamp(dist * WATER_COLOR_DIST, 0.0, 2.0));
|
||||
|
Reference in New Issue
Block a user