I initially wanted to use light map tilling to display, but most of the tilling values are between 0.1-0.01. The displayed colors are almost the same, but the density displayed by the checkerboard is quite different. Is there any way to solve it? I think Probably a problem with the shader algorithm
Your post was suck in the moderation queue for some time but I did approve it, even though I can understand why it wasn’t approved for so long. Your title and your description doesn’t really make much sense. It may be a language barrier / translation issue. However you should be way more specific what exactly you’re doing. “UV area”, “express density in color”, “use light map tiling to display” those are very vague or doesn’t really make sense.
You asked if there’s a way to solve it, but the actual issue or what specifically you try to do isn’t really clear. You think it’s a problem with your “shader” but you haven’t provided any reference code, example, article, whatever. How are we supposed to help you here?
So please, revise your question and be more specific, add some code, examples, maybe screenshots (don’t post screenshots of code, use code tags) and explain what your goal is.
This is my Code:
half4 albedo = tex2D(_MainTex, i.uv.xy);
half alpha = albedo.a;
half4 nomBaseData = tex2D(_NormTex, i.uv.xy);
half3 nomBase = SelfUnpackNormal(nomBaseData);
half3 nomWorld;
nomWorld.x = dot(i.tspace0, nomBase);
nomWorld.y = dot(i.tspace1, nomBase);
nomWorld.z = dot(i.tspace2, nomBase);
nomWorld = normalize(nomWorld);
fixed3 LightDir = normalize(_WorldSpaceLightPos0.xyz);
half diff = max(0, dot(nomWorld, LightDir));
float2 lightmapuv = i.uvLM * _LightmapScale;
// float test = i.uvLM.x;
// return test;
float2 m = lightmapuv * _Griddensity;
float m1 = step(0.5, frac(m.r)) * step(frac(m.g), 0.5);
float m2 = step(frac(m.r), 0.5) * step(0.5, frac(m.g));
m1 += m2;
m1 = m1 * 0.2 + 0.8;
//return m1;
float2 texSize = float2(512.0f, 2048.0f);
float2 dxUv = ddx(lightmapuv);
float2 dyUv = ddy(lightmapuv);
float2 ddx_ = texSize * dxUv;
float2 ddy_ = texSize * dyUv;
float d = max(dot(ddx_, ddx_), dot(ddy_, ddy_));
float3 dxPosws = ddx(i.posWorld);
float3 dyPosWs = ddy(i.posWorld);
float d2 = max(dot(dxPosws, dxPosws), dot(dyPosWs, dyPosWs));
d = sqrt(d / d2);
d /= 128;
d = pow(d, 0.45);
float3 Color1 = float3(0.3, 1.0, 0.2);
float3 Color2 = float3(0.5, 0.02, 0.02);
float3 Color3 = float3(0, 0, 0.8);
float3 FinaCol = _Color2ed;
FinaCol = lerp(FinaCol, _Color1st, (saturate(d - 0.3)) * 1.45);
FinaCol = lerp(_Color3rd, FinaCol, saturate((d - 0.2) * 10));
FinaCol *= (diff * 0.5 + 0.5) * m1 * 2;
clip(alpha - 0.5);
return float4(FinaCol, 1);
To recap, the two pictures I posted are what I want to achieve, so that the density of the checkerboard can be mapped into color, but no matter how I write the code, I can’t seem to achieve it.
