Răsfoiți Sursa

More SM4 shaders. Do not render on D3D11 when shaders are not valid.

Lasse Öörni 10 ani în urmă
părinte
comite
d1a7fad925

+ 151 - 0
Bin/CoreData/Shaders/HLSL4/LitParticle.hlsl

@@ -0,0 +1,151 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "Lighting.hlsl"
+#include "Fog.hlsl"
+
+void VS(float4 iPos : POSITION,
+    float3 iNormal : NORMAL,
+    float2 iTexCoord : TEXCOORD0,
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #ifdef SKINNED
+        float4 iBlendWeights : BLENDWEIGHT,
+        int4 iBlendIndices : BLENDINDICES,
+    #endif
+    #ifdef INSTANCED
+        float4x3 iModelInstance : TEXCOORD2,
+    #endif
+    #ifdef BILLBOARD
+        float2 iSize : TEXCOORD1,
+    #endif
+    out float2 oTexCoord : TEXCOORD0,
+    out float4 oWorldPos : TEXCOORD3,
+    #if PERPIXEL
+        #ifdef SHADOW
+            out float4 oShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            out float4 oSpotPos : TEXCOORD5,
+        #endif
+        #ifdef POINTLIGHT
+            out float3 oCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        out float3 oVertexLight : TEXCOORD4,
+    #endif
+    #ifdef VERTEXCOLOR
+        out float4 oColor : COLOR0,
+    #endif
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oTexCoord = GetTexCoord(iTexCoord);
+    oWorldPos = float4(worldPos, GetDepth(oPos));
+
+    #ifdef VERTEXCOLOR
+        oColor = iColor;
+    #endif
+
+    #ifdef PERPIXEL
+        // Per-pixel forward lighting
+        float4 projWorldPos = float4(worldPos.xyz, 1.0);
+
+        #ifdef SHADOW
+            // Shadow projection: transform from world space to shadow space
+            GetShadowPos(projWorldPos, oShadowPos);
+        #endif
+
+        #ifdef SPOTLIGHT
+            // Spotlight projection: transform from world space to projector texture coordinates
+            oSpotPos = mul(projWorldPos, cLightMatrices[0]);
+        #endif
+
+        #ifdef POINTLIGHT
+            oCubeMaskVec = mul(worldPos - cLightPos.xyz, (float3x3)cLightMatrices[0]);
+        #endif
+    #else
+        // Ambient & per-vertex lighting
+        oVertexLight = GetAmbient(GetZonePos(worldPos));
+
+        #ifdef NUMVERTEXLIGHTS
+            for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
+                oVertexLight += GetVertexLightVolumetric(i, worldPos) * cVertexLights[i * 3].rgb;
+        #endif
+    #endif
+}
+
+void PS(float2 iTexCoord : TEXCOORD0,
+    float4 iWorldPos : TEXCOORD3,
+    #ifdef PERPIXEL
+        #ifdef SHADOW
+            float4 iShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            float4 iSpotPos : TEXCOORD5,
+        #endif
+        #ifdef CUBEMASK
+            float3 iCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        float3 iVertexLight : TEXCOORD4,
+    #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    out float4 oColor : SV_TARGET)
+{
+    // Get material diffuse albedo
+    #ifdef DIFFMAP
+        float4 diffInput = tDiffMap.Sample(sDiffMap, iTexCoord);
+        #ifdef ALPHAMASK
+            if (diffInput.a < 0.5)
+                discard;
+        #endif
+        float4 diffColor = cMatDiffColor * diffInput;
+    #else
+        float4 diffColor = cMatDiffColor;
+    #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= iColor;
+    #endif
+
+    // Get fog factor
+    #ifdef HEIGHTFOG
+        float fogFactor = GetHeightFogFactor(iWorldPos.w, iWorldPos.y);
+    #else
+        float fogFactor = GetFogFactor(iWorldPos.w);
+    #endif
+
+    #ifdef PERPIXEL
+        // Per-pixel forward lighting
+        float3 lightColor;
+        float3 finalColor;
+        
+        float diff = GetDiffuseVolumetric(iWorldPos.xyz);
+
+        #ifdef SHADOW
+            diff *= GetShadow(iShadowPos, iWorldPos.w);
+        #endif
+
+        #if defined(SPOTLIGHT)
+            lightColor = iSpotPos.w > 0.0 ? sLightSpotMap.Sample(sLightSpotMap, iSpotPos.xy / iSpotPos.w).rrr * cLightColor.rgb : 0.0;
+        #elif defined(CUBEMASK)
+            lightColor = tLightCubeMap.Sample(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+        #else
+            lightColor = cLightColor.rgb;
+        #endif
+
+        finalColor = diff * lightColor * diffColor.rgb;
+        oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+    #else
+        // Ambient & per-vertex lighting
+        float3 finalColor = iVertexLight * diffColor.rgb;
+
+        oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+    #endif
+}

+ 1 - 1
Bin/CoreData/Shaders/HLSL4/LitSolid.hlsl

@@ -196,7 +196,7 @@ void PS(
         #endif
 
         #if defined(SPOTLIGHT)
-            lightColor = iSpotPos.w > 0.0 ? tLightSpotMap.Sample(sLightSpotMap, iSpotPos.xy / iSpotPos.w).rgb * cLightColor.rgb : 0.0;
+            lightColor = iSpotPos.w > 0.0 ? tLightSpotMap.Sample(sLightSpotMap, iSpotPos.xy / iSpotPos.w).rrr * cLightColor.rgb : 0.0;
         #elif defined(CUBEMASK)
             lightColor = tLightCubeMap.Sample(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
         #else

+ 34 - 0
Bin/CoreData/Shaders/HLSL4/Shadow.hlsl

@@ -0,0 +1,34 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+
+void VS(float4 iPos : POSITION,
+    #ifdef SKINNED
+        float4 iBlendWeights : BLENDWEIGHT,
+        int4 iBlendIndices : BLENDINDICES,
+    #endif
+    #ifdef INSTANCED
+        float4x3 iModelInstance : TEXCOORD2,
+    #endif
+    float2 iTexCoord : TEXCOORD0,
+    out float2 oTexCoord : TEXCOORD0,
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oTexCoord = GetTexCoord(iTexCoord);
+}
+
+void PS(
+    float2 iTexCoord : TEXCOORD0,
+    out float4 oColor : SV_TARGET)
+{
+    #ifdef ALPHAMASK
+        float alpha = tDiffMap.Sample(sDiffMap, iTexCoord).a;
+        if (alpha < 0.5)
+            discard;
+    #endif
+
+    oColor = 1.0;
+}

+ 21 - 0
Bin/CoreData/Shaders/HLSL4/Skybox.hlsl

@@ -0,0 +1,21 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+
+void VS(float4 iPos : POSITION,
+    out float4 oPos : SV_POSITION,
+    out float3 oTexCoord : TEXCOORD0)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    
+    oPos.z = oPos.w;
+    oTexCoord = iPos.xyz;
+}
+
+void PS(float3 iTexCoord : TEXCOORD0,
+    out float4 oColor : SV_TARGET)
+{
+    oColor = cMatDiffColor * tDiffCubeMap.Sample(sDiffCubeMap, iTexCoord);
+}

+ 15 - 0
Bin/CoreData/Shaders/HLSL4/Stencil.hlsl

@@ -0,0 +1,15 @@
+#include "Uniforms.hlsl"
+#include "Transform.hlsl"
+
+void VS(float4 iPos : POSITION,
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+}
+
+void PS(out float4 oColor : SV_TARGET)
+{
+    oColor = 1.0;
+}

+ 207 - 0
Bin/CoreData/Shaders/HLSL4/TerrainBlend.hlsl

@@ -0,0 +1,207 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "ScreenPos.hlsl"
+#include "Lighting.hlsl"
+#include "Fog.hlsl"
+
+Texture2D tWeightMap0 : register(t0);
+Texture2D tDetailMap1 : register(t1);
+Texture2D tDetailMap2 : register(t2);
+Texture2D tDetailMap3 : register(t3);
+SamplerState sWeightMap0 : register(s0);
+SamplerState sDetailMap1 : register(s1);
+SamplerState sDetailMap2 : register(s2);
+SamplerState sDetailMap3 : register(s3);
+
+uniform float2 cDetailTiling;
+
+void VS(float4 iPos : POSITION,
+    float3 iNormal : NORMAL,
+    float2 iTexCoord : TEXCOORD0,
+    #ifdef SKINNED
+        float4 iBlendWeights : BLENDWEIGHT,
+        int4 iBlendIndices : BLENDINDICES,
+    #endif
+    #ifdef INSTANCED
+        float4x3 iModelInstance : TEXCOORD2,
+    #endif
+    #ifdef BILLBOARD
+        float2 iSize : TEXCOORD1,
+    #endif
+    out float2 oTexCoord : TEXCOORD0,
+    out float3 oNormal : TEXCOORD1,
+    out float4 oWorldPos : TEXCOORD2,
+    out float2 oDetailTexCoord : TEXCOORD3,
+    #ifdef PERPIXEL
+        #ifdef SHADOW
+            out float4 oShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            out float4 oSpotPos : TEXCOORD5,
+        #endif
+        #ifdef POINTLIGHT
+            out float3 oCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        out float3 oVertexLight : TEXCOORD4,
+        out float4 oScreenPos : TEXCOORD5,
+    #endif
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oNormal = GetWorldNormal(modelMatrix);
+    oWorldPos = float4(worldPos, GetDepth(oPos));
+    oTexCoord = GetTexCoord(iTexCoord);
+    oDetailTexCoord = cDetailTiling * oTexCoord;
+
+    #ifdef PERPIXEL
+        // Per-pixel forward lighting
+        float4 projWorldPos = float4(worldPos.xyz, 1.0);
+
+        #ifdef SHADOW
+            // Shadow projection: transform from world space to shadow space
+            GetShadowPos(projWorldPos, oShadowPos);
+        #endif
+
+        #ifdef SPOTLIGHT
+            // Spotlight projection: transform from world space to projector texture coordinates
+            oSpotPos = mul(projWorldPos, cLightMatrices[0]);
+        #endif
+
+        #ifdef POINTLIGHT
+            oCubeMaskVec = mul(worldPos - cLightPos.xyz, (float3x3)cLightMatrices[0]);
+        #endif
+    #else
+        // Ambient & per-vertex lighting
+        oVertexLight = GetAmbient(GetZonePos(worldPos));
+
+        #ifdef NUMVERTEXLIGHTS
+            for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
+                oVertexLight += GetVertexLight(i, worldPos, oNormal) * cVertexLights[i * 3].rgb;
+        #endif
+        
+        oScreenPos = GetScreenPos(oPos);
+    #endif
+}
+
+void PS(float2 iTexCoord : TEXCOORD0,
+    float3 iNormal : TEXCOORD1,
+    float4 iWorldPos : TEXCOORD2,
+    float2 iDetailTexCoord : TEXCOORD3,
+    #ifdef PERPIXEL
+        #ifdef SHADOW
+            float4 iShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            float4 iSpotPos : TEXCOORD5,
+        #endif
+        #ifdef CUBEMASK
+            float3 iCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        float3 iVertexLight : TEXCOORD4,
+        float4 iScreenPos : TEXCOORD5,
+    #endif
+    #ifdef PREPASS
+        out float4 oDepth : SV_TARGET1,
+    #endif
+    #ifdef DEFERRED
+        out float4 oAlbedo : SV_TARGET1,
+        out float4 oNormal : SV_TARGET2,
+        out float4 oDepth : SV_TARGET3,
+    #endif
+    out float4 oColor : SV_TARGET)
+{
+    // Get material diffuse albedo
+    float3 weights = tWeightMap0.Sample(sWeightMap0, iTexCoord).rgb;
+    float sumWeights = weights.r + weights.g + weights.b;
+    weights /= sumWeights;
+    float4 diffColor = cMatDiffColor * (
+        weights.r * tDetailMap1.Sample(sDetailMap1, iDetailTexCoord) +
+        weights.g * tDetailMap2.Sample(sDetailMap2, iDetailTexCoord) +
+        weights.b * tDetailMap3.Sample(sDetailMap3, iDetailTexCoord)
+    );
+
+    // Get material specular albedo
+    float3 specColor = cMatSpecColor.rgb;
+
+    // Get normal
+    float3 normal = normalize(iNormal);
+
+    // Get fog factor
+    #ifdef HEIGHTFOG
+        float fogFactor = GetHeightFogFactor(iWorldPos.w, iWorldPos.y);
+    #else
+        float fogFactor = GetFogFactor(iWorldPos.w);
+    #endif
+
+    #if defined(PERPIXEL)
+        // Per-pixel forward lighting
+        float3 lightDir;
+        float3 lightColor;
+        float3 finalColor;
+        
+        float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
+
+        #ifdef SHADOW
+            diff *= GetShadow(iShadowPos, iWorldPos.w);
+        #endif
+    
+        #if defined(SPOTLIGHT)
+            lightColor = iSpotPos.w > 0.0 ? tLightSpotMap.Sample(sLightSpotMap, iSpotPos.xy / iSpotPos.w).rrr * cLightColor.rgb : 0.0;
+        #elif defined(CUBEMASK)
+            lightColor = tLightCubeMap.Sample(sLightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+        #else
+            lightColor = cLightColor.rgb;
+        #endif
+    
+        #ifdef SPECULAR
+            float spec = GetSpecular(normal, cCameraPosPS - iWorldPos.xyz, lightDir, cMatSpecColor.a);
+            finalColor = diff * lightColor * (diffColor.rgb + spec * specColor * cLightColor.a);
+        #else
+            finalColor = diff * lightColor * diffColor.rgb;
+        #endif
+
+        #ifdef AMBIENT
+            finalColor += cAmbientColor * diffColor.rgb;
+            finalColor += cMatEmissiveColor;
+            oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+        #else
+            oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+        #endif
+    #elif defined(PREPASS)
+        // Fill light pre-pass G-Buffer
+        float specPower = cMatSpecColor.a / 255.0;
+
+        oColor = float4(normal * 0.5 + 0.5, specPower);
+        oDepth = iWorldPos.w;
+    #elif defined(DEFERRED)
+        // Fill deferred G-buffer
+        float specIntensity = specColor.g;
+        float specPower = cMatSpecColor.a / 255.0;
+
+        float3 finalColor = iVertexLight * diffColor.rgb;
+
+        oColor = float4(GetFog(finalColor, fogFactor), 1.0);
+        oAlbedo = fogFactor * float4(diffColor.rgb, specIntensity);
+        oNormal = float4(normal * 0.5 + 0.5, specPower);
+        oDepth = iWorldPos.w;
+    #else
+        // Ambient & per-vertex lighting
+        float3 finalColor = iVertexLight * diffColor.rgb;
+
+        #ifdef MATERIAL
+            // Add light pre-pass accumulation result
+            // Lights are accumulated at half intensity. Bring back to full intensity now
+            float4 lightInput = 2.0 * tLightBuffer.Sample(sLightBuffer, iScreenPos.xy / iScreenPos.w);
+            float3 lightSpecColor = lightInput.a * (lightInput.rgb / GetIntensity(lightInput.rgb));
+
+            finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
+        #endif
+
+        oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+    #endif
+}

+ 62 - 0
Bin/CoreData/Shaders/HLSL4/Text.hlsl

@@ -0,0 +1,62 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+
+#ifdef TEXT_EFFECT_SHADOW
+uniform float2 cShadowOffset;
+uniform float4 cShadowColor;
+#endif
+
+#ifdef TEXT_EFFECT_STROKE
+uniform float4 cStrokeColor;
+#endif
+
+void VS(float4 iPos : POSITION,
+        float4 iColor : COLOR0,
+        float2 iTexCoord : TEXCOORD0,
+        out float4 oPos : SV_POSITION,
+        out float4 oColor : COLOR0,
+        out float2 oTexCoord : TEXCOORD0)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oColor = iColor;
+    oTexCoord = iTexCoord;
+}
+
+void PS(float4 iColor : COLOR0,
+        float2 iTexCoord : TEXCOORD0,
+        out float4 oColor : SV_TARGET)
+{
+    oColor.rgb = iColor.rgb;
+
+#ifdef SIGNED_DISTANCE_FIELD
+    float distance = tDiffMap.Sample(sDiffMap, iTexCoord).a;
+    if (distance < 0.5f)
+    {
+    #ifdef TEXT_EFFECT_SHADOW
+        if (tDiffMap.Sample(sDiffMap, iTexCoord - cShadowOffset).a > 0.5f)
+            oColor = cShadowColor;
+        else
+    #endif
+        oColor.a = 0.0f;
+    }
+    else
+    {
+    #ifdef TEXT_EFFECT_STROKE
+        if (distance < 0.525f)
+            oColor.rgb = cStrokeColor.rgb;
+    #endif
+
+    #ifdef TEXT_EFFECT_SHADOW
+        if (tDiffMap.Sample(sDiffMap, iTexCoord + cShadowOffset).a < 0.5f)
+            oColor.a = iColor.a;
+        else
+    #endif
+        oColor.a = iColor.a * smoothstep(0.5f, 0.505f, distance);
+    }
+#else
+    oColor.a = iColor.a * tDiffMap.Sample(sDiffMap, iTexCoord).a;
+#endif
+}

+ 89 - 0
Bin/CoreData/Shaders/HLSL4/Unlit.hlsl

@@ -0,0 +1,89 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "Fog.hlsl"
+
+void VS(float4 iPos : POSITION,
+    float2 iTexCoord : TEXCOORD0,
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #ifdef SKINNED
+        float4 iBlendWeights : BLENDWEIGHT,
+        int4 iBlendIndices : BLENDINDICES,
+    #endif
+    #ifdef INSTANCED
+        float4x3 iModelInstance : TEXCOORD2,
+    #endif
+    #ifdef BILLBOARD
+        float2 iSize : TEXCOORD1,
+    #endif
+    out float2 oTexCoord : TEXCOORD0,
+    out float4 oWorldPos : TEXCOORD2,
+    #ifdef VERTEXCOLOR
+        out float4 oColor : COLOR0,
+    #endif
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oTexCoord = GetTexCoord(iTexCoord);
+    oWorldPos = float4(worldPos, GetDepth(oPos));
+
+    #ifdef VERTEXCOLOR
+        oColor = iColor;
+    #endif
+}
+
+void PS(float2 iTexCoord : TEXCOORD0,
+    float4 iWorldPos: TEXCOORD2,
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #ifdef PREPASS
+        out float4 oDepth : SV_TARGET1,
+    #endif
+    #ifdef DEFERRED
+        out float4 oAlbedo : SV_TARGET1,
+        out float4 oNormal : SV_TARGET2,
+        out float4 oDepth : SV_TARGET3,
+    #endif
+    out float4 oColor : SV_TARGET)
+{
+    // Get material diffuse albedo
+    #ifdef DIFFMAP
+        float4 diffColor = cMatDiffColor * tDiffMap.Sample(sDiffMap, iTexCoord);
+        #ifdef ALPHAMASK
+            if (diffColor.a < 0.5)
+                discard;
+        #endif
+    #else
+        float4 diffColor = cMatDiffColor;
+    #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= iColor;
+    #endif
+
+    // Get fog factor
+    #ifdef HEIGHTFOG
+        float fogFactor = GetHeightFogFactor(iWorldPos.w, iWorldPos.y);
+    #else
+        float fogFactor = GetFogFactor(iWorldPos.w);
+    #endif
+
+    #if defined(PREPASS)
+        // Fill light pre-pass G-Buffer
+        oColor = float4(0.5, 0.5, 0.5, 1.0);
+        oDepth = iWorldPos.w;
+    #elif defined(DEFERRED)
+        // Fill deferred G-buffer
+        oColor = float4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
+        oAlbedo = float4(0.0, 0.0, 0.0, 0.0);
+        oNormal = float4(0.5, 0.5, 0.5, 1.0);
+        oDepth = iWorldPos.w;
+    #else
+        oColor = float4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
+    #endif
+}

+ 27 - 0
Bin/CoreData/Shaders/HLSL4/Urho2D.hlsl

@@ -0,0 +1,27 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+
+void VS(float4 iPos : POSITION,
+    float2 iTexCoord : TEXCOORD0,
+    float4 iColor : COLOR0,
+    out float4 oColor : COLOR0,
+    out float2 oTexCoord : TEXCOORD0,
+    out float4 oPos : SV_POSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+
+    oColor = iColor;
+    oTexCoord = iTexCoord;
+}
+
+void PS(float4 iColor : COLOR0,
+        float2 iTexCoord : TEXCOORD0,
+        out float4 oColor : SV_TARGET)
+{
+    float4 diffColor = cMatDiffColor * iColor;
+    float4 diffInput = tDiffMap.Sample(sDiffMap, iTexCoord);
+    oColor = diffColor * diffInput;
+}

+ 3 - 3
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -649,7 +649,7 @@ bool Graphics::ResolveToTexture(Texture2D* destination, const IntRect& viewport)
 
 void Graphics::Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCount)
 {
-    if (!vertexCount)
+    if (!vertexCount || !shaderProgram_)
         return;
     
     PrepareDraw();
@@ -671,7 +671,7 @@ void Graphics::Draw(PrimitiveType type, unsigned vertexStart, unsigned vertexCou
 
 void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount)
 {
-    if (!indexCount)
+    if (!vertexCount || !shaderProgram_)
         return;
     
     PrepareDraw();
@@ -694,7 +694,7 @@ void Graphics::Draw(PrimitiveType type, unsigned indexStart, unsigned indexCount
 void Graphics::DrawInstanced(PrimitiveType type, unsigned indexStart, unsigned indexCount, unsigned minVertex, unsigned vertexCount,
     unsigned instanceCount)
 {
-    if (!indexCount || !instanceCount)
+    if (!indexCount || !instanceCount || !shaderProgram_)
         return;
     
     PrepareDraw();