Skip to content

Commit

Permalink
Android shader fixes
Browse files Browse the repository at this point in the history
Change-Id: I7fda13990e8c43c4724f30bc588c65c58b681359
  • Loading branch information
dubois committed Dec 5, 2017
1 parent dc9d1cd commit 7bebe27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ Category {
float4 center = SpreadParticle(v, spreadProgress);

float3 displacement_SS = spreadProgress * computeDisplacement(center, 1);
float3 displacement_WS = mul(xf_CS, displacement_SS);
float3 displacement_OS = mul(unity_WorldToObject, displacement_WS);
float3 displacement_WS = mul(xf_CS, float4(displacement_SS, 0));
float3 displacement_OS = mul(unity_WorldToObject, float4(displacement_WS, 0));
center.xyz += displacement_OS;
float4 corner = OrientParticle(center.xyz, halfSize, v.vid, rotation);
o.vertex = UnityObjectToClipPos(corner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Category {
// The problem with this is that if you scale up a layer, the particles
// get big but the overall motion stays the same.
float4 center_WS = mul(unity_ObjectToWorld, center);
center_WS.xyz += mul(xf_CS, disp);
center_WS.xyz += mul(xf_CS, float4(disp, 0));
float4 corner_WS = OrientParticle_WS(center_WS.xyz, halfSize, v.vid, rotation);
o.vertex = mul(UNITY_MATRIX_VP, corner_WS);
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,22 @@ Category {
float4 vertex : POSITION;
fixed4 color : COLOR;
float3 normal : NORMAL;
#if SHADER_TARGET >= 40
centroid float2 texcoord : TEXCOORD0;
#else
float2 texcoord : TEXCOORD0;
#endif
float3 worldPos : TEXCOORD1;
};

struct v2f {
float4 vertex : POSITION;
float4 color : COLOR;
#if SHADER_TARGET >= 40
centroid float2 texcoord : TEXCOORD0;
#else
float2 texcoord : TEXCOORD0;
#endif
float3 worldPos : TEXCOORD1;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Category {
disp += float3(0,0,1) * curlZ(center_WS.xyz * freq + time, d);
disp = disp * 5 * kDecimetersToWorldUnits;

center_WS.xyz += mul(xf_CS, disp);
center_WS.xyz += mul(xf_CS, float4(disp, 0));

float4 corner = OrientParticle_WS(center_WS.xyz, halfSize, v.vid, rotation);
o.vertex = mul(UNITY_MATRIX_VP, corner);
Expand Down

0 comments on commit 7bebe27

Please sign in to comment.