shade stains
This commit is contained in:
parent
f0ddf19133
commit
6e167ce499
@ -2019,7 +2019,7 @@ void V_TickForever(WaveLaneCtx *lane)
|
||||
|
||||
|
||||
|
||||
if (0)
|
||||
// if (0)
|
||||
{
|
||||
for (P_Ent *bullet = P_FirstEnt(local_frame); !P_IsEntNil(bullet); bullet = P_NextEnt(bullet))
|
||||
{
|
||||
|
||||
@ -75,6 +75,46 @@ ComputeShader(V_ClearParticlesCS, 64)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Quads
|
||||
|
||||
//////////////////////////////
|
||||
//- Vertex shader
|
||||
|
||||
VertexShader(V_QuadVS, V_QuadPSInput)
|
||||
{
|
||||
V_GpuParams params = G_Dereference<V_GpuParams>(V_ShaderConst_Params)[0];
|
||||
StructuredBuffer<V_Quad> quads = G_Dereference<V_Quad>(params.quads);
|
||||
|
||||
V_Quad quad = quads[SV_InstanceID];
|
||||
|
||||
Vec2 rect_uv = RectUvFromVertexId(SV_VertexID);
|
||||
// Vec2 tex_uv = lerp(quad.tex_uv0, quad.tex_uv1, rect_uv);
|
||||
// Vec2 screen_pos = lerp(quad.p0, quad.p1, rect_uv);
|
||||
Vec2 screen_pos = 0;
|
||||
|
||||
V_QuadPSInput result;
|
||||
result.sv_position = Vec4(NdcFromPos(screen_pos, params.screen_dims).xy, 0, 1);
|
||||
result.quad_idx = SV_InstanceID;
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- Pixel shader
|
||||
|
||||
PixelShader(V_QuadPS, V_QuadPSOutput, V_QuadPSInput input)
|
||||
{
|
||||
V_GpuParams params = G_Dereference<V_GpuParams>(V_ShaderConst_Params)[0];
|
||||
StructuredBuffer<V_Quad> quads = G_Dereference<V_Quad>(params.quads);
|
||||
V_Quad quad = quads[input.quad_idx];
|
||||
|
||||
Vec4 final_color = 0;
|
||||
|
||||
V_QuadPSOutput output;
|
||||
output.sv_target0 = final_color;
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Backdrop
|
||||
|
||||
@ -285,46 +325,6 @@ ComputeShader(V_ClearParticlesCS, 64)
|
||||
// }
|
||||
// }
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Quads
|
||||
|
||||
//////////////////////////////
|
||||
//- Vertex shader
|
||||
|
||||
VertexShader(V_QuadVS, V_QuadPSInput)
|
||||
{
|
||||
V_GpuParams params = G_Dereference<V_GpuParams>(V_ShaderConst_Params)[0];
|
||||
StructuredBuffer<V_Quad> quads = G_Dereference<V_Quad>(params.quads);
|
||||
|
||||
V_Quad quad = quads[SV_InstanceID];
|
||||
|
||||
Vec2 rect_uv = RectUvFromVertexId(SV_VertexID);
|
||||
// Vec2 tex_uv = lerp(quad.tex_uv0, quad.tex_uv1, rect_uv);
|
||||
// Vec2 screen_pos = lerp(quad.p0, quad.p1, rect_uv);
|
||||
Vec2 screen_pos = 0;
|
||||
|
||||
V_QuadPSInput result;
|
||||
result.sv_position = Vec4(NdcFromPos(screen_pos, params.screen_dims).xy, 0, 1);
|
||||
result.quad_idx = SV_InstanceID;
|
||||
return result;
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- Pixel shader
|
||||
|
||||
PixelShader(V_QuadPS, V_QuadPSOutput, V_QuadPSInput input)
|
||||
{
|
||||
V_GpuParams params = G_Dereference<V_GpuParams>(V_ShaderConst_Params)[0];
|
||||
StructuredBuffer<V_Quad> quads = G_Dereference<V_Quad>(params.quads);
|
||||
V_Quad quad = quads[input.quad_idx];
|
||||
|
||||
Vec4 final_color = 0;
|
||||
|
||||
V_QuadPSOutput output;
|
||||
output.sv_target0 = final_color;
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//~ Particle simulation
|
||||
|
||||
@ -484,6 +484,8 @@ ComputeShader2D(V_ShadeCS, 8, 8)
|
||||
RWTexture2D<Vec4> shade_tex = G_Dereference<Vec4>(params.shade_rw);
|
||||
Texture2D<Vec4> albedo_tex = G_Dereference<Vec4>(params.albedo_ro);
|
||||
Texture2D<P_TileKind> tiles = G_Dereference<P_TileKind>(params.tiles);
|
||||
RWTexture2D<Vec4> stains = G_Dereference<Vec4>(params.stains);
|
||||
RWTexture2D<f32> drynesses = G_Dereference<f32>(params.drynesses);
|
||||
SamplerState wrap_sampler = G_Dereference(params.pt_wrap_sampler);
|
||||
|
||||
Vec2 shade_pos = SV_DispatchThreadID + Vec2(0.5, 0.5);
|
||||
@ -571,10 +573,22 @@ ComputeShader2D(V_ShadeCS, 8, 8)
|
||||
}
|
||||
}
|
||||
|
||||
//- Albedo tex color
|
||||
Vec4 albedo_tex_color = albedo_tex.Load(Vec3(shade_pos, 0));
|
||||
|
||||
//- Stain color
|
||||
Vec4 stain_color = 0;
|
||||
{
|
||||
f32 dryness = drynesses.Load(cell_pos);
|
||||
stain_color = V_DryColor(stains.Load(cell_pos), dryness);
|
||||
stain_color.rgb *= 1.0 - (0.75 * tile_is_wall); // Darken wall stains
|
||||
}
|
||||
|
||||
//- Composite albedo
|
||||
albedo = BlendPremul(!tile_is_wall * tile_color, albedo); // Blend floor tile
|
||||
albedo = BlendPremul(albedo_tex.Load(Vec3(shade_pos, 0)), albedo);
|
||||
albedo = BlendPremul(albedo_tex_color, albedo);
|
||||
albedo = BlendPremul(tile_is_wall * tile_color, albedo); // Blend wall tile
|
||||
albedo = BlendPremul(stain_color, albedo);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@ -710,6 +724,7 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
overlay_color = grid_color;
|
||||
}
|
||||
}
|
||||
|
||||
// Axis
|
||||
if (V_ShaderConst_GpuFlags & V_GpuFlag_DebugDraw)
|
||||
{
|
||||
@ -728,6 +743,7 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
overlay_color = y_axis_color;
|
||||
}
|
||||
}
|
||||
|
||||
// World bounds
|
||||
{
|
||||
const Vec4 bounds_color = LinearFromSrgb(Vec4(0.75, 0.75, 0, 1));
|
||||
@ -741,6 +757,7 @@ PixelShader(V_CompositePS, V_CompositePSOutput, V_CompositePSInput input)
|
||||
overlay_color = bounds_color;
|
||||
}
|
||||
}
|
||||
|
||||
// Premultiply
|
||||
overlay_color.rgb *= overlay_color.a;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user