direct3d - Passing colors through a pixel shader in HLSL -
i have have pixel shader should pass input color through, instead getting constant result. think syntax might problem. here shader:
struct pixelshaderinput { float3 color : color; }; struct pixelshaderoutput { float4 color : sv_target0; }; pixelshaderoutput main(pixelshaderinput input) { pixelshaderoutput output; output.color.rgba = float4(input.color, 1.0f); // input.color 0.5, 0.5, 0.5; output black // output.color.rgba = float4(0.5f, 0.5f, 0.5f, 1); // output grayness homecoming output; }
for testing, have vertex shader precedes in pipleline passing color parameter of 0.5, 0.5, 0.5. stepping through pixel shader in visualstudio, input.color has right values, , these beingness assinged output.color correctly. when rendered, vertices utilize shader black.
here vertex shader element description:
const d3d11_input_element_desc vertexdesc[] = { { "position", 0, dxgi_format_r32g32b32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, { "color", 0, dxgi_format_r32g32b32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, { "texcoord", 0, dxgi_format_r32g32_float, 0, d3d11_append_aligned_element, d3d11_input_per_vertex_data, 0 }, };
i'm not sure if it's of import vertex shader takes colors rgb outputs same, pixel shader outputs rgba. alpha layer working correctly @ least.
if comment out first assignment, 1 using input.color, , uncomment other assignment, explicit values, rendered pixels grayness (as expected).
any ideas on i'm doing wrong here?
i'm using shader model 4 level 9_1, optimizations disabled , debug info enabled.
output.color.rgba = float4(input.color, 1.0f);
your input.color float4 , passing float4, think should work
output.color.rgba = float4(input.color.rgb, 1.0f);
this need pass thru simply
homecoming input.color;
if want alter colour reddish like
input.color = float4(1.0f, 0.0f, 0.0f, 1.0f); homecoming input.color;
direct3d hlsl pixel-shader
No comments:
Post a Comment