diff options
| author | yum <yum.food.vr@gmail.com> | 2025-04-23 16:30:01 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-04-23 16:30:01 -0700 |
| commit | 7aae547b83c94ff3ecf62524809ecb21d6061d33 (patch) | |
| tree | 8ddb859cb4a8926e553d08d120406304ca355d3c | |
| parent | 4e8de4d6f93bce6d4951ad85fe4ae31b9e0cdedd (diff) | |
tweak how decal rotation works
| -rw-r--r-- | decals.cginc | 5 | ||||
| -rw-r--r-- | texture_utils.cginc | 4 | ||||
| -rw-r--r-- | yum_pbr.cginc | 9 |
3 files changed, 10 insertions, 8 deletions
diff --git a/decals.cginc b/decals.cginc index 60968af..bc49493 100644 --- a/decals.cginc +++ b/decals.cginc @@ -60,8 +60,9 @@ struct DecalParams { ); \
\
float2 raw_decal_uv = get_uv_by_channel(i, params.uv_channel); \
- float2 decal_uv = (raw_decal_uv * params.mainTex_ST.xy + params.mainTex_ST.zw); \
- decal_uv = mul(decal_rot, decal_uv); \
+ float2 decal_uv = raw_decal_uv; \
+ decal_uv = decal_uv * params.mainTex_ST.xy + params.mainTex_ST.zw; \
+ decal_uv = mul(decal_rot, decal_uv - 0.5) + 0.5; \
decal_uv = (params.tiling_mode == DECAL_TILING_MODE_CLAMP ? saturate(decal_uv) : decal_uv);
#define APPLY_DECAL_SEC01_SDF_ON(i, albedo, normal_tangent, metallic, smoothness, params) \
diff --git a/texture_utils.cginc b/texture_utils.cginc index 5909c72..9d7bf2f 100644 --- a/texture_utils.cginc +++ b/texture_utils.cginc @@ -24,7 +24,9 @@ float2 get_uv_by_channel(v2f i, uint which_channel) { } } -#define UV_SCOFF(i, tex_st, which_channel) get_uv_by_channel(i, round(which_channel)) * (tex_st).xy + (tex_st).zw +#define UV_SCOFF_IMPL(uv, tex_st) (uv) * (tex_st).xy + (tex_st).zw + +#define UV_SCOFF(i, tex_st, which_channel) UV_SCOFF_IMPL(get_uv_by_channel(i, round(which_channel)), tex_st) #endif // __TEXTURE_UTILS_INC diff --git a/yum_pbr.cginc b/yum_pbr.cginc index 662ee1c..8ecbe2a 100644 --- a/yum_pbr.cginc +++ b/yum_pbr.cginc @@ -47,7 +47,7 @@ YumPbr GetYumPbr(v2f i) { for (uint ii = 0; ii < _UV_Domain_Warping_Spatial_Octaves; ii++) { float2 noise_uv = warped_uv * frequency + time_offset; float2 offset_sample = _UV_Domain_Warping_Noise.SampleLevel(trilinear_repeat_s, noise_uv, 0).rg; - offset_sample = (offset_sample * 2.0 - 1.0); + offset_sample = (offset_sample * 2.0 - 1.0); warped_uv += offset_sample * amplitude; frequency *= lacunarity; amplitude *= persistence; @@ -78,16 +78,15 @@ YumPbr GetYumPbr(v2f i) { #endif float3 normal_tangent = UnpackScaleNormal( - tex2D(_BumpMap, UV_SCOFF(i, _BumpMap_ST, /*which_channel=*/0)), - _BumpScale); + tex2D(_BumpMap, UV_SCOFF_IMPL(raw_uv, _BumpMap_ST)), _BumpScale); #if defined(_DETAIL_MAPS) float detail_mask = _DetailMask.SampleLevel(point_repeat_s, i.uv01.xy, 0); float4 detail_albedo = tex2D(_DetailAlbedoMap, - UV_SCOFF(i, _DetailAlbedoMap_ST, /*which_channel=*/0)); + UV_SCOFF_IMPL(raw_uv, _DetailNormalMap_ST)); float3 detail_normal = UnpackScaleNormal( tex2D(_DetailNormalMap, - UV_SCOFF(i, _DetailNormalMap_ST, /*which_channel=*/0)), + UV_SCOFF_IMPL(raw_uv, _DetailNormalMap_ST)), _DetailNormalMapScale); result.albedo = lerp(result.albedo, result.albedo * detail_albedo, detail_mask); //result.albedo.a *= detail_albedo.a; |
