Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[World] Censor shader #27

Open
riperiperi opened this issue Aug 31, 2016 · 3 comments
Open

[World] Censor shader #27

riperiperi opened this issue Aug 31, 2016 · 3 comments

Comments

@riperiperi
Copy link
Owner

riperiperi commented Aug 31, 2016

Obvious enough. Might need to force using a backbuffer rendertarget for this one (right now only used in software depth). TS1 has this easy because of their rendering pipeline.

image

@ssinakhot
Copy link

I'm not big on graphics but I might be able to help out if you can give me some direction?

@riperiperi
Copy link
Owner Author

The censor blur is a sprite that simply draws what is behind it on the screen, except heavily mosaiced. Since you cannot use a render target as a texture as you're rendering to it, you must first copy the screen render texture to another texture at the time you want to start drawing transparent effects like this. You could do this to a half res render target on standby each frame.

The blur itself is rather simple to do using SV_Position in the shader to sample the copied screen texture at the fragment position, then you can quantize that by removing the fractional part (float2 frac = fmod(SV_Position.xy, pixelSize), float2 uv = SV_Position.xy - frac)

It's a bit more difficult to get it to match the original, where the mosaic always starts at the top left of the box, but it's possible if you're able to get the top left position to the fragment shader.

@riperiperi
Copy link
Owner Author

Note: It's been a while since I used HLSL, so I'm not sure what coordinate space SV_Position is in. (0-1, or pixels eg. 0-1920) Either way, texture sampling will expect it in 0-1 uv space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants