Преглед на файлове

Cube maps, point light shadows & deferred / light prepass rendering on D3D11.

Lasse Öörni преди 10 години
родител
ревизия
6112220b16

+ 1 - 5
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -2432,11 +2432,7 @@ void Graphics::PrepareDraw()
 
 
     if (texturesDirty_ && firstDirtyTexture_ < MAX_TEXTURE_UNITS)
     if (texturesDirty_ && firstDirtyTexture_ < MAX_TEXTURE_UNITS)
     {
     {
-        // Set same textures for both vertex & pixel shaders
-        impl_->deviceContext_->VSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
-            &impl_->shaderResourceViews_[firstDirtyTexture_]);
-        impl_->deviceContext_->VSSetSamplers(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
-            &impl_->samplers_[firstDirtyTexture_]);
+        /// \todo Research how to best implement vertex texture fetch in an unified way between D3D9, D3D11 and OpenGL. For now only set PS textures to save API calls
         impl_->deviceContext_->PSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
         impl_->deviceContext_->PSSetShaderResources(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
             &impl_->shaderResourceViews_[firstDirtyTexture_]);
         impl_->deviceContext_->PSSetSamplers(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,
         impl_->deviceContext_->PSSetSamplers(firstDirtyTexture_, lastDirtyTexture_ - firstDirtyTexture_ + 1,

+ 24 - 0
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.cpp

@@ -383,6 +383,30 @@ unsigned Texture::CheckMaxLevels(int width, int height, unsigned requestedLevels
         return requestedLevels;
         return requestedLevels;
 }
 }
 
 
+unsigned Texture::GetSRVFormat(unsigned format)
+{
+    if (format == DXGI_FORMAT_R24G8_TYPELESS)
+        return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
+    else if (format == DXGI_FORMAT_R16_TYPELESS)
+        return DXGI_FORMAT_R16_UNORM;
+    else if (format == DXGI_FORMAT_R32_TYPELESS)
+        return DXGI_FORMAT_R32_FLOAT;
+    else
+        return format;
+}
+
+unsigned Texture::GetDSVFormat(unsigned format)
+{
+    if (format == DXGI_FORMAT_R24G8_TYPELESS)
+        return DXGI_FORMAT_D24_UNORM_S8_UINT;
+    else if (format == DXGI_FORMAT_R16_TYPELESS)
+        return DXGI_FORMAT_D16_UNORM;
+    else if (format == DXGI_FORMAT_R32_TYPELESS)
+        return DXGI_FORMAT_D32_FLOAT;
+    else
+        return format;
+}
+
 void Texture::CheckTextureBudget(StringHash type)
 void Texture::CheckTextureBudget(StringHash type)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();

+ 5 - 1
Source/Urho3D/Graphics/Direct3D11/D3D11Texture.h

@@ -122,7 +122,11 @@ public:
     static SharedArrayPtr<unsigned char> ConvertRGBToRGBA(int width, int height, const unsigned char* data);
     static SharedArrayPtr<unsigned char> ConvertRGBToRGBA(int width, int height, const unsigned char* data);
     /// Check maximum allowed mip levels for a specific texture size.
     /// Check maximum allowed mip levels for a specific texture size.
     static unsigned CheckMaxLevels(int width, int height, unsigned requestedLevels);
     static unsigned CheckMaxLevels(int width, int height, unsigned requestedLevels);
-    
+    /// Return the shader resource view format corresponding to a texture format. Handles conversion of typeless depth texture formats.
+    static unsigned GetSRVFormat(unsigned format);
+    /// Return the depth-stencil view format corresponding to a texture format. Handles conversion of typeless depth texture formats.
+    static unsigned GetDSVFormat(unsigned format);
+
 protected:
 protected:
     /// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references.
     /// Check whether texture memory budget has been exceeded. Free unused materials in that case to release the texture references.
     void CheckTextureBudget(StringHash type);
     void CheckTextureBudget(StringHash type);

+ 2 - 18
Source/Urho3D/Graphics/Direct3D11/D3D11Texture2D.cpp

@@ -444,20 +444,9 @@ bool Texture2D::Create()
 
 
     D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
     D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
     memset(&resourceViewDesc, 0, sizeof resourceViewDesc);
     memset(&resourceViewDesc, 0, sizeof resourceViewDesc);
-    if (usage_ != TEXTURE_DEPTHSTENCIL)
-        resourceViewDesc.Format = textureDesc.Format;
-    else
-    {
-        if (textureDesc.Format == DXGI_FORMAT_R24G8_TYPELESS)
-            resourceViewDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
-        else if (textureDesc.Format == DXGI_FORMAT_R16_TYPELESS)
-            resourceViewDesc.Format = DXGI_FORMAT_R16_UNORM;
-        else if (textureDesc.Format == DXGI_FORMAT_R32_TYPELESS)
-            resourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
-    }
+    resourceViewDesc.Format = (DXGI_FORMAT)GetSRVFormat(textureDesc.Format);
     resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
     resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
     resourceViewDesc.Texture2D.MipLevels = (unsigned)levels_;
     resourceViewDesc.Texture2D.MipLevels = (unsigned)levels_;
-    resourceViewDesc.Texture2D.MostDetailedMip = 0;
 
 
     graphics_->GetImpl()->GetDevice()->CreateShaderResourceView((ID3D11Resource*)object_, &resourceViewDesc,
     graphics_->GetImpl()->GetDevice()->CreateShaderResourceView((ID3D11Resource*)object_, &resourceViewDesc,
         (ID3D11ShaderResourceView**)&shaderResourceView_);
         (ID3D11ShaderResourceView**)&shaderResourceView_);
@@ -491,12 +480,7 @@ bool Texture2D::Create()
 
 
         D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
         D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc;
         memset(&depthStencilViewDesc, 0, sizeof depthStencilViewDesc);
         memset(&depthStencilViewDesc, 0, sizeof depthStencilViewDesc);
-        if (textureDesc.Format == DXGI_FORMAT_R24G8_TYPELESS)
-            depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
-        else if (textureDesc.Format == DXGI_FORMAT_R16_TYPELESS)
-            depthStencilViewDesc.Format = DXGI_FORMAT_D16_UNORM;
-        else if (textureDesc.Format == DXGI_FORMAT_R32_TYPELESS)
-            depthStencilViewDesc.Format = DXGI_FORMAT_D32_FLOAT;
+        depthStencilViewDesc.Format = (DXGI_FORMAT)GetDSVFormat(textureDesc.Format);
         depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
         depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
 
 
         graphics_->GetImpl()->GetDevice()->CreateDepthStencilView((ID3D11Resource*)object_, &depthStencilViewDesc,
         graphics_->GetImpl()->GetDevice()->CreateDepthStencilView((ID3D11Resource*)object_, &depthStencilViewDesc,

+ 124 - 13
Source/Urho3D/Graphics/Direct3D11/D3D11TextureCube.cpp

@@ -330,12 +330,6 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
         return false;
         return false;
     }
     }
     
     
-    if (IsCompressed())
-    {
-        x &= ~3;
-        y &= ~3;
-    }
-    
     int levelWidth = GetLevelWidth(level);
     int levelWidth = GetLevelWidth(level);
     int levelHeight = GetLevelHeight(level);
     int levelHeight = GetLevelHeight(level);
     if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
     if (x < 0 || x + width > levelWidth || y < 0 || y + height > levelHeight || width <= 0 || height <= 0)
@@ -343,17 +337,62 @@ bool TextureCube::SetData(CubeMapFace face, unsigned level, int x, int y, int wi
         LOGERROR("Illegal dimensions for setting data");
         LOGERROR("Illegal dimensions for setting data");
         return false;
         return false;
     }
     }
-    
+
+    // If compressed, align the update region on a block
     if (IsCompressed())
     if (IsCompressed())
     {
     {
-        height = (height + 3) >> 2;
-        y >>= 2;
+        x &= ~3;
+        y &= ~3;
+        width += 3;
+        width &= 0xfffffffc;
+        height += 3;
+        height &= 0xfffffffc;
     }
     }
-    
+
     unsigned char* src = (unsigned char*)data;
     unsigned char* src = (unsigned char*)data;
     unsigned rowSize = GetRowDataSize(width);
     unsigned rowSize = GetRowDataSize(width);
-    
-    /// \todo Implement
+    unsigned rowStart = GetRowDataSize(x);
+    unsigned subResource = D3D11CalcSubresource((unsigned)level, (unsigned)face, (unsigned)levels_);
+
+    if (usage_ == TEXTURE_DYNAMIC)
+    {
+        if (IsCompressed())
+        {
+            height = (height + 3) >> 2;
+            y >>= 2;
+        }
+
+        D3D11_MAPPED_SUBRESOURCE mappedData;
+        mappedData.pData = 0;
+
+        graphics_->GetImpl()->GetDeviceContext()->Map((ID3D11Resource*)object_, subResource, D3D11_MAP_WRITE_DISCARD, 0,
+            &mappedData);
+        if (mappedData.pData)
+        {
+            for (int row = 0; row < height; ++row)
+                memcpy((unsigned char*)mappedData.pData + (row + y) * mappedData.RowPitch + rowStart, src + row * rowSize, rowSize);
+            graphics_->GetImpl()->GetDeviceContext()->Unmap((ID3D11Resource*)object_, subResource);
+        }
+        else
+        {
+            LOGERROR("Failed to map texture for update");
+            return false;
+        }
+    }
+    else
+    {
+        D3D11_BOX destBox;
+        destBox.left = x;
+        destBox.right = x + width;
+        destBox.top = y;
+        destBox.bottom = y + height;
+        destBox.front = 0;
+        destBox.back = 1;
+
+        graphics_->GetImpl()->GetDeviceContext()->UpdateSubresource((ID3D11Resource*)object_, subResource, &destBox, data,
+            rowSize, 0);
+    }
+
     return true;
     return true;
 }
 }
 
 
@@ -447,6 +486,14 @@ bool TextureCube::SetData(CubeMapFace face, SharedPtr<Image> image, bool useAlph
         
         
         for (unsigned i = 0; i < levels_; ++i)
         for (unsigned i = 0; i < levels_; ++i)
         {
         {
+            // D3D11 needs RGB data as 4-component
+            SharedArrayPtr<unsigned char> convertedData;
+            if (components == 3)
+            {
+                convertedData = ConvertRGBToRGBA(levelWidth, levelHeight, levelData);
+                levelData = convertedData;
+            }
+
             SetData(face, i, 0, 0, levelWidth, levelHeight, levelData);
             SetData(face, i, 0, 0, levelWidth, levelHeight, levelData);
             memoryUse += levelWidth * levelHeight * components;
             memoryUse += levelWidth * levelHeight * components;
             
             
@@ -582,7 +629,71 @@ bool TextureCube::Create()
     if (!graphics_ || !width_ || !height_)
     if (!graphics_ || !width_ || !height_)
         return false;
         return false;
     
     
-    /// \todo Implement
+    levels_ = CheckMaxLevels(width_, height_, requestedLevels_);
+
+    D3D11_TEXTURE2D_DESC textureDesc;
+    memset(&textureDesc, 0, sizeof textureDesc);
+    textureDesc.Width = width_;
+    textureDesc.Height = height_;
+    textureDesc.MipLevels = levels_;
+    textureDesc.ArraySize = MAX_CUBEMAP_FACES;
+    textureDesc.Format = (DXGI_FORMAT)format_;
+    textureDesc.SampleDesc.Count = 1;
+    textureDesc.SampleDesc.Quality = 0;
+    textureDesc.Usage = usage_ == TEXTURE_DYNAMIC ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_DEFAULT;
+    textureDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
+    if (usage_ == TEXTURE_RENDERTARGET)
+        textureDesc.BindFlags |= D3D11_BIND_RENDER_TARGET;
+    else if (usage_ == TEXTURE_DEPTHSTENCIL)
+        textureDesc.BindFlags |= D3D11_BIND_DEPTH_STENCIL;
+    textureDesc.CPUAccessFlags = usage_ == TEXTURE_DYNAMIC ? D3D11_CPU_ACCESS_WRITE : 0;
+    textureDesc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
+
+    graphics_->GetImpl()->GetDevice()->CreateTexture2D(&textureDesc, 0, (ID3D11Texture2D**)&object_);
+    if (!object_)
+    {
+        LOGERROR("Failed to create texture");
+        return false;
+    }
+
+    D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc;
+    memset(&resourceViewDesc, 0, sizeof resourceViewDesc);
+    resourceViewDesc.Format = (DXGI_FORMAT)GetSRVFormat(textureDesc.Format);
+    resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
+    resourceViewDesc.Texture2D.MipLevels = (unsigned)levels_;
+
+    graphics_->GetImpl()->GetDevice()->CreateShaderResourceView((ID3D11Resource*)object_, &resourceViewDesc,
+        (ID3D11ShaderResourceView**)&shaderResourceView_);
+    if (!shaderResourceView_)
+    {
+        LOGERROR("Failed to create shader resource view for texture");
+        return false;
+    }
+
+    if (usage_ == TEXTURE_RENDERTARGET)
+    {
+        for (unsigned i = 0; i < MAX_CUBEMAP_FACES; ++i)
+        {
+            renderSurfaces_[i] = new RenderSurface(this);
+
+            D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
+            memset(&renderTargetViewDesc, 0, sizeof renderTargetViewDesc);
+            renderTargetViewDesc.Format = textureDesc.Format;
+            renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+            renderTargetViewDesc.Texture2DArray.ArraySize = 1;
+            renderTargetViewDesc.Texture2DArray.FirstArraySlice = i;
+            renderTargetViewDesc.Texture2DArray.MipSlice = 0;
+
+            graphics_->GetImpl()->GetDevice()->CreateRenderTargetView((ID3D11Resource*)object_, &renderTargetViewDesc,
+                (ID3D11RenderTargetView**)&renderSurfaces_[i]->renderTargetView_);
+
+            if (!renderSurfaces_[i]->renderTargetView_)
+            {
+                LOGERROR("Failed to create rendertarget view for texture");
+                return false;
+            }
+        }
+    }
 
 
     return true;
     return true;
 }
 }

+ 9 - 9
bin/CoreData/Shaders/HLSL/DeferredLight.hlsl

@@ -14,7 +14,7 @@ void VS(float4 iPos : POSITION,
     #ifdef ORTHO
     #ifdef ORTHO
         out float3 oNearRay : TEXCOORD2,
         out float3 oNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -44,11 +44,11 @@ void PS(
     #ifdef ORTHO
     #ifdef ORTHO
         float3 iNearRay : TEXCOORD2,
         float3 iNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // If rendering a directional light quad, optimize out the w divide
     // If rendering a directional light quad, optimize out the w divide
     #ifdef DIRLIGHT
     #ifdef DIRLIGHT
-        float depth = Sample(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DLod0(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -57,10 +57,10 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth;
             float3 worldPos = iFarRay * depth;
         #endif
         #endif
-        float4 albedoInput = Sample(sAlbedoBuffer, iScreenPos);
-        float4 normalInput = Sample(sNormalBuffer, iScreenPos);
+        float4 albedoInput = Sample2DLod0(AlbedoBuffer, iScreenPos);
+        float4 normalInput = Sample2DLod0(NormalBuffer, iScreenPos);
     #else
     #else
-        float depth = tex2Dproj(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DProj(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -69,8 +69,8 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth / iScreenPos.w;
             float3 worldPos = iFarRay * depth / iScreenPos.w;
         #endif
         #endif
-        float4 albedoInput = tex2Dproj(sAlbedoBuffer, iScreenPos);
-        float4 normalInput = tex2Dproj(sNormalBuffer, iScreenPos);
+        float4 albedoInput = Sample2DProj(AlbedoBuffer, iScreenPos);
+        float4 normalInput = Sample2DProj(NormalBuffer, iScreenPos);
     #endif
     #endif
     
     
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
@@ -86,7 +86,7 @@ void PS(
 
 
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
-        lightColor = spotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, spotPos).rrr * cLightColor.rgb : 0.0;
+        lightColor = spotPos.w > 0.0 ? Sample2DProj(LightSpotMap, spotPos).rrr * cLightColor.rgb : 0.0;
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
     #else
     #else

+ 1 - 1
bin/CoreData/Shaders/HLSL/LitSolid.hlsl

@@ -263,7 +263,7 @@ void PS(
             // Add light pre-pass accumulation result
             // Add light pre-pass accumulation result
             // Lights are accumulated at half intensity. Bring back to full intensity now
             // Lights are accumulated at half intensity. Bring back to full intensity now
             float4 lightInput = 2.0 * Sample2DProj(LightBuffer, iScreenPos);
             float4 lightInput = 2.0 * Sample2DProj(LightBuffer, iScreenPos);
-            float3 lightSpecColor = lightInput.a * (lightInput.rgb / GetIntensity(lightInput.rgb));
+            float3 lightSpecColor = lightInput.a * lightInput.rgb / max(GetIntensity(lightInput.rgb), 0.001);
 
 
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
             finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
         #endif
         #endif

+ 7 - 7
bin/CoreData/Shaders/HLSL/PrepassLight.hlsl

@@ -14,7 +14,7 @@ void VS(float4 iPos : POSITION,
     #ifdef ORTHO
     #ifdef ORTHO
         out float3 oNearRay : TEXCOORD2,
         out float3 oNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oPos : POSITION)
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -44,11 +44,11 @@ void PS(
     #ifdef ORTHO
     #ifdef ORTHO
         float3 iNearRay : TEXCOORD2,
         float3 iNearRay : TEXCOORD2,
     #endif
     #endif
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
     // If rendering a directional light quad, optimize out the w divide
     // If rendering a directional light quad, optimize out the w divide
     #ifdef DIRLIGHT
     #ifdef DIRLIGHT
-        float depth = Sample(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DLod0(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -57,9 +57,9 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth;
             float3 worldPos = iFarRay * depth;
         #endif
         #endif
-        float4 normalInput = Sample(sNormalBuffer, iScreenPos);
+        float4 normalInput = Sample2DLod0(NormalBuffer, iScreenPos);
     #else
     #else
-        float depth = tex2Dproj(sDepthBuffer, iScreenPos).r;
+        float depth = Sample2DProj(DepthBuffer, iScreenPos).r;
         #ifdef HWDEPTH
         #ifdef HWDEPTH
             depth = ReconstructDepth(depth);
             depth = ReconstructDepth(depth);
         #endif
         #endif
@@ -68,7 +68,7 @@ void PS(
         #else
         #else
             float3 worldPos = iFarRay * depth / iScreenPos.w;
             float3 worldPos = iFarRay * depth / iScreenPos.w;
         #endif
         #endif
-        float4 normalInput = tex2Dproj(sNormalBuffer, iScreenPos);
+        float4 normalInput = Sample2DProj(NormalBuffer, iScreenPos);
     #endif
     #endif
 
 
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
     float3 normal = normalize(normalInput.rgb * 2.0 - 1.0);
@@ -85,7 +85,7 @@ void PS(
 
 
     #if defined(SPOTLIGHT)
     #if defined(SPOTLIGHT)
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
         float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
-        lightColor = spotPos.w > 0.0 ? tex2Dproj(sLightSpotMap, spotPos).rrr * cLightColor.rgb : 0.0;
+        lightColor = spotPos.w > 0.0 ? Sample2DProj(LightSpotMap, spotPos).rrr * cLightColor.rgb : 0.0;
     #elif defined(CUBEMASK)
     #elif defined(CUBEMASK)
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
         lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
     #else
     #else

+ 1 - 1
bin/CoreData/Shaders/HLSL/Samplers.hlsl

@@ -78,7 +78,7 @@ SamplerState sZoneVolumeMap : register(s15);
 
 
 #define Sample2D(tex, uv) t##tex.Sample(s##tex, uv)
 #define Sample2D(tex, uv) t##tex.Sample(s##tex, uv)
 #define Sample2DProj(tex, uv) t##tex.Sample(s##tex, uv.xy / uv.w)
 #define Sample2DProj(tex, uv) t##tex.Sample(s##tex, uv.xy / uv.w)
-#define Sample2DLod0(tex, uv) t##tex.Sample(s##tex, uv)
+#define Sample2DLod0(tex, uv) t##tex.SampleLevel(s##tex, uv, 0.0)
 #define SampleCube(tex, uv) t##tex.Sample(s##tex, uv)
 #define SampleCube(tex, uv) t##tex.Sample(s##tex, uv)
 #define SampleShadow(tex, uv) t##tex.SampleCmpLevelZero(s##tex, uv.xy, uv.z)
 #define SampleShadow(tex, uv) t##tex.SampleCmpLevelZero(s##tex, uv.xy, uv.z)
 
 

+ 4 - 4
bin/CoreData/Shaders/HLSL/Skybox.hlsl

@@ -3,8 +3,8 @@
 #include "Transform.hlsl"
 #include "Transform.hlsl"
 
 
 void VS(float4 iPos : POSITION,
 void VS(float4 iPos : POSITION,
-    out float4 oPos : POSITION,
-    out float3 oTexCoord : TEXCOORD0)
+    out float3 oTexCoord : TEXCOORD0,
+    out float4 oPos : OUTPOSITION)
 {
 {
     float4x3 modelMatrix = iModelMatrix;
     float4x3 modelMatrix = iModelMatrix;
     float3 worldPos = GetWorldPos(modelMatrix);
     float3 worldPos = GetWorldPos(modelMatrix);
@@ -15,7 +15,7 @@ void VS(float4 iPos : POSITION,
 }
 }
 
 
 void PS(float3 iTexCoord : TEXCOORD0,
 void PS(float3 iTexCoord : TEXCOORD0,
-    out float4 oColor : COLOR0)
+    out float4 oColor : OUTCOLOR0)
 {
 {
-    oColor = cMatDiffColor * texCUBE(sDiffCubeMap, iTexCoord);
+    oColor = cMatDiffColor * SampleCube(DiffCubeMap, iTexCoord);
 }
 }