hologram shader improvement
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#define TEXSLOT_FONTATLAS 22
|
||||
|
||||
#define TEXSLOT_BLUENOISE 23
|
||||
#define TEXSLOT_RANDOM64X64 24
|
||||
|
||||
// Ondemand textures are 2d textures and declared in shader globals, these can be used independently in any shader:
|
||||
#define TEXSLOT_ONDEMAND0 30
|
||||
|
||||
@@ -23,6 +23,7 @@ TEXTURECUBEARRAY(texture_shadowarray_transparent_cube, float4, TEXSLOT_SHADOWARR
|
||||
TEXTURE3D(texture_voxelradiance, float4, TEXSLOT_VOXELRADIANCE);
|
||||
TEXTURE2D(texture_sheenlut, float, TEXSLOT_SHEENLUT);
|
||||
TEXTURE2D(texture_bluenoise, float4, TEXSLOT_BLUENOISE);
|
||||
TEXTURE2D(texture_random64x64, float4, TEXSLOT_RANDOM64X64);
|
||||
STRUCTUREDBUFFER(EntityArray, ShaderEntity, SBSLOT_ENTITYARRAY);
|
||||
STRUCTUREDBUFFER(MatrixArray, float4x4, SBSLOT_MATRIXARRAY);
|
||||
|
||||
|
||||
@@ -19,18 +19,38 @@ float4 main(PixelInput input) : SV_TARGET
|
||||
}
|
||||
color *= input.color;
|
||||
|
||||
float4 emissiveColor = GetMaterial().emissiveColor;
|
||||
[branch]
|
||||
if (emissiveColor.a > 0 && GetMaterial().uvset_emissiveMap >= 0)
|
||||
{
|
||||
const float2 UV_emissiveMap = GetMaterial().uvset_emissiveMap == 0 ? input.uvsets.xy : input.uvsets.zw;
|
||||
float4 emissiveMap = texture_emissivemap.Sample(sampler_objectshader, UV_emissiveMap);
|
||||
emissiveMap.rgb = DEGAMMA(emissiveMap.rgb);
|
||||
emissiveColor *= emissiveMap;
|
||||
}
|
||||
color.rgb += emissiveColor.rgb * emissiveColor.a;
|
||||
|
||||
float time = g_xFrame_Time;
|
||||
float2 uv = input.pos.xy * g_xFrame_InternalResolution_rcp;
|
||||
uv.y *= g_xFrame_InternalResolution.y * g_xFrame_InternalResolution_rcp.x;
|
||||
|
||||
float noise = sin(dot(input.pos.xy + time, float2(12.9898, 78.233)));
|
||||
noise = saturate(frac(noise * 43758.5453));
|
||||
color *= noise;
|
||||
// wave:
|
||||
color.a *= sin(input.pos3D.y * 30 + time * 10) * 0.5 + 0.5;
|
||||
|
||||
color.a *= sin(input.pos3D.y * 25 + time * 10) * 0.5f + 0.5f;
|
||||
// rim:
|
||||
color *= lerp(0.3, 6, pow(1 - saturate(dot(normalize(input.nor), normalize(g_xCamera_CamPos - input.pos3D))), 2));
|
||||
|
||||
color *= lerp(0.5, 4, pow(1 - saturate(dot(normalize(input.nor), normalize(g_xCamera_CamPos - input.pos3D))), 2));
|
||||
|
||||
color.a += 0.5;
|
||||
// keep some base color
|
||||
color.a += 0.2;
|
||||
color.a = saturate(color.a);
|
||||
|
||||
// grain:
|
||||
float noise = 1;
|
||||
noise *= texture_random64x64.SampleLevel(sampler_linear_wrap, uv * 4 + time, 0).r * 2 - 1;
|
||||
noise *= texture_random64x64.SampleLevel(sampler_linear_wrap, uv * float2(-2, 3) + time, 0).g * 2 - 1;
|
||||
noise = noise * 0.5 + 0.5;
|
||||
|
||||
color *= noise;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,7 @@ enum DSSTYPES
|
||||
DSSTYPE_ENVMAP,
|
||||
DSSTYPE_CAPTUREIMPOSTOR,
|
||||
DSSTYPE_WRITEONLY,
|
||||
DSSTYPE_HOLOGRAM,
|
||||
DSSTYPE_COUNT
|
||||
};
|
||||
// blend states
|
||||
|
||||
@@ -1524,7 +1524,7 @@ void LoadShaders()
|
||||
|
||||
desc.bs = &blendStates[BSTYPE_ADDITIVE];
|
||||
desc.rs = &rasterizers[RSTYPE_FRONT];
|
||||
desc.dss = &depthStencils[DSSTYPE_DEFAULT];
|
||||
desc.dss = &depthStencils[DSSTYPE_HOLOGRAM];
|
||||
desc.pt = TRIANGLELIST;
|
||||
|
||||
PipelineState pso;
|
||||
@@ -2245,6 +2245,9 @@ void SetUpStates()
|
||||
dsd.BackFace.StencilDepthFailOp = STENCIL_OP_KEEP;
|
||||
depthStencils[DSSTYPE_DEFAULT] = dsd;
|
||||
|
||||
dsd.DepthWriteMask = DEPTH_WRITE_MASK_ZERO;
|
||||
depthStencils[DSSTYPE_HOLOGRAM] = dsd;
|
||||
|
||||
dsd.DepthEnable = true;
|
||||
dsd.DepthWriteMask = DEPTH_WRITE_MASK_ALL;
|
||||
dsd.DepthFunc = COMPARISON_GREATER;
|
||||
@@ -2287,8 +2290,6 @@ void SetUpStates()
|
||||
depthStencils[DSSTYPE_WRITEONLY] = dsd;
|
||||
|
||||
|
||||
|
||||
|
||||
BlendState bd;
|
||||
bd.RenderTarget[0].BlendEnable = false;
|
||||
bd.RenderTarget[0].SrcBlend = BLEND_SRC_ALPHA;
|
||||
@@ -7812,6 +7813,7 @@ void BindCommonResources(CommandList cmd)
|
||||
|
||||
BindConstantBuffers(stage, cmd);
|
||||
|
||||
device->BindResource(stage, wiTextureHelper::getRandom64x64(), TEXSLOT_RANDOM64X64, cmd);
|
||||
device->BindResource(stage, wiTextureHelper::getBlueNoise(), TEXSLOT_BLUENOISE, cmd);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 56;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 17;
|
||||
const int revision = 18;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user