Thursday 15 January 2015

shader - HLSL TextureSampler Color returning white -



shader - HLSL TextureSampler Color returning white -

i next tutorial build basic effect texture in xna/monogame. seems working if percentage = 0 homecoming color white. having hard time wrapping head around why happening. here relevant hlsl code

float percentage; sampler texturesampler: register(s0); float4 pixelshaderfunction(float4 pos : sv_position, float4 color1 : color0, float2 tex : texcoord0) : sv_target0 { float4 color = tex2d(texturesampler, tex).abgr; float = color.a; float r = color.r; float g = color.g; float b = color.b; color.rgb = dot(color.rgb, float3(0.7 * percentage, 0.59 * percentage, 0.11 * percentage)); r = r - (r - color.rgb) * percentage; g = g - (g - color.rgb) * percentage; b = b - (b - color.rgb) * percentage; color.a = a; color.r = r; color.g = g; color.b = b; homecoming color; } technique nail { pass pass1 { pixelshader = compile ps_3_0 pixelshaderfunction(); } }

when set argb color1.argb outputs proper color renders solid square rather actual object (a circle in case)

i have fixed changing

float4 color = tex2d(texturesampler, tex).abgr;

to

float4 color = tex2d(texturesampler, tex).abgr * color1;

shader hlsl monogame

No comments:

Post a Comment