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

Transparency renders as skybox #50

Open
Phyremaster opened this issue Nov 12, 2023 · 0 comments
Open

Transparency renders as skybox #50

Phyremaster opened this issue Nov 12, 2023 · 0 comments

Comments

@Phyremaster
Copy link

Phyremaster commented Nov 12, 2023

In some cases, transparency on objects renders the skybox instead of opaque objects behind the object with transparency.

I encountered this while working on a shader; the pixel shader disables culling, enables transparency, and (depending on texture coordinates) discards some pixels. This results in gaps that show the back side of the test sphere. This renders as intended in the material editor but not in the scene or game views. Other than setting DevShader and DebugInfo to true in the header, the only changes I've made to the template shader file are in the pixel shader:

PS
{
	#include "common/pixel.hlsl"

	RenderState( CullMode, NONE );
	BoolAttribute( translucent, true );

	float g_flDensity < UiType( Slider ); UiStep( 1 ); Default( 100 ); Range( 1, 1000 ); >;

	//
	// Main
	//
	float4 MainPs( PixelInput i ) : SV_Target0
	{
		Material m = Material::From( i );

		float2 denseTexCoords = i.vTextureCoords * g_flDensity;
		float2 localTexCoords = frac(denseTexCoords) * 2 - 1;
		float localDistanceFromCenter = length(localTexCoords);

		if (localDistanceFromCenter > 1) discard;

		return ShadingModelStandard::Shade( i, m );
	}
}

ShadowBrain mentioned encountering the same behavior with some transparent objects when I brought this up in Discord.

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

No branches or pull requests

1 participant