sampler refactor - part2
This commit is contained in:
@@ -15,9 +15,10 @@
|
||||
#define SSLOT_ANISO_CLAMP 10
|
||||
#define SSLOT_ANISO_WRAP 11
|
||||
#define SSLOT_ANISO_MIRROR 12
|
||||
#define SSLOT_SHADOWCOMP 13
|
||||
#define SSLOT_CMP_DEPTH 13
|
||||
#define SSLOT_RESERVED0 14
|
||||
#define SSLOT_RESERVED1 15
|
||||
#define SSLOT_COUNT_PERSISTENT SSLOT_RESERVED1 + 1 - SSLOT_COUNT_ONDEMAND
|
||||
|
||||
// On demand samplers:
|
||||
// These are bound on demand and alive until another is bound at the same slot
|
||||
@@ -25,6 +26,9 @@
|
||||
#define SSLOT_ONDEMAND1 1
|
||||
#define SSLOT_ONDEMAND2 2
|
||||
#define SSLOT_ONDEMAND3 3
|
||||
#define SSLOT_COUNT_ONDEMAND SSLOT_ONDEMAND3 + 1
|
||||
|
||||
#define SSLOT_COUNT SSLOT_COUNT_PERSISTENT + SSLOT_COUNT_ONDEMAND
|
||||
|
||||
///////////////////////////
|
||||
// Helpers:
|
||||
|
||||
@@ -14,6 +14,6 @@ struct VertextoPixel
|
||||
float main(VertextoPixel PSIn) : SV_DEPTH
|
||||
{
|
||||
[branch]if(g_xMat_hasTex)
|
||||
clip( xTextureTex.Sample(texSampler,PSIn.tex).a<0.1?-1:1 );
|
||||
clip( xTextureTex.Sample(sampler_linear_wrap,PSIn.tex).a<0.1?-1:1 );
|
||||
return distance(PSIn.pos3D.xyz,lightPos.xyz)/lightEnerdis.y;
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
Texture2D<float> xSceneDepthMap:register(t1);
|
||||
Texture2D<float4> xTexture:register(t2);
|
||||
Texture2D<float4> xNormal:register(t3);
|
||||
SamplerState texSampler:register(s0);
|
||||
|
||||
struct VertexToPixel{
|
||||
float4 pos : SV_POSITION;
|
||||
@@ -48,7 +47,7 @@ PixelOutputType main(VertexToPixel PSIn)
|
||||
if (hasTexNor & 0x0000010){
|
||||
float3 normal = normalize(cross(ddx(pos3D), ddy(pos3D)));
|
||||
//clip( dot(normal,front)>-0.2?-1:1 ); //clip at oblique angle
|
||||
float4 nortex=xNormal.Sample(texSampler,projTex.xy);
|
||||
float4 nortex=xNormal.Sample(sampler_aniso_clamp,projTex.xy);
|
||||
float3 eyevector = normalize( eye - pos3D );
|
||||
if(nortex.a>0){
|
||||
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -projTex.xy);
|
||||
@@ -60,7 +59,7 @@ PixelOutputType main(VertexToPixel PSIn)
|
||||
Out.nor.xyz=normal;
|
||||
}
|
||||
if(hasTexNor & 0x0000001){
|
||||
Out.col=xTexture.Sample(texSampler,projTex.xy);
|
||||
Out.col=xTexture.Sample(sampler_aniso_clamp,projTex.xy);
|
||||
Out.col.a*=opacity;
|
||||
float3 edgeBlend = clipSpace.xyz;
|
||||
edgeBlend.z = edgeBlend.z * 2 - 1;
|
||||
|
||||
@@ -16,9 +16,9 @@ float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET
|
||||
|
||||
[branch]if(depth<g_xCamera_ZFarP){
|
||||
color=pow(abs(color),GAMMA);
|
||||
float4 lighting = xLightMap.SampleLevel(Sampler,PSIn.tex,0);
|
||||
float4 lighting = xLightMap.SampleLevel(sampler_point_clamp,PSIn.tex,0);
|
||||
color.rgb *= lighting.rgb + g_xWorld_Ambient.rgb;
|
||||
color.rgb *= xAOMap.SampleLevel(Sampler, PSIn.tex.xy, 0).rrr;
|
||||
color.rgb *= xAOMap.SampleLevel(sampler_linear_clamp, PSIn.tex.xy, 0).rrr;
|
||||
color=pow(abs(color),INV_GAMMA);
|
||||
|
||||
float fog = getFog((depth));
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// dir light constant buffer is global
|
||||
|
||||
Texture2D<float> xTextureSh[3]:register(t4);
|
||||
SamplerComparisonState compSampler:register(s1);
|
||||
|
||||
inline float offset_lookup(Texture2D<float> intex, SamplerComparisonState map,
|
||||
float2 loc,
|
||||
@@ -30,13 +29,13 @@ inline float shadowCascade(float4 shadowPos, float2 ShTex, Texture2D<float> shad
|
||||
for (float y = -range; y <= range; y += 1.0f)
|
||||
for (float x = -range; x <= range; x += 1.0f)
|
||||
{
|
||||
sum += offset_lookup(shadowTexture, compSampler, ShTex, float2(x, y), scale, realDistance);
|
||||
sum += offset_lookup(shadowTexture, sampler_cmp_depth, ShTex, float2(x, y), scale, realDistance);
|
||||
samples++;
|
||||
}
|
||||
|
||||
retVal *= sum / samples;
|
||||
}
|
||||
else retVal *= offset_lookup(shadowTexture, compSampler, ShTex, float2(0, 0), scale, realDistance);
|
||||
else retVal *= offset_lookup(shadowTexture, sampler_cmp_depth, ShTex, float2(0, 0), scale, realDistance);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -6,20 +6,18 @@
|
||||
float4 main( VertexToPixel PSIn ) : SV_TARGET
|
||||
{
|
||||
float4 color = float4(g_xDirLight_col.rgb,1);
|
||||
float2 screenPos;
|
||||
screenPos.x = PSIn.pos2D.x/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
screenPos.y = -PSIn.pos2D.y/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(Sampler,screenPos,0);
|
||||
float2 screenPos = float2(1,-1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
//clip(depth<1?1:-1);
|
||||
|
||||
//[branch]if(depth<g_xCamera_ZFarP)
|
||||
{
|
||||
|
||||
float4 norU = normalMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 norU = normalMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
bool unshaded = isUnshaded(norU.w);
|
||||
|
||||
[branch]if(!unshaded){
|
||||
float4 material = materialMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 material = materialMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
float specular = material.w*specularMaximumIntensity;
|
||||
uint specular_power = material.z;
|
||||
float3 normal = norU.xyz;
|
||||
|
||||
@@ -25,10 +25,6 @@ struct HullOutputType
|
||||
|
||||
|
||||
Texture2D dispMap:register(t0);
|
||||
/*Texture2D dispMap1:register(t1);
|
||||
Texture2D dispMap2:register(t2);
|
||||
Texture2D dispMap3:register(t3);*/
|
||||
SamplerState texSampler:register(s0);
|
||||
|
||||
float3 GetLightDirection(float3 pos3D, float3 lightPos)
|
||||
{
|
||||
@@ -102,7 +98,7 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
|
||||
Out.clip = dot(vertexPosition, g_xClipPlane);
|
||||
|
||||
////DISPLACEMENT
|
||||
//if(xDisplace[(uint)patch[0].tex.z]) vertexPosition.xyz += vertexNormal * (-1+dispMap.SampleLevel( texSampler,vertexTex,0 ).r) *0.4;
|
||||
//if(xDisplace[(uint)patch[0].tex.z]) vertexPosition.xyz += vertexNormal * (-1+dispMap.SampleLevel( sampler_aniso_wrap,vertexTex,0 ).r) *0.4;
|
||||
//
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@ Texture2D<float> xTextureMat:register(t4);
|
||||
Texture2D<float4> xTextureNor:register(t5);
|
||||
Texture2D<float4> xTextureSpe:register(t6);
|
||||
|
||||
SamplerState texSampler:register(s0);
|
||||
SamplerState mapSampler:register(s1);
|
||||
|
||||
struct PixelOutputType
|
||||
{
|
||||
float4 col : SV_TARGET0;
|
||||
|
||||
@@ -25,7 +25,7 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
PSIn.tex *= g_xMat_texMulAdd.xy;
|
||||
PSIn.tex += g_xMat_texMulAdd.zw;
|
||||
[branch]if(g_xMat_hasTex) {
|
||||
baseColor *= xTextureTex.Sample(texSampler,PSIn.tex);
|
||||
baseColor *= xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex);
|
||||
}
|
||||
baseColor.rgb *= PSIn.instanceColor;
|
||||
|
||||
@@ -38,7 +38,7 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
//NORMALMAP
|
||||
float3 bumpColor=0;
|
||||
if(g_xMat_hasNor){
|
||||
float4 nortex = xTextureNor.Sample(texSampler,PSIn.tex);
|
||||
float4 nortex = xTextureNor.Sample(sampler_aniso_wrap,PSIn.tex);
|
||||
if(nortex.a>0){
|
||||
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex.xy);
|
||||
bumpColor = 2.0f * nortex.rgb - 1.0f;
|
||||
@@ -50,7 +50,7 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
|
||||
//SPECULAR
|
||||
//if(hasRefNorTexSpe.w){
|
||||
spec = lerp(spec,xTextureSpe.Sample(texSampler, PSIn.tex).r, g_xMat_hasSpe);
|
||||
spec = lerp(spec,xTextureSpe.Sample(sampler_aniso_wrap, PSIn.tex).r, g_xMat_hasSpe);
|
||||
//}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
enviroTex.GetDimensions(mip,size.x,size.y,mipLevels);
|
||||
|
||||
float3 ref = normalize(reflect(-eyevector, normal));
|
||||
envCol = enviroTex.SampleLevel(texSampler,ref,(1-smoothstep(0,128, g_xMat_specular_power))*mipLevels);
|
||||
envCol = enviroTex.SampleLevel(sampler_linear_clamp,ref,(1-smoothstep(0,128, g_xMat_specular_power))*mipLevels);
|
||||
baseColor = lerp(baseColor,envCol, g_xMat_metallic*spec);
|
||||
}
|
||||
|
||||
@@ -74,9 +74,9 @@ PixelOutputType main(PixelInputType PSIn)
|
||||
RefTex.x = PSIn.ReflectionMapSamplingPos.x/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
|
||||
RefTex.y = -PSIn.ReflectionMapSamplingPos.y/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
|
||||
float colorMat = 0;
|
||||
colorMat = xTextureMat.SampleLevel(texSampler,PSIn.tex,0);
|
||||
colorMat = xTextureMat.SampleLevel(sampler_aniso_wrap,PSIn.tex,0);
|
||||
normal = normalize( lerp(normal,PSIn.nor,pow(abs(colorMat.x),0.02f)) );
|
||||
float4 colorReflection = xTextureRef.SampleLevel(mapSampler,RefTex+normal.xz,0);
|
||||
float4 colorReflection = xTextureRef.SampleLevel(sampler_linear_clamp,RefTex+normal.xz,0);
|
||||
baseColor.rgb=lerp(baseColor.rgb,colorReflection.rgb,colorMat);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
|
||||
//if(mat == matIndex){
|
||||
if(g_xMat_hasTex) {
|
||||
baseColor = xTextureTex.Sample(texSampler,PSIn.tex);
|
||||
baseColor = xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex);
|
||||
/*else if(mat==1) baseColor = xTextureTex1.Sample(texSampler,PSIn.tex);
|
||||
else if(mat==2) baseColor = xTextureTex2.Sample(texSampler,PSIn.tex);
|
||||
else if(mat==3) baseColor = xTextureTex3.Sample(texSampler,PSIn.tex);*/
|
||||
|
||||
@@ -20,7 +20,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
PSIn.tex += g_xMat_texMulAdd.zw;
|
||||
|
||||
if (g_xMat_hasTex) {
|
||||
baseColor *= xTextureTex.Sample(texSampler, PSIn.tex);
|
||||
baseColor *= xTextureTex.Sample(sampler_aniso_wrap, PSIn.tex);
|
||||
}
|
||||
baseColor.rgb *= PSIn.instanceColor;
|
||||
|
||||
@@ -36,7 +36,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
//NORMALMAP
|
||||
float3 bumpColor = 0;
|
||||
if (g_xMat_hasNor){
|
||||
float4 nortex = xTextureNor.Sample(texSampler, PSIn.tex);
|
||||
float4 nortex = xTextureNor.Sample(sampler_aniso_wrap, PSIn.tex);
|
||||
if (nortex.a>0){
|
||||
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex.xy);
|
||||
bumpColor = 2.0f * nortex.rgb - 1.0f;
|
||||
@@ -45,7 +45,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
}
|
||||
}
|
||||
|
||||
spec = lerp(spec, xTextureSpe.Sample(texSampler, PSIn.tex).r, g_xMat_hasSpe);
|
||||
spec = lerp(spec, xTextureSpe.Sample(sampler_aniso_wrap, PSIn.tex).r, g_xMat_hasSpe);
|
||||
|
||||
//ENVIROMENT MAP
|
||||
float4 envCol = 0;
|
||||
@@ -56,7 +56,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
enviroTex.GetDimensions(mip, size.x, size.y, mipLevels);
|
||||
|
||||
float3 ref = normalize(reflect(-eyevector, normal));
|
||||
envCol = enviroTex.SampleLevel(texSampler, ref, (1 - smoothstep(0, 128, g_xMat_specular_power))*mipLevels);
|
||||
envCol = enviroTex.SampleLevel(sampler_linear_clamp, ref, (1 - smoothstep(0, 128, g_xMat_specular_power))*mipLevels);
|
||||
baseColor = lerp(baseColor, envCol, g_xMat_metallic*spec);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ float4 main(PixelInputType PSIn) : SV_TARGET
|
||||
|
||||
//if(PSIn.mat==matIndex){
|
||||
if(g_xMat_hasTex) {
|
||||
baseColor *= xTextureTex.Sample(texSampler,PSIn.tex);
|
||||
baseColor *= xTextureTex.Sample(sampler_aniso_wrap,PSIn.tex);
|
||||
}
|
||||
baseColor.rgb *= PSIn.instanceColor;
|
||||
//baseColor=pow(baseColor,GAMMA);
|
||||
|
||||
@@ -18,7 +18,7 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
PSIn.tex += g_xMat_texMulAdd.zw;
|
||||
|
||||
[branch]if(g_xMat_hasTex){
|
||||
baseColor *= xTextureTex.Sample(texSampler, PSIn.tex);
|
||||
baseColor *= xTextureTex.Sample(sampler_aniso_wrap, PSIn.tex);
|
||||
//baseColor*=baseColor.a;
|
||||
}
|
||||
baseColor.rgb *= PSIn.instanceColor;
|
||||
@@ -35,7 +35,7 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
//NORMALMAP
|
||||
float3 bumpColor=0;
|
||||
if(g_xMat_hasNor){
|
||||
float4 nortex = xTextureNor.Sample(texSampler,PSIn.tex);
|
||||
float4 nortex = xTextureNor.Sample(sampler_aniso_wrap,PSIn.tex);
|
||||
if(nortex.a>0){
|
||||
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex.xy);
|
||||
bumpColor = 2.0f * nortex.rgb - 1.0f;
|
||||
@@ -55,14 +55,14 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
enviroTex.GetDimensions(mip,size.x,size.y,mipLevels);
|
||||
|
||||
float3 ref = normalize(reflect(-eyevector, normal));
|
||||
envCol = enviroTex.SampleLevel(texSampler,ref,(1-smoothstep(0,128, g_xMat_specular_power))*mipLevels);
|
||||
envCol = enviroTex.SampleLevel(sampler_linear_clamp,ref,(1-smoothstep(0,128, g_xMat_specular_power))*mipLevels);
|
||||
baseColor = lerp(baseColor,envCol, g_xMat_metallic*spec);
|
||||
}
|
||||
|
||||
|
||||
//REFRACTION
|
||||
float2 perturbatedRefrTexCoords = screenPos.xy + (normalize(PSIn.nor2D).rg + bumpColor.rg) * g_xMat_refractionIndex;
|
||||
float4 refractiveColor = (xTextureRefrac.SampleLevel(mapSampler, perturbatedRefrTexCoords, 0));
|
||||
float4 refractiveColor = (xTextureRefrac.SampleLevel(sampler_linear_clamp, perturbatedRefrTexCoords, 0));
|
||||
baseColor.rgb=lerp(refractiveColor.rgb,baseColor.rgb,baseColor.a);
|
||||
|
||||
baseColor.rgb=pow(abs(baseColor.rgb),GAMMA);
|
||||
@@ -73,7 +73,7 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
|
||||
//SPECULAR
|
||||
if(g_xMat_hasSpe && !g_xMat_shadeless){
|
||||
spec = xTextureSpe.Sample(texSampler, PSIn.tex);
|
||||
spec = xTextureSpe.Sample(sampler_aniso_wrap, PSIn.tex);
|
||||
}
|
||||
/*float3 reflectionVector = reflect(xSun, normal);
|
||||
float specR = dot(normalize(reflectionVector), eyevector);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "effectHF_VS.hlsli"
|
||||
|
||||
Texture2D noiseTex:register(t0);
|
||||
SamplerState texSampler:register(s0);
|
||||
|
||||
PixelInputType main(Input input)
|
||||
{
|
||||
@@ -47,7 +46,7 @@ PixelInputType main(Input input)
|
||||
//VERTEX OFFSET MOTION BLUR
|
||||
//if(xMotionBlur.x){
|
||||
//float offsetMod = dot(input.nor,vel);
|
||||
//pos = lerp(pos,posPrev,(offsetMod<0?((1-saturate(offsetMod))*(noiseTex.SampleLevel( texSampler,input.tex.xy,0 ).r)*0.6f):0));
|
||||
//pos = lerp(pos,posPrev,(offsetMod<0?((1-saturate(offsetMod))*(noiseTex.SampleLevel( sampler_linear_wrap,input.tex.xy,0 ).r)*0.6f):0));
|
||||
//}
|
||||
|
||||
Out.pos = Out.pos2D = mul( pos, g_xCamera_VP );
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
Texture2D xTexture:register (t0);
|
||||
SamplerState Sampler;
|
||||
|
||||
struct VertextoPixel
|
||||
{
|
||||
@@ -9,5 +10,5 @@ struct VertextoPixel
|
||||
|
||||
float4 main(VertextoPixel PSIn) : SV_TARGET
|
||||
{
|
||||
return xTexture.Sample(Sampler, PSIn.tex);
|
||||
return xTexture.Sample(sampler_linear_clamp, PSIn.tex);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ SAMPLERSTATE( sampler_point_mirror, SSLOT_POINT_MIRROR )
|
||||
SAMPLERSTATE( sampler_aniso_clamp, SSLOT_ANISO_CLAMP )
|
||||
SAMPLERSTATE( sampler_aniso_wrap, SSLOT_ANISO_WRAP )
|
||||
SAMPLERSTATE( sampler_aniso_mirror, SSLOT_ANISO_MIRROR )
|
||||
SAMPLERCOMPARISONSTATE( sampler_shadow_cmp, SSLOT_SHADOWCOMP )
|
||||
SAMPLERCOMPARISONSTATE( sampler_cmp_depth, SSLOT_CMP_DEPTH )
|
||||
|
||||
CBUFFER(WorldCB, CBSLOT_RENDERER_WORLD)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ Texture2D<float4> xRefracTexture:register(t4);
|
||||
Texture2D<float4> xMaskTex:register(t5);
|
||||
Texture2D<float4> xTexture:register(t6);
|
||||
|
||||
SamplerState Sampler:register(s0);
|
||||
SAMPLERSTATE(Sampler, SSLOT_ONDEMAND0);
|
||||
|
||||
struct VertextoPixel
|
||||
{
|
||||
|
||||
@@ -20,7 +20,6 @@ struct VertextoPixel{
|
||||
|
||||
Texture2D<float> depth:register(t0);
|
||||
Texture2D flare[7]:register(t1);
|
||||
SamplerComparisonState compSampler:register(s0);
|
||||
|
||||
inline void append(inout TriangleStream<VertextoPixel> triStream, VertextoPixel p1, uint selector, float2 posMod, float2 size){
|
||||
float2 pos = (xSunPos.xy-0.5)*float2(2,-2);
|
||||
@@ -96,7 +95,7 @@ void main(point InVert p[1], inout TriangleStream<VertextoPixel> triStream)
|
||||
for (float y = -range; y <= range; y += 1.0f)
|
||||
for (float x = -range; x <= range; x += 1.0f){
|
||||
samples+=1.0f;
|
||||
accdepth += ( depth.SampleCmpLevelZero(compSampler,xSunPos.xy+float2(x,y)/(depthMapSize*xSunPos.z),xSunPos.z).r ) ;
|
||||
accdepth += ( depth.SampleCmpLevelZero(sampler_cmp_depth,xSunPos.xy+float2(x,y)/(depthMapSize*xSunPos.z),xSunPos.z).r ) ;
|
||||
}
|
||||
accdepth/=samples;
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
struct VertextoPixel{
|
||||
float4 pos : SV_POSITION;
|
||||
float3 texPos : TEXCOORD0;
|
||||
@@ -6,41 +8,33 @@ struct VertextoPixel{
|
||||
};
|
||||
|
||||
Texture2D flare[7]:register(t1);
|
||||
SamplerState flareSampler:register(s0);
|
||||
|
||||
|
||||
float4 main(VertextoPixel PSIn) : SV_TARGET
|
||||
{
|
||||
//float4 color = flare[0].Sample(flareSampler,PSIn.texPosSel.xy);
|
||||
//color = lerp(color,flare[1].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/1));
|
||||
//color = lerp(color,flare[2].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/2));
|
||||
//color = lerp(color,flare[3].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/3));
|
||||
//color = lerp(color,flare[4].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/4));
|
||||
//color = lerp(color,flare[5].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/5));
|
||||
//color = lerp(color,flare[6].Sample(flareSampler,PSIn.texPosSel.xy), int(PSIn.texPosSel.w/6));
|
||||
float4 color=0;
|
||||
[branch]
|
||||
switch(PSIn.sel){ // sad :(
|
||||
case 0:
|
||||
color=flare[0].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[0].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 1:
|
||||
color=flare[1].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[1].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 2:
|
||||
color=flare[2].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[2].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 3:
|
||||
color=flare[3].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[3].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 4:
|
||||
color=flare[4].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[4].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 5:
|
||||
color=flare[5].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[5].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
case 6:
|
||||
color=flare[6].SampleLevel(flareSampler,PSIn.texPos.xy,0);
|
||||
color=flare[6].SampleLevel(sampler_linear_clamp,PSIn.texPos.xy,0);
|
||||
break;
|
||||
default:break;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@ Texture2D<float> depthMap:register(t0);
|
||||
Texture2D<float4> normalMap:register(t1);
|
||||
//Texture2D<float4> specularMap:register(t2);
|
||||
Texture2D<float4> materialMap:register(t2);
|
||||
SamplerState Sampler:register(s0);
|
||||
|
||||
static const float specularMaximumIntensity = 1;
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
TextureCube xTextureSh:register(t7);
|
||||
SamplerComparisonState compSampler:register(s1);
|
||||
|
||||
CBUFFER(PointLightCB, CBSLOT_RENDERER_POINTLIGHT)
|
||||
{
|
||||
@@ -25,7 +24,7 @@ inline float pointLight(in float3 pos3D, in float3 normal, out float3 lightDir,
|
||||
[branch]if(lightEnerdis.w){
|
||||
const float3 lv = pos3D.xyz-lightPos.xyz;
|
||||
static const float bias = 0.025;
|
||||
lightint *= xTextureSh.SampleCmpLevelZero(compSampler,lv,length(lv)/lightEnerdis.y-bias ).r;
|
||||
lightint *= xTextureSh.SampleCmpLevelZero(sampler_cmp_depth,lv,length(lv)/lightEnerdis.y-bias ).r;
|
||||
}
|
||||
|
||||
return saturate(attenuation*lightint);
|
||||
|
||||
@@ -5,18 +5,16 @@
|
||||
float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
{
|
||||
float4 light = float4(lightColor.rgb,1);
|
||||
float2 screenPos;
|
||||
screenPos.x = PSIn.pos2D.x/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
screenPos.y = -PSIn.pos2D.y/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(Sampler,screenPos,0);
|
||||
float2 screenPos = float2(1,-1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
|
||||
[branch]if(depth<g_xCamera_ZFarP){
|
||||
|
||||
float4 norU = normalMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 norU = normalMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
bool unshaded = isUnshaded(norU.w);
|
||||
|
||||
[branch]if(!unshaded){
|
||||
float4 material = materialMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 material = materialMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
float specular = material.w*specularMaximumIntensity;
|
||||
uint specular_power = material.z;
|
||||
float3 normal = norU.xyz;
|
||||
@@ -45,7 +43,7 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
light=float4(1,1,1,1);
|
||||
|
||||
//float3 lv = pos3D.xyz-lightPos.xyz;
|
||||
//light=xTextureSh.Sample(Sampler,lv);
|
||||
//light=xTextureSh.Sample(sampler_point_clamp,lv);
|
||||
//light=lightColor;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
Texture2D xTexture : register(t0);
|
||||
Texture2D<float> depthMap:register(t1);
|
||||
SamplerState Sampler : register(s0);
|
||||
|
||||
struct VertextoPixel
|
||||
{
|
||||
@@ -18,16 +17,14 @@ struct VertextoPixel
|
||||
|
||||
float4 main(VertextoPixel PSIn) : SV_TARGET
|
||||
{
|
||||
float2 pTex;
|
||||
pTex.x = PSIn.pp.x/PSIn.pp.w/2.0f +0.5f;
|
||||
pTex.y = -PSIn.pp.y/PSIn.pp.w/2.0f +0.5f;
|
||||
float4 depthScene=(depthMap.GatherRed(Sampler,pTex));
|
||||
float2 pTex = float2(1,-1) * PSIn.pp.xy / PSIn.pp.w / 2.0f + 0.5f;
|
||||
float4 depthScene=(depthMap.GatherRed(sampler_linear_clamp,pTex));
|
||||
float depthFragment=PSIn.pp.z;
|
||||
float fade = saturate(1.0/PSIn.opaAddDarkSiz.w*(max(max(depthScene.x,depthScene.y),max(depthScene.z,depthScene.w))-depthFragment));
|
||||
//fade = depthScene<depthFragment?0:1;
|
||||
|
||||
float4 color = float4(0,0,0,0);
|
||||
color=xTexture.Sample(Sampler,PSIn.tex);
|
||||
color=xTexture.Sample(sampler_linear_clamp,PSIn.tex);
|
||||
|
||||
[branch]if(PSIn.opaAddDarkSiz.z){
|
||||
color.rgb=float3(0,0,0);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include "grassHF_PS.hlsli"
|
||||
#include "ditherHF.hlsli"
|
||||
Texture2D xTexture:register(t0);
|
||||
SamplerState xSampler:register(s0);
|
||||
|
||||
PS_OUT main(QGS_OUT PSIn)
|
||||
{
|
||||
@@ -10,15 +9,12 @@ PS_OUT main(QGS_OUT PSIn)
|
||||
clip(dither(PSIn.pos.xy) - PSIn.fade);
|
||||
#endif
|
||||
|
||||
float2 ScreenCoord, ScreenCoordPrev;
|
||||
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
ScreenCoordPrev.x = PSIn.pos2DPrev.x / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
float2 ScreenCoord = float2(1, -1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
float2 ScreenCoordPrev = float2(1, -1) * PSIn.pos2DPrev.xy / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
float2 vel = ScreenCoord - ScreenCoordPrev;
|
||||
|
||||
PS_OUT Out = (PS_OUT)0;
|
||||
float4 col = xTexture.Sample(xSampler,PSIn.tex);
|
||||
float4 col = xTexture.Sample(sampler_linear_clamp,PSIn.tex);
|
||||
clip( col.a < 0.1 ? -1:1 );
|
||||
Out.col = float4(col.rgb,1);
|
||||
Out.nor = float4(PSIn.nor,0);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
Texture2D<float4> xTextureTex:register(t0);
|
||||
SamplerState texSampler:register(s0);
|
||||
|
||||
struct VertextoPixel
|
||||
{
|
||||
@@ -12,5 +11,5 @@ struct VertextoPixel
|
||||
void main(VertextoPixel PSIn)
|
||||
{
|
||||
[branch]if(g_xMat_hasTex)
|
||||
clip( xTextureTex.Sample(texSampler,PSIn.tex).a<0.1?-1:1 );
|
||||
clip( xTextureTex.Sample(sampler_linear_wrap,PSIn.tex).a<0.1?-1:1 );
|
||||
}
|
||||
@@ -9,7 +9,7 @@ inline float4 GetSkyColor(in float3 normal)
|
||||
|
||||
normal = normalize(normal) * overBright;
|
||||
|
||||
float3 col = /*lerp( xHorizon.rgb,*/ enviroTex.SampleLevel(texSampler, normal, 0).rgb/*, saturate(nor.y/0.3f) )*/;
|
||||
float3 col = /*lerp( xHorizon.rgb,*/ enviroTex.SampleLevel(sampler_linear_clamp, normal, 0).rgb/*, saturate(nor.y/0.3f) )*/;
|
||||
float3 sun = max(pow(abs(dot(g_xWorld_SunDir.xyz, normal)), 256)*g_xWorld_SunColor.rgb, 0);
|
||||
|
||||
return float4(col + sun, 1);
|
||||
|
||||
@@ -16,11 +16,8 @@ struct PSOut{
|
||||
|
||||
PSOut main(VSOut PSIn)
|
||||
{
|
||||
float2 ScreenCoord, ScreenCoordPrev;
|
||||
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
ScreenCoordPrev.x = PSIn.pos2DPrev.x / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
float2 ScreenCoord = float2(1, -1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
float2 ScreenCoordPrev = float2(1, -1) * PSIn.pos2DPrev.xy / PSIn.pos2DPrev.w / 2.0f + 0.5f;
|
||||
float2 vel = ScreenCoord - ScreenCoordPrev;
|
||||
|
||||
PSOut Out = (PSOut)0;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Texture2D<float> xTextureSh:register(t4);
|
||||
SamplerComparisonState compSampler:register(s1);
|
||||
|
||||
|
||||
CBUFFER(SpotLightCB, CBSLOT_RENDERER_SPOTLIGHT)
|
||||
@@ -27,7 +26,7 @@ inline float shadowCascade(float4 shadowPos, float2 ShTex, Texture2D<float> shad
|
||||
float sum = 0;
|
||||
float scale = xBiasResSoftshadow.y;
|
||||
float retVal = 1;
|
||||
retVal *= offset_lookup(shadowTexture, compSampler, ShTex, float2(0, 0), scale, realDistance);
|
||||
retVal *= offset_lookup(shadowTexture, sampler_cmp_depth, ShTex, float2(0, 0), scale, realDistance);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
{
|
||||
float4 light = float4(lightColor.rgb,1);
|
||||
float2 screenPos;
|
||||
screenPos.x = PSIn.pos2D.x/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
screenPos.y = -PSIn.pos2D.y/PSIn.pos2D.w/2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(Sampler,screenPos,0);
|
||||
float2 screenPos = float2(1,-1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f;
|
||||
float depth = depthMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
//clip(depth<1?1:-1);
|
||||
|
||||
|
||||
@@ -16,11 +14,11 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
|
||||
[branch]if(depth<g_xCamera_ZFarP){
|
||||
|
||||
float4 norU = normalMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 norU = normalMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
bool unshaded = isUnshaded(norU.w);
|
||||
|
||||
[branch]if(!unshaded){
|
||||
float4 material = materialMap.SampleLevel(Sampler,screenPos,0);
|
||||
float4 material = materialMap.SampleLevel(sampler_point_clamp,screenPos,0);
|
||||
float specular = material.w*specularMaximumIntensity;
|
||||
uint specular_power = material.z;
|
||||
float3 normal = norU.xyz;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#include "globals.hlsli"
|
||||
|
||||
Texture2D<float4> xRefracTexture:register(t0);
|
||||
Texture2D<float4> xDistortionTexture:register(t1);
|
||||
Texture2D<float4> xTexture:register(t2);
|
||||
SamplerState xSampler:register(s0);
|
||||
|
||||
struct VertexToPixel{
|
||||
float4 pos : SV_POSITION;
|
||||
@@ -17,7 +18,7 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
float blendOut = 1 - pow(max(co.x,co.y), 2);
|
||||
blendOut *= PSIn.col.a;
|
||||
|
||||
float4 tex = xTexture.Sample(xSampler,PSIn.tex);
|
||||
float4 tex = xTexture.Sample(sampler_linear_mirror,PSIn.tex);
|
||||
tex.a *= blendOut;
|
||||
|
||||
float4 color = float4(PSIn.col.rgb * blendOut,1);
|
||||
@@ -25,15 +26,15 @@ float4 main(VertexToPixel PSIn) : SV_TARGET
|
||||
float2 distortionCo;
|
||||
distortionCo.x = PSIn.dis.x/PSIn.dis.w/2.0f + 0.5f;
|
||||
distortionCo.y = -PSIn.dis.y/PSIn.dis.w/2.0f + 0.5f;
|
||||
float2 distort = (xDistortionTexture.Sample(xSampler,PSIn.tex).rg - float2(0.5f, 0.5f))*0.3f * blendOut;
|
||||
float2 distort = (xDistortionTexture.Sample(sampler_linear_mirror,PSIn.tex).rg - float2(0.5f, 0.5f))*0.3f * blendOut;
|
||||
|
||||
// Chromatic Aberration
|
||||
float2 dim;
|
||||
xRefracTexture.GetDimensions(dim.x, dim.y);
|
||||
dim = 4.0f / dim * blendOut;
|
||||
color.r += xRefracTexture.SampleLevel(xSampler, distortionCo + distort + dim * float2(1, 1), 0).r;
|
||||
color.g += xRefracTexture.SampleLevel(xSampler, distortionCo + distort + dim * float2(-1, 1), 0).g;
|
||||
color.b += xRefracTexture.SampleLevel(xSampler, distortionCo + distort + dim * float2(0, -1), 0).b;
|
||||
color.r += xRefracTexture.SampleLevel(sampler_linear_mirror, distortionCo + distort + dim * float2(1, 1), 0).r;
|
||||
color.g += xRefracTexture.SampleLevel(sampler_linear_mirror, distortionCo + distort + dim * float2(-1, 1), 0).g;
|
||||
color.b += xRefracTexture.SampleLevel(sampler_linear_mirror, distortionCo + distort + dim * float2(0, -1), 0).b;
|
||||
|
||||
color.rgb = lerp(color.rgb, tex.rgb, tex.a);
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
float3 bumpColor=0;
|
||||
if(g_xMat_hasNor){
|
||||
float3x3 tangentFrame = compute_tangent_frame(normal, eyevector, -PSIn.tex);
|
||||
bumpColor0 = 2.0f * xTextureNor.Sample(texSampler,PSIn.tex - g_xMat_texMulAdd.ww).rg - 1.0f;
|
||||
bumpColor1 = 2.0f * xTextureNor.Sample(texSampler,PSIn.tex + g_xMat_texMulAdd.zw).rg - 1.0f;
|
||||
bumpColor2 = xRippleMap.Sample(texSampler,screenPos).rg;
|
||||
bumpColor0 = 2.0f * xTextureNor.Sample(sampler_aniso_wrap,PSIn.tex - g_xMat_texMulAdd.ww).rg - 1.0f;
|
||||
bumpColor1 = 2.0f * xTextureNor.Sample(sampler_aniso_wrap,PSIn.tex + g_xMat_texMulAdd.zw).rg - 1.0f;
|
||||
bumpColor2 = xRippleMap.Sample(sampler_aniso_wrap,screenPos).rg;
|
||||
bumpColor= float3( bumpColor0+bumpColor1+bumpColor2,1 ) * g_xMat_refractionIndex;
|
||||
normal = normalize(mul(normalize(bumpColor), tangentFrame));
|
||||
//normal = (bumpColor.x * PSIn.tan) + (bumpColor.y * PSIn.bin) + (bumpColor.z * PSIn.nor);
|
||||
@@ -51,15 +51,15 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
float2 RefTex;
|
||||
RefTex.x = PSIn.ReflectionMapSamplingPos.x/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
|
||||
RefTex.y = -PSIn.ReflectionMapSamplingPos.y/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
|
||||
float4 reflectiveColor = xTextureRef.SampleLevel(mapSampler,RefTex+bumpColor.rg,0);
|
||||
float4 reflectiveColor = xTextureRef.SampleLevel(sampler_linear_mirror,RefTex+bumpColor.rg,0);
|
||||
|
||||
//reflectiveColor.rgb = lerp(skyColor, reflectiveColor.rgb, reflectiveColor.a);
|
||||
|
||||
//REFRACTION
|
||||
float2 perturbatedRefrTexCoords = screenPos.xy + bumpColor.rg;
|
||||
float depth = PSIn.pos2D.z;
|
||||
float refDepth = (xDepthMap.Sample(mapSampler, screenPos));
|
||||
float3 refractiveColor = xTextureRefrac.SampleLevel(mapSampler, perturbatedRefrTexCoords, 0).rgb;
|
||||
float refDepth = (xDepthMap.Sample(sampler_linear_mirror, screenPos));
|
||||
float3 refractiveColor = xTextureRefrac.SampleLevel(sampler_linear_mirror, perturbatedRefrTexCoords, 0).rgb;
|
||||
float eyeDot = dot(normal, eyevector);
|
||||
float mod = saturate(0.05*(refDepth-depth));
|
||||
float3 dullColor = lerp(refractiveColor, g_xMat_diffuseColor.rgb, saturate(eyeDot));
|
||||
@@ -83,7 +83,7 @@ float4 main( PixelInputType PSIn) : SV_TARGET
|
||||
|
||||
//SPECULAR
|
||||
if(g_xMat_hasSpe){
|
||||
spec = xTextureSpe.Sample(texSampler, PSIn.tex);
|
||||
spec = xTextureSpe.Sample(sampler_aniso_wrap, PSIn.tex);
|
||||
}
|
||||
/*float3 reflectionVector = reflect(xSun, normal);
|
||||
float specR = dot(normalize(reflectionVector), eyevector);
|
||||
|
||||
@@ -11,7 +11,6 @@ VertexShader wiFont::vertexShader;
|
||||
PixelShader wiFont::pixelShader;
|
||||
BlendState wiFont::blendState;
|
||||
BufferResource wiFont::constantBuffer;
|
||||
Sampler wiFont::sampleState;
|
||||
RasterizerState wiFont::rasterizerState;
|
||||
DepthStencilState wiFont::depthStencilState;
|
||||
vector<wiFont::Vertex> wiFont::vertexList;
|
||||
@@ -39,32 +38,12 @@ void wiFont::Initialize()
|
||||
pixelShader=NULL;
|
||||
blendState=NULL;
|
||||
constantBuffer=NULL;
|
||||
sampleState=NULL;
|
||||
rasterizerState=NULL;
|
||||
depthStencilState=NULL;
|
||||
}
|
||||
|
||||
void wiFont::SetUpStates()
|
||||
{
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
wiRenderer::graphicsDevice->CreateSamplerState(&samplerDesc, &sampleState);
|
||||
|
||||
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC rs;
|
||||
rs.FillMode=D3D11_FILL_SOLID;
|
||||
rs.CullMode=D3D11_CULL_BACK;
|
||||
@@ -173,7 +152,6 @@ void wiFont::CleanUpStatic()
|
||||
if(pixelShader) pixelShader->Release(); pixelShader=NULL;
|
||||
if(vertexLayout) vertexLayout->Release(); vertexLayout=NULL;
|
||||
if(constantBuffer) constantBuffer->Release(); constantBuffer=NULL;
|
||||
if(sampleState) sampleState->Release(); sampleState=NULL;
|
||||
if(rasterizerState) rasterizerState->Release(); rasterizerState=NULL;
|
||||
if(blendState) blendState->Release(); blendState=NULL;
|
||||
if(depthStencilState) depthStencilState->Release(); depthStencilState=NULL;
|
||||
@@ -311,7 +289,6 @@ void wiFont::Draw(DeviceContext context){
|
||||
wiRenderer::BindIndexBuffer(indexBuffer,context);
|
||||
|
||||
wiRenderer::BindTexturePS(fontStyles[style].texture,0,context);
|
||||
wiRenderer::BindSamplerPS(sampleState,0,context);
|
||||
wiRenderer::DrawIndexed(text.length()*6,context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ protected:
|
||||
static PixelShader pixelShader;
|
||||
static BlendState blendState;
|
||||
static BufferResource constantBuffer;
|
||||
static Sampler sampleState;
|
||||
static RasterizerState rasterizerState;
|
||||
static DepthStencilState depthStencilState;
|
||||
|
||||
|
||||
+20
-19
@@ -4,6 +4,7 @@
|
||||
#include "wiImageEffects.h"
|
||||
#include "wiLoader.h"
|
||||
#include "wiHelper.h"
|
||||
#include "SamplerMapping.h"
|
||||
|
||||
#pragma region STATICS
|
||||
BlendState wiImage::blendState, wiImage::blendStateAdd, wiImage::blendStateNoBlend, wiImage::blendStateAvg;
|
||||
@@ -401,28 +402,28 @@ void wiImage::Draw(TextureView texture, const wiImageEffects& effects,DeviceCont
|
||||
wiRenderer::BindBlendState(blendStateAvg,context);
|
||||
|
||||
if(effects.quality==QUALITY_NEAREST){
|
||||
if(effects.sampleFlag==SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssMirrorPoi,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssWrapPoi,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssClampPoi,0,context);
|
||||
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_MIRROR], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_WRAP], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_POINT_CLAMP], SSLOT_ONDEMAND0, context);
|
||||
}
|
||||
else if(effects.quality==QUALITY_BILINEAR){
|
||||
if(effects.sampleFlag==SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssMirrorLin,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssWrapLin,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssClampLin,0,context);
|
||||
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_MIRROR], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_WRAP], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_LINEAR_CLAMP], SSLOT_ONDEMAND0, context);
|
||||
}
|
||||
else if(effects.quality==QUALITY_ANISOTROPIC){
|
||||
if(effects.sampleFlag==SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssMirrorAni,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssWrapAni,0,context);
|
||||
else if(effects.sampleFlag==SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssClampAni,0,context);
|
||||
if (effects.sampleFlag == SAMPLEMODE_MIRROR)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_MIRROR], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_WRAP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_WRAP], SSLOT_ONDEMAND0, context);
|
||||
else if (effects.sampleFlag == SAMPLEMODE_CLAMP)
|
||||
wiRenderer::BindSamplerPS(wiRenderer::samplers[SSLOT_ANISO_CLAMP], SSLOT_ONDEMAND0, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -451,7 +452,7 @@ void wiImage::DrawDeferred(TextureView texture
|
||||
wiRenderer::BindTexturePS(ao,8,context);
|
||||
|
||||
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssClampLin,0,context);
|
||||
//wiRenderer::BindSamplerPS(wiRenderer::ssClampLin,0,context);
|
||||
|
||||
wiRenderer::BindBlendState(blendStateNoBlend,context);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ PixelShader wiLensFlare::pixelShader;
|
||||
GeometryShader wiLensFlare::geometryShader;
|
||||
VertexShader wiLensFlare::vertexShader;
|
||||
VertexLayout wiLensFlare::inputLayout;
|
||||
Sampler wiLensFlare::samplerState;
|
||||
RasterizerState wiLensFlare::rasterizerState;
|
||||
DepthStencilState wiLensFlare::depthStencilState;
|
||||
BlendState wiLensFlare::blendState;
|
||||
@@ -26,7 +25,6 @@ void wiLensFlare::CleanUp(){
|
||||
|
||||
if(constantBuffer) constantBuffer->Release(); constantBuffer = NULL;
|
||||
|
||||
if(samplerState) samplerState->Release(); samplerState = NULL;
|
||||
if(rasterizerState) rasterizerState->Release(); rasterizerState = NULL;
|
||||
if(blendState) blendState->Release(); blendState = NULL;
|
||||
if(depthStencilState) depthStencilState->Release(); depthStencilState = NULL;
|
||||
@@ -56,9 +54,6 @@ void wiLensFlare::Draw(TextureView depthMap, DeviceContext context, const XMVECT
|
||||
|
||||
wiRenderer::BindTextureGS(depthMap,0,context);
|
||||
|
||||
wiRenderer::BindSamplerPS(wiRenderer::ssClampLin,0,context);
|
||||
wiRenderer::BindSamplerGS(samplerState,0,context);
|
||||
|
||||
int i=0;
|
||||
for(TextureView x : rims){
|
||||
if(x!=nullptr){
|
||||
@@ -108,26 +103,6 @@ void wiLensFlare::SetUpCB()
|
||||
}
|
||||
void wiLensFlare::SetUpStates()
|
||||
{
|
||||
D3D11_SAMPLER_DESC samplerDesc;
|
||||
ZeroMemory( &samplerDesc, sizeof(D3D11_SAMPLER_DESC) );
|
||||
samplerDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
wiRenderer::graphicsDevice->CreateSamplerState(&samplerDesc, &samplerState);
|
||||
|
||||
|
||||
|
||||
|
||||
D3D11_RASTERIZER_DESC rs;
|
||||
rs.FillMode=D3D11_FILL_SOLID;
|
||||
rs.CullMode=D3D11_CULL_NONE;
|
||||
|
||||
@@ -11,7 +11,6 @@ private:
|
||||
static GeometryShader geometryShader;
|
||||
static VertexShader vertexShader;
|
||||
static VertexLayout inputLayout;
|
||||
static Sampler samplerState;
|
||||
static RasterizerState rasterizerState;
|
||||
static DepthStencilState depthStencilState;
|
||||
static BlendState blendState;
|
||||
|
||||
+43
-224
@@ -33,8 +33,7 @@ bool wiRenderer::DX11 = false,wiRenderer::VSYNC=true,wiRenderer::DEFERREDCONTEXT
|
||||
DeviceContext wiRenderer::deferredContexts[];
|
||||
CommandList wiRenderer::commandLists[];
|
||||
mutex wiRenderer::graphicsMutex;
|
||||
Sampler wiRenderer::ssClampLin,wiRenderer::ssClampPoi,wiRenderer::ssMirrorLin,wiRenderer::ssMirrorPoi,wiRenderer::ssWrapLin,wiRenderer::ssWrapPoi
|
||||
,wiRenderer::ssClampAni,wiRenderer::ssWrapAni,wiRenderer::ssMirrorAni,wiRenderer::ssComp;
|
||||
Sampler wiRenderer::samplers[SSLOT_COUNT_PERSISTENT];
|
||||
|
||||
map<DeviceContext,long> wiRenderer::drawCalls;
|
||||
BufferResource wiRenderer::constantBuffers[CBTYPE_LAST];
|
||||
@@ -53,8 +52,6 @@ bool wiRenderer::HAIRPARTICLEENABLED=true,wiRenderer::EMITTERSENABLED=true;
|
||||
bool wiRenderer::wireRender = false, wiRenderer::debugSpheres = false, wiRenderer::debugBoneLines = false, wiRenderer::debugBoxes = false;
|
||||
BlendState wiRenderer::blendState, wiRenderer::blendStateTransparent, wiRenderer::blendStateAdd;
|
||||
|
||||
Sampler wiRenderer::texSampler, wiRenderer::mapSampler, wiRenderer::comparisonSampler, wiRenderer::mirSampler,wiRenderer::pointSampler;
|
||||
Sampler wiRenderer::skySampler;
|
||||
TextureView wiRenderer::enviroMap,wiRenderer::colorGrading;
|
||||
float wiRenderer::GameSpeed=1,wiRenderer::overrideGameSpeed=1;
|
||||
int wiRenderer::visibleCount;
|
||||
@@ -338,12 +335,6 @@ void wiRenderer::CleanUp()
|
||||
|
||||
void wiRenderer::SetUpStaticComponents()
|
||||
{
|
||||
texSampler = NULL;
|
||||
mapSampler = NULL;
|
||||
comparisonSampler = NULL;
|
||||
mirSampler = NULL;
|
||||
|
||||
|
||||
for (int i = 0; i < CBTYPE_LAST; ++i)
|
||||
{
|
||||
SafeInit(constantBuffers[i]);
|
||||
@@ -380,6 +371,10 @@ void wiRenderer::SetUpStaticComponents()
|
||||
{
|
||||
SafeInit(vertexLayouts[i]);
|
||||
}
|
||||
for (int i = 0; i < SSLOT_COUNT_PERSISTENT; ++i)
|
||||
{
|
||||
SafeInit(samplers[i]);
|
||||
}
|
||||
|
||||
//thread t1(LoadBasicShaders);
|
||||
//thread t2(LoadShadowShaders);
|
||||
@@ -460,21 +455,11 @@ void wiRenderer::SetUpStaticComponents()
|
||||
}
|
||||
void wiRenderer::CleanUpStatic()
|
||||
{
|
||||
|
||||
if(texSampler) texSampler->Release(); texSampler=NULL;
|
||||
if(mapSampler) mapSampler->Release(); mapSampler=NULL;
|
||||
if(pointSampler) pointSampler->Release(); pointSampler=NULL;
|
||||
if(comparisonSampler) comparisonSampler->Release(); comparisonSampler=NULL;
|
||||
if(mirSampler) mirSampler->Release(); mirSampler=NULL;
|
||||
|
||||
if(blendState) blendState->Release(); blendState=NULL;
|
||||
if(blendStateTransparent) blendStateTransparent->Release(); blendStateTransparent=NULL;
|
||||
if(blendStateAdd) blendStateAdd->Release(); blendStateAdd=NULL;
|
||||
|
||||
|
||||
if(skySampler) skySampler->Release(); skySampler=NULL;
|
||||
|
||||
|
||||
wiHairParticle::CleanUpStatic();
|
||||
wiEmittedParticle::CleanUpStatic();
|
||||
Cube::CleanUpStatic();
|
||||
@@ -517,6 +502,10 @@ void wiRenderer::CleanUpStatic()
|
||||
{
|
||||
SafeRelease(vertexLayouts[i]);
|
||||
}
|
||||
for (int i = 0; i < SSLOT_COUNT_PERSISTENT; ++i)
|
||||
{
|
||||
SafeRelease(samplers[i]);
|
||||
}
|
||||
|
||||
if (physicsEngine) physicsEngine->CleanUp();
|
||||
}
|
||||
@@ -1027,175 +1016,56 @@ void wiRenderer::SetUpStates()
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssMirrorLin);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_LINEAR_MIRROR]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_LINEAR_CLAMP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_LINEAR_WRAP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssMirrorPoi);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssWrapLin);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_POINT_MIRROR]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssWrapPoi);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_POINT_WRAP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssClampLin);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssClampPoi);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_POINT_CLAMP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 4;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssClampAni);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_ANISO_CLAMP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 4;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssWrapAni);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_ANISO_WRAP]);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 4;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssMirrorAni);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &ssComp);
|
||||
|
||||
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_ANISOTROPIC;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &texSampler);
|
||||
|
||||
ZeroMemory( &samplerDesc, sizeof(D3D11_SAMPLER_DESC) );
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &mapSampler);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_ANISO_MIRROR]);
|
||||
|
||||
ZeroMemory( &samplerDesc, sizeof(D3D11_SAMPLER_DESC) );
|
||||
samplerDesc.Filter = D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
|
||||
@@ -1205,59 +1075,21 @@ void wiRenderer::SetUpStates()
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &comparisonSampler);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_MIRROR;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 16;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &mirSampler);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &pointSampler);
|
||||
|
||||
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
|
||||
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
samplerDesc.MipLODBias = 0.0f;
|
||||
samplerDesc.MaxAnisotropy = 0;
|
||||
samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
||||
samplerDesc.BorderColor[0] = 0;
|
||||
samplerDesc.BorderColor[1] = 0;
|
||||
samplerDesc.BorderColor[2] = 0;
|
||||
samplerDesc.BorderColor[3] = 0;
|
||||
samplerDesc.MinLOD = 0;
|
||||
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &skySampler);
|
||||
graphicsDevice->CreateSamplerState(&samplerDesc, &samplers[SSLOT_CMP_DEPTH]);
|
||||
|
||||
Lock();
|
||||
{
|
||||
for (int i = 0; i < SSLOT_COUNT_PERSISTENT; ++i)
|
||||
{
|
||||
int slot = i + SSLOT_COUNT_ONDEMAND;
|
||||
BindSamplerPS(samplers[i], slot, immediateContext);
|
||||
BindSamplerVS(samplers[i], slot, immediateContext);
|
||||
BindSamplerGS(samplers[i], slot, immediateContext);
|
||||
BindSamplerDS(samplers[i], slot, immediateContext);
|
||||
BindSamplerHS(samplers[i], slot, immediateContext);
|
||||
}
|
||||
}
|
||||
Unlock();
|
||||
|
||||
D3D11_RASTERIZER_DESC rs;
|
||||
rs.FillMode=D3D11_FILL_SOLID;
|
||||
@@ -1284,6 +1116,7 @@ void wiRenderer::SetUpStates()
|
||||
rs.MultisampleEnable=false;
|
||||
rs.AntialiasedLineEnable=false;
|
||||
graphicsDevice->CreateRasterizerState(&rs,&rasterizers[RSTYPE_SHADOW]);
|
||||
|
||||
rs.FillMode=D3D11_FILL_SOLID;
|
||||
rs.CullMode=D3D11_CULL_NONE;
|
||||
rs.FrontCounterClockwise=true;
|
||||
@@ -1307,7 +1140,6 @@ void wiRenderer::SetUpStates()
|
||||
rs.MultisampleEnable=false;
|
||||
rs.AntialiasedLineEnable=false;
|
||||
graphicsDevice->CreateRasterizerState(&rs,&rasterizers[RSTYPE_WIRE]);
|
||||
|
||||
|
||||
rs.FillMode=D3D11_FILL_SOLID;
|
||||
rs.CullMode=D3D11_CULL_NONE;
|
||||
@@ -1939,7 +1771,6 @@ void wiRenderer::DrawTrails(DeviceContext context, TextureView refracRes){
|
||||
BindVS(vertexShaders[VSTYPE_TRAIL],context);
|
||||
|
||||
BindTexturePS(refracRes,0,context);
|
||||
BindSamplerPS(mirSampler,0,context);
|
||||
|
||||
for (Object* o : objectsWithTrails)
|
||||
{
|
||||
@@ -2064,8 +1895,6 @@ void wiRenderer::DrawLights(Camera* camera, DeviceContext context
|
||||
BindTexturePS(depth,0,context);
|
||||
BindTexturePS(normal,1,context);
|
||||
BindTexturePS(material,2,context);
|
||||
BindSamplerPS(pointSampler,0,context);
|
||||
BindSamplerPS(comparisonSampler,1,context);
|
||||
|
||||
|
||||
BindBlendState(blendStateAdd,context);
|
||||
@@ -2329,7 +2158,6 @@ void wiRenderer::DrawForShadowMap(DeviceContext context)
|
||||
BindBlendState(blendState, context);
|
||||
|
||||
BindPS(pixelShaders[PSTYPE_SHADOW], context);
|
||||
BindSamplerPS(texSampler, 0, context);
|
||||
|
||||
BindVS(vertexShaders[VSTYPE_SHADOW], context);
|
||||
|
||||
@@ -2753,11 +2581,6 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContex
|
||||
else
|
||||
return;
|
||||
|
||||
if(DX11Eff && tessF)
|
||||
BindSamplerDS(texSampler,0,context);
|
||||
BindSamplerPS(texSampler,0,context);
|
||||
BindSamplerPS(mapSampler,1,context);
|
||||
|
||||
|
||||
BindBlendState(blendState,context);
|
||||
|
||||
@@ -2877,8 +2700,6 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, TextureView refracRes, Tex
|
||||
BindVertexLayout(vertexLayouts[VLTYPE_EFFECT],context);
|
||||
BindVS(vertexShaders[VSTYPE_EFFECT10],context);
|
||||
|
||||
BindSamplerPS(texSampler,0,context);
|
||||
BindSamplerPS(mapSampler,1,context);
|
||||
|
||||
if (!wireRender)
|
||||
{
|
||||
@@ -3014,7 +2835,6 @@ void wiRenderer::DrawSky(DeviceContext context, bool isReflection)
|
||||
}
|
||||
|
||||
BindTexturePS(enviroMap,0,context);
|
||||
BindSamplerPS(skySampler,0,context);
|
||||
|
||||
BindVertexBuffer(nullptr,0,0,context);
|
||||
BindVertexLayout(nullptr, context);
|
||||
@@ -3050,7 +2870,6 @@ void wiRenderer::DrawDecals(Camera* camera, DeviceContext context, TextureView d
|
||||
}
|
||||
|
||||
BindTexturePS(depth, 1, context);
|
||||
BindSamplerPS(ssClampAni, 0, context);
|
||||
BindVS(vertexShaders[VSTYPE_DECAL], context);
|
||||
BindPS(pixelShaders[PSTYPE_DECAL], context);
|
||||
BindRasterizerState(rasterizers[RSTYPE_BACK], context);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "wiEnums.h"
|
||||
#include "wiGraphicsAPI.h"
|
||||
#include "skinningDEF.h"
|
||||
#include "SamplerMapping.h"
|
||||
|
||||
struct Transform;
|
||||
struct Vertex;
|
||||
@@ -80,8 +81,7 @@ public:
|
||||
inline static void Lock(){ graphicsMutex.lock(); }
|
||||
inline static void Unlock(){ graphicsMutex.unlock(); }
|
||||
|
||||
static Sampler ssClampLin,ssClampPoi,ssMirrorLin,ssMirrorPoi,ssWrapLin,ssWrapPoi
|
||||
,ssClampAni,ssWrapAni,ssMirrorAni,ssComp;
|
||||
static Sampler samplers[SSLOT_COUNT_PERSISTENT];
|
||||
|
||||
|
||||
static int SCREENWIDTH,SCREENHEIGHT;
|
||||
@@ -294,12 +294,10 @@ protected:
|
||||
|
||||
|
||||
|
||||
static bool wireRender, debugSpheres, debugBoneLines, debugBoxes;
|
||||
static bool wireRender, debugSpheres, debugBoneLines, debugBoxes;
|
||||
|
||||
|
||||
static BlendState blendState, blendStateTransparent, blendStateAdd;
|
||||
static Sampler texSampler, mapSampler, comparisonSampler, mirSampler, pointSampler;
|
||||
static Sampler skySampler;
|
||||
static BlendState blendState, blendStateTransparent, blendStateAdd;
|
||||
static TextureView enviroMap,colorGrading;
|
||||
static void LoadBuffers();
|
||||
static void LoadBasicShaders();
|
||||
|
||||
Reference in New Issue
Block a user