mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Revert world-space normal change and write paint shader
• Revert previous change to compute world normal in the surf function, was unnecessary for edge wear effect • Rewrite paint shader with new library • Allow for texture scaling and tiling in decals
This commit is contained in:
@ -1,17 +1,6 @@
|
||||
#ifndef DECALS_COMMON_INCLUDED
|
||||
#define DECALS_COMMON_INCLUDED
|
||||
|
||||
inline fixed3 OrientNormal(float3 normal, float4 tSpace0, float4 tSpace1, float4 tSpace2) {
|
||||
float3 WorldNormal;
|
||||
WorldNormal.x = dot(tSpace0.xyz, normal);
|
||||
WorldNormal.y = dot(tSpace1.xyz, normal);
|
||||
WorldNormal.z = dot(tSpace2.xyz, normal);
|
||||
WorldNormal = normalize(WorldNormal);
|
||||
return WorldNormal;
|
||||
}
|
||||
|
||||
#define DECAL_ORIENT_NORMAL(normal, IN) OrientNormal(normal, IN.tSpace0, IN.tSpace1, IN.tSpace2)
|
||||
|
||||
struct DecalSurfaceInput
|
||||
{
|
||||
float4 uv_decal;
|
||||
@ -21,10 +10,6 @@ struct DecalSurfaceInput
|
||||
float3 normal;
|
||||
float3 viewDir;
|
||||
float3 worldPosition;
|
||||
|
||||
float4 tSpace0;
|
||||
float4 tSpace1;
|
||||
float4 tSpace2;
|
||||
};
|
||||
|
||||
struct appdata_decal
|
||||
@ -33,6 +18,7 @@ struct appdata_decal
|
||||
float3 normal : NORMAL;
|
||||
#ifdef DECAL_BASE_NORMAL
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 tangent : TANGENT;
|
||||
#endif //DECAL_BASE_NORMAL
|
||||
};
|
||||
|
||||
@ -157,9 +143,6 @@ fixed4 frag_forward(v2f IN) : SV_Target
|
||||
i.normal = IN.normal;
|
||||
i.viewDir = viewDir;
|
||||
i.worldPosition = worldPosition;
|
||||
i.tSpace0 = IN.tSpace0;
|
||||
i.tSpace1 = IN.tSpace1;
|
||||
i.tSpace2 = IN.tSpace2;
|
||||
|
||||
// initialize surface output
|
||||
o.Albedo = 0.0;
|
||||
@ -175,6 +158,15 @@ fixed4 frag_forward(v2f IN) : SV_Target
|
||||
// compute lighting & shadowing factor
|
||||
UNITY_LIGHT_ATTENUATION(atten, IN, worldPosition)
|
||||
|
||||
// compute world normal
|
||||
float3 WorldNormal;
|
||||
WorldNormal.x = dot(_unity_tbn_0, o.Normal);
|
||||
WorldNormal.y = dot(_unity_tbn_1, o.Normal);
|
||||
WorldNormal.z = dot(_unity_tbn_2, o.Normal);
|
||||
WorldNormal = normalize(WorldNormal);
|
||||
o.Normal = WorldNormal;
|
||||
|
||||
|
||||
//KSP lighting function
|
||||
c += LightingBlinnPhongSmooth(o, lightDir, viewDir, atten);
|
||||
|
||||
|
Reference in New Issue
Block a user