Jump to content

[SOLVED] why setProceduralTextureImage has to be called every frame?


photo

Recommended Posts

Posted

hi. I would like to assign a texture to the material

 here is what in the material file

 

<texture name="foreground" pass="post" type="procedural"/>

 

if i use setProceduralTextureImage to assign a image to this foreground texture. i have to assign it every update. Otherwise the texture will be black in the next frame.

is there anyway to just assign once?

thanks

 

Posted

Dear Cinetec,

 

Don't use procedural textures for static images, just use regular ones. Also, instead of calling setProceduralTextureImage just call setImageTextureImage once.

Posted

hi Bob:

<material name="post_B" hidden="1">
		
		<!-- states -->
		<state name="procedural_width" type="switch" items="half_width,width">1</state>
		<state name="procedural_height" type="switch" items="half_height,height">1</state>
		
		<!-- shaders -->
		<shader pass="post"
			vertex="shaders/paint/vertex_filter_base.shader"
			fragment="shaders/paint/fragment_paint_brush.shader"/>
		
		<!-- textures -->
		<texture name="foreground" pass="post" type="procedural"/>
		
		<!-- parameters -->


	</material>
	
	<material name="post_A" >
		<!-- shaders -->
		<shader pass="post"
			vertex="shaders/paint/vertex_filter_base.shader"
			fragment="shaders/paint/fragment_paint_composite.shader"/>
		
		<!-- textures -->
		<texture name="foreground" pass="post" type="procedural"/>
		<!-- parameters -->
	</material>

in my case, i need send a image to post_b material from post_a. It seems only use setProceduralTextureImage could do this.

Posted

Hi Cinetec!

 

Use "filter" texture type for such purposes. For example, in our SSR implementation we're using filter textures to store accumulated reflections which are calculated by another shader and blend them with the screen.

<material name="ssr_calculate" hidden="1">
	
	<!-- shaders -->
	<shader pass="post"
		vertex="core/shaders/default/pbr/vertex/ssr.shader"
		fragment="core/shaders/default/pbr/fragment/ssr.shader"/>
	
	<!-- textures -->
	<texture name="color" pass="post" type="procedural"/>
	<texture name="deferred_depth" pass="post" type="procedural"/>
	<texture name="deferred_normal" pass="post" type="procedural"/>
	<texture name="auxiliary" pass="post" type="procedural"/>
	<texture name="vignette" pass="post" filter="linear" wrap="clamp">core/textures/post_filter_reflection_vignette.dds</texture>
	
	<!-- parameters -->
	...
</material>

<material name="ssr_blur_h" hidden="1">
	
	<!-- shaders -->
	<shader pass="post"
		defines="HBLUR"
		vertex="core/shaders/default/pbr/vertex/ssr.shader"
		fragment="core/shaders/default/pbr/fragment/ssr_blur.shader"/>
	
	<!-- textures -->
	<texture name="color" pass="post" type="procedural"/>
	<texture name="deferred_depth" pass="post" type="procedural"/>
	<texture name="deferred_normal" pass="post" type="procedural"/>
	<texture name="auxiliary" pass="post" type="procedural"/>
	
	<!-- parameters -->
	...
</material>

<material name="screen_space_reflections">
	<state name="filter_width" type="switch" hidden="1" items="width">0</state>
	<state name="filter_height" type="switch" hidden="1" items="height">0</state>
	
	<!-- shaders -->
	<shader pass="post"
		defines="VBLUR,FINAL"
		vertex="core/shaders/default/pbr/vertex/ssr.shader"
		fragment="core/shaders/default/pbr/fragment/ssr_blur.shader"/>
	
	<!-- textures -->
	<texture name="color" pass="post" type="procedural"/>
	<texture name="deferred_depth" pass="post" type="procedural"/>
	<texture name="deferred_normal" pass="post" type="procedural"/>
	<texture name="auxiliary" pass="post" type="procedural"/>
	<texture name="vignette" pass="post" filter="linear" wrap="clamp">core/textures/post_filter_reflection_vignette.dds</texture>

	<!-- this is the texture you're looking for -->
	<texture name="color_reflection" pass="post" type="filter" materials="ssr_calculate,ssr_blur_h"/>
	
	<!-- parameters -->
	...
	
</material>
Posted

hi Bob:

   is that possible to transfer a procedural texture from Material A to B? i know if i want access deferred_color i need use type="deferred_color" in material B. But it seems we missing some other procedural texture access in material B. like "color" "auxiliary" . color is the final render texture and auxiliary is the deferred auxiliary texture. those 2 texture are accessible from material A directly. but not material B

Posted

Hi Cinetec,

 

Use "filter" texture type for such purposes as it allows you to pass it to other shaders as input texture, just look at the sample I mentioned above. You need to set "materials" attribute which will tell what shaders will be applied before this texture get back to your first shader. Don't forget to define that filter texture in other shaders as well (take notice that its name is 'color' by default but you can change this by using "filter_name" state).

Posted

hi Bob:

   It seems filter type does transfer all buffer i need to the material. But one question, how could i get this texture from uniginescript? i guess getProceduralTextureImage doesn't handle this filter type anymore.

thanks

Posted

You can't assign filter textures directly from the script. For such purposes use regular texture and use it during filter texture process.

Posted

thanks Bob. we figured it out.

×
×
  • Create New...