decal texture tiling support

This commit is contained in:
Turánszki János
2023-03-08 18:06:31 +01:00
parent 8477fee1f5
commit 6bb2a8519b
9 changed files with 15 additions and 5 deletions
@@ -776,6 +776,8 @@ Describes an orientation in 3D space.
- SetEngineStencilRef(int value)
- SetUserStencilRef(int value)
- GetStencilRef() : int result
- SetTexMulAdd(Vector vector)
- GetTexMulAdd() : Vector
- SetTexture(TextureSlot slot, string texturefile)
- SetTexture(TextureSlot slot, Texture texture)
- SetTextureUVSet(TextureSlot slot, int uvset)
+1 -1
View File
@@ -56,7 +56,7 @@ void DecalWindow::Create(EditorComponent* _editor)
y += step;
infoLabel.Create("");
infoLabel.SetText("Set decal properties in the Material component. Decals support the following material properties:\n - Base color\n - Base color texture\n - Emissive strength\n - Normalmap texture\n - Normalmap strength\n - Surfacemap texture");
infoLabel.SetText("Set decal properties in the Material component. Decals support the following material properties:\n - Base color\n - Base color texture\n - Emissive strength\n - Normalmap texture\n - Normalmap strength\n - Surfacemap texture\n - Texture tiling (TexMulAdd)");
infoLabel.SetSize(XMFLOAT2(300, 100));
infoLabel.SetPos(XMFLOAT2(10, y));
infoLabel.SetColor(wi::Color::Transparent());
+4 -2
View File
@@ -521,10 +521,11 @@ inline void ForwardDecals(inout Surface surface, inout float4 surfaceMap)
int decalSurfacemap = asint(decalProjection[3][3]);
decalProjection[3] = float4(0, 0, 0, 1);
const float3 clipSpacePos = mul(decalProjection, float4(surface.P, 1)).xyz;
const float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
[branch]
if (is_saturated(uvw))
{
uvw.xy = mad(uvw.xy, decal.shadowAtlasMulAdd.xy, decal.shadowAtlasMulAdd.zw);
// mipmapping needs to be performed by hand:
const float2 decalDX = mul(P_dx, (float3x3)decalProjection).xy;
const float2 decalDY = mul(P_dy, (float3x3)decalProjection).xy;
@@ -850,10 +851,11 @@ inline void TiledDecals(inout Surface surface, uint flatTileIndex, inout float4
int decalSurfacemap = asint(decalProjection[3][3]);
decalProjection[3] = float4(0, 0, 0, 1);
const float3 clipSpacePos = mul(decalProjection, float4(surface.P, 1)).xyz;
const float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
[branch]
if (is_saturated(uvw))
{
uvw.xy = mad(uvw.xy, decal.shadowAtlasMulAdd.xy, decal.shadowAtlasMulAdd.zw);
// mipmapping needs to be performed by hand:
const float2 decalDX = mul(P_dx, (float3x3)decalProjection).xy;
const float2 decalDY = mul(P_dy, (float3x3)decalProjection).xy;
+2 -1
View File
@@ -523,10 +523,11 @@ struct Surface
int decalSurfacemap = asint(decalProjection[3][3]);
decalProjection[3] = float4(0, 0, 0, 1);
const float3 clipSpacePos = mul(decalProjection, float4(P, 1)).xyz;
const float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
float3 uvw = clipspace_to_uv(clipSpacePos.xyz);
[branch]
if (is_saturated(uvw))
{
uvw.xy = mad(uvw.xy, decal.shadowAtlasMulAdd.xy, decal.shadowAtlasMulAdd.zw);
// mipmapping needs to be performed by hand:
const float2 decalDX = mul(P_dx, (float3x3)decalProjection).xy;
const float2 decalDY = mul(P_dy, (float3x3)decalProjection).xy;
+1
View File
@@ -3768,6 +3768,7 @@ void UpdateRenderData(
shaderentity.SetRange(decal.range);
float emissive_mul = 1 + decal.emissive;
shaderentity.SetColor(float4(decal.color.x * emissive_mul, decal.color.y * emissive_mul, decal.color.z * emissive_mul, decal.color.w));
shaderentity.shadowAtlasMulAdd = decal.texMulAdd;
shaderentity.SetIndices(matrixCounter, 0);
shadermatrix = XMMatrixInverse(nullptr, XMLoadFloat4x4(&decal.world));
+1
View File
@@ -3801,6 +3801,7 @@ namespace wi::scene
decal.normal = material.textures[MaterialComponent::NORMALMAP].resource;
decal.surfacemap = material.textures[MaterialComponent::SURFACEMAP].resource;
decal.normal_strength = material.normalMapStrength;
decal.texMulAdd = material.texMulAdd;
}
}
void Scene::RunProbeUpdateSystem(wi::jobsystem::context& ctx)
+2
View File
@@ -3507,6 +3507,8 @@ Luna<MaterialComponent_BindLua>::FunctionType MaterialComponent_BindLua::methods
lunamethod(MaterialComponent_BindLua, SetEngineStencilRef),
lunamethod(MaterialComponent_BindLua, SetUserStencilRef),
lunamethod(MaterialComponent_BindLua, GetStencilRef),
lunamethod(MaterialComponent_BindLua, SetTexMulAdd),
lunamethod(MaterialComponent_BindLua, GetTexMulAdd),
lunamethod(MaterialComponent_BindLua, SetTexture),
lunamethod(MaterialComponent_BindLua, SetTextureUVSet),
+1
View File
@@ -1065,6 +1065,7 @@ namespace wi::scene
XMFLOAT3 position;
float range;
XMFLOAT4X4 world;
XMFLOAT4 texMulAdd;
wi::Resource texture;
wi::Resource normal;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 175;
const int revision = 176;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);