Jump to content

Transparent surfaces and planar reflections


photo

Recommended Posts

Hi,

I have an object extern which has a alpha blending material, something very similar with the old 2D clouds (actually is a resurrection of the old 2d volumetric clouds with some modifications):

<base_material name="vstep_volume_clouds" editable="0">
	<options two_sided="1" transparent="2" order="10" depth_mask="0" cast_shadow="0" receive_shadow="0" cast_world_shadow="0" receive_world_shadow="0"/>
	<blend src="src_alpha" dest="one_minus_src_alpha"/>

	<state name="surface" internal="1" type="switch" items="sphere,clouds,shadow">0</state>
	<state name="ambient" type="switch" items="none,default" title="Environment and Emission" group="Light Passes"	 tooltip="Environment and emissions">1</state>
	<state name="volume" internal="0" type="toggle" title="Soft Interaction" group="Options"	tooltip="&lt;p&gt;Enable soft depth interaction.&lt;/p&gt;">0</state>
	<state name="turbulence" internal="0" type="toggle" group="Options"						tooltip="&lt;p&gt;Enable the turbulence effect.&lt;/p&gt;">1</state>
	<state name="geodetic" internal="1" defines="name">0</state>

	<!-- textures -->
	<texture name="noise" surface="0" filter="linear">core/textures/sky_base_noise.dds</texture>
	<texture name="volume" surface="0" filter="linear" wrap="clamp_z">core/textures/sky_base_volume.dds</texture>
	<texture name="density" surface="0" filter="linear">core/textures/sky_base_density.dds</texture>
	<texture type="opacity_depth" unit="15"/>

	<!-- parameters -->
	<group name="Transform">
		<float4 name="volume_transform"	expression="1" title="Volume" tooltip="&lt;p&gt;Transformation of the volumetric clouds mask.&lt;/p&gt;">vec4(2,2,sin(time*0)*0+time*0.005*sin(2.61799),cos(time*0)*0+time*0.005*cos(2.61799))</float4>
		<float4 name="noise_transform" title="Noise" tooltip="&lt;p&gt;Transformation of the volumetric noise texture.&lt;/p&gt;">12.0f 12.0f 1.0f 1.0f</float4>
	</group>
	<group name="Volume">
		<color name="volume_0_color" 	title="Color 0"		tooltip="&lt;p&gt;Color of the volumetric clouds.&lt;/p&gt;">1.0 1.0 1.0 1.0</color>
		<color name="volume_1_color" 	title="Color 1"		tooltip="&lt;p&gt;Color of the volumetric clouds shadowed areas.&lt;/p&gt;">0.321569 0.396078 0.498039 1</color>
		<slider name="volume_01_scale" min="0.0" max="4.0" max_expand="1"		title="Multiplier"	tooltip="&lt;p&gt;Volumetric clouds color multiplier.&lt;/p&gt;">1.0</slider>
		<slider name="volume_alpha" min="0.0" max="2.0" max_expand="1"			title="Alpha"		tooltip="&lt;p&gt;Volumetric clouds alpha value.&lt;/p&gt;">0.15</slider>
		<slider name="volume_turbulence" min="0.0" max="2.0" max_expand="1"	title="Turbulence"	tooltip="&lt;p&gt;Volumetric clouds turbulence noise.&lt;/p&gt;">0.45</slider>
		<float2 name="volume_fade" title="Volume Size" tooltip="&lt;p&gt;Controls the fading of the clouds as we go through them.&lt;/p&gt;">300 1000</float2>
	</group>
	<group name="Options">
		<slider name="volume_scale" volume="1" min="0.0" max="128.0" max_expand="1" title="Soft Interaction" tooltip="&lt;p&gt;Clouds soft interaction scale.&lt;/p&gt;&lt;p&gt;Depth factor that controls the volumetric clouds dispersal depending on their position relative to the object.&lt;/p&gt;">64.0</slider>
	</group>

	<shader pass="ambient" node="object_extern"
		surface="0"
		turbulence_defines=",TURBULENCE"
		volume_defines=",VOLUME"
		ambient="1"
		vertex="data/Common/Materials/Sky/Clouds/vertex/volume.vert"
		fragment="data/Common/Materials/Sky/Clouds/fragment/volume.frag"/>

	<shader pass="reflection" node="object_extern"
		surface="0"
		turbulence_defines=",TURBULENCE"
		volume_defines=",VOLUME"
		defines="BASE_REFLECTION"
		planar_reflection="1"
		vertex="data/Common/Materials/Sky/Clouds/vertex/volume.vert"
		fragment="data/Common/Materials/Sky/Clouds/fragment/volume.frag"/>

</base_material>

All is working fine for normal rendering, but the clouds never show in any 2D planar reflection surfaces. 

Debugging the code I can see that only surfaces with deferred pass are considered to be added to reflection_surfaces for the RenderScene. So my question is: what is missing from my material to make the alpha blended surface show in reflections? Do I need to add a deferred pass? And if so what this actually do?

As seen above I've added a reflection pass but I guess this is to be added to surfaces actually doing the reflection (and not the reflected ones)?

Regards,
Adrian L.

Link to comment

Hello Adrian,

I don't think there should be additional considiration to make alpha blend objects appear in planar reflection. Planar reflection just renders scene from another camera. If you add for example volume_cloud_base object (which defines only ambient pass and a couple of debug ones), it will appear in the reflection.

image.png

Reflection pass is responsible for applying planar reflection, not participating in it. reflection_surfaces correspond to those surfaces which define that pass

So we'll probably need some sort of reproducer to find out the reason why it doesn't appear.

 

Link to comment
×
×
  • Create New...