Jump to content
  • Advertisement
Sign in to follow this  
stevemk14ebr

Pixel Shader not coloring all objects

This topic is 1520 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm messing around with coloring the objects of a game i play (offline of course), and am having an issue with my pixel shader. I set the Rasterizer to wireframe, set the HS,GS,DS, and CS shaders to null, then set the pixel shader to a simple red. This works for most objects but some aren't colored properly. Can anyone help?

//Do some model sorting if this is the model i want then do what is below
//this is all done inside a DrawIndexedPrimitiveHook
pDeviceContext->HSSetShader(NULL, NULL, NULL);
pDeviceContext->GSSetShader(NULL, NULL, NULL);
pDeviceContext->DSSetShader(NULL, NULL, NULL);
pDeviceContext->CSSetShader(NULL, NULL, NULL);

//Rasterizer is initialized else where
pDeviceContext->RSSetState(pRasStateWire);
pDeviceContext->PSSetShader(psRed, NULL, NULL);

//Draw the object by calling game original unhooked drawindexedprimitive

//I Set all the shaders back to what they were so the next model draws as it should and return

Shader code:

"float4 main( ):SV_Target"
"{"
"  return float4(1.0f,0.0f,0.0f,1.0f);  "
"}";
//I store it in a char array and compile from memory so that's why i have quotes on every line

Result is some objects not colored properly (like this boat and the arms/gun). Can anyone tell me a possible reason why this happens, i'm out of ideas here.

I can provide more code or info on what i'm doing if requested.

QsrWEpT.jpg

Edited by stevemk14ebr

Share this post


Link to post
Share on other sites
Advertisement

There are other draw commands than just drawindexedprimitive, so hooking it may not be enough.

 

Cheers!

Share this post


Link to post
Share on other sites

If i return in my hook before that object is drawn it does not show up, so no elements of it are drawn using another function. So the issue is me not setting something right, it has to be a blend issue or shader or smth.

Share this post


Link to post
Share on other sites

What game are you talking about? Is the game using forward or deferred rendering?

 

Cheers!

 

[edit] Yes, blend operators may affect the color too 

Edited by kauna

Share this post


Link to post
Share on other sites

Yeah ok, it makes sense - if I interpret the image correctly, only objects not using deferred rendering are red. 

 

You see, the pixel shader you use doesn't output any data that the deferred renderer requires for correct lighting calculations. All the render targets are cleared probably to black, and don't provide the required data. 

 

You could do double drawing - calling the draw command with the original parameters and then with the modified shader and depth stencil state (assuming that the render target 0 contains the color data). This way you'll get the correct lighting parameters for the render targets.

 

Cheers!

Edited by kauna

Share this post


Link to post
Share on other sites

I tried, it still doesn't color the object properly

 

the order i did was 

 

1)call original drawindexed

2)filter out objects

3)if its the object i want then set shaders

4)call original (the shaders should apply now)

5)reset shaders

6)return

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!