@Juix wrote:
I have recently started using pixel shaders to add some cool effects to my game. I recently added a "cloth" in game that would replace parts of player's characters with a 10x10 repeating texture. It works perfectly for iOS and most Android devices, but some Android devices don't draw anything. Does anyone have any insight into why this is?
Here are some screenshots of the problem
Problematic Device:
Working Device
Shader
The shader uses the R and G values of the mask to determine how to overlay the texture
`sampler s0; float2 posInTexture; float2 texSize; bool hasTex1; bool hasTex2; float2 textilePos1; float2 textilePos2; float alpha; texture textile; sampler textile_sampler = sampler_state { Texture = <textile>; MinFilter = Point; MagFilter = Point; MipFilter = Point; AddressU = Clamp; AddressV = Clamp; }; texture mask; sampler mask_sampler = sampler_state { Texture = <mask>; MinFilter = Point; MagFilter = Point; MipFilter = Point; AddressU = Clamp; AddressV = Clamp; }; float mod(int a, int b) { return a - (b * floor(a / b)); } float4 TextileColor(int pX, int pY, sampler text, float2 offset) { return tex2D(text, float2(offset.x + mod(pX, 10) / 50, offset.y + mod(pY, 10) / 50)); } float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { float4 color = tex2D(mask_sampler, coords); float4 normColor = tex2D(s0, coords); float2 localPos = float2((coords.x - posInTexture.x) / texSize.x, (coords.y - posInTexture.y) / texSize.y); float4 texColor1 = float4(TextileColor(localPos.x * 48, localPos.y * 48, textile_sampler, textilePos1).rgb * color.r, 1); float4 texColor2 = float4(TextileColor(localPos.x * 48, localPos.y * 48, textile_sampler, textilePos2).rgb * color.g, 1); if (hasTex1 && color.r > 0) { return texColor1 * alpha; } if (hasTex2 && color.g > 0) { return texColor2 * alpha; } return normColor * alpha; } technique Technique1 { pass Pass1 { PixelShader = compile ps_3_0 PixelShaderFunction(); } }
`
Any help would be greatly appreciated! Thanks
Posts: 1
Participants: 1