[2.1] Shader template parser messing up?

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


DOS
Gnoblar
Posts: 19
Joined: Tue Oct 27, 2020 5:34 pm

[2.1] Shader template parser messing up?

Post by DOS »

Hello,

there is an issue with the shader templates I have encountered multiple times now after adding a new @property( ... ) block to a template, where the template won't be parsed correctly any more. E.g. this is part of the dump of a pixel shader:

Code: Select all

#if 0
	***	solid_wireframe	0
	***	hlms_pose	0
	***	hlms_uv_count	0
	***	ELSE_ShadeNon	1
	***	exclude_lines	0
	***	hlms_lights_spotparams	0
	***	hlms_disable_stage	0
	***	hlms_lights_area_approx	0
	***	ELSE_ShadeFlatColour	1
	***	texcoord	4
	***	fast_shader_build_hack	1
	***	glsl	635204550
	***	out_uv_count	0
	***	hlms_high_quality	0
	***	num_array_textures	0
	***	vp_height	1237
	***	IF_NoDiffuseMap	1
	***	hlms_lights_directional	0
	***	alpha_test	0
	***	glsles	1070293233
	***	normals	1
	***	hlms_pose_normals	0
	***	hlms_pose_half	0
	***	hlms_lights_spot	1
	***	raster_cons 	0
	***	hlms_alphablend	1
	***	IF_NeedsMaterial	1
	***	num_textures	0
	***	ELSE_ShadeMaterialColour	1
	***	hlms_shadow_uses_depth_texture	0
	***	hlms_tangent	0
	***	hlms_bones_per_vertex	0
	***	alpha_test_shadow_caster_only	0
	***	materials_per_buffer	2
	***	hlms_skeleton	0
	***	partial_pso_clip_distances	0
	***	syntax	-334286542
	***	vertex_colour	1
	***	hlms_lights_point	1
	***	flat_colour	0
	***	metal	-1698855755
	***	s_lights_directional_non_caster	1
	***	hlms_lights_area_ltc	0
	***	diffuse_map	0
	***	hlms_lights_attenuation	0
	***	hlms_render_depth_only	0
	***	full_pso_clip_distances	0
	***	hlms_qtangent	0
	***	vp_width	2397
	***	diffuse	1
	***	out_uv_half_count	0
	***	hlms_normal	1
	***	hlsl	-334286542
	***	ambient_fixed	1
	***	hlms_colour	1
	***	IF_ShadePixelColour	1
	DONE DUMPING PROPERTIES
	***	blend_mode_idx3	@insertpiece( NormalNonPremul)
	***	blend_mode_idx11	@insertpiece( NormalNonPremul)
	***	blend_mode_idx2	@insertpiece( NormalNonPremul)
	***	blend_mode_idx14	@insertpiece( NormalNonPremul)
	***	blend_mode_idx5	@insertpiece( NormalNonPremul)
	***	blend_mode_idx8	@insertpiece( NormalNonPremul)
	***	blend_mode_idx10	@insertpiece( NormalNonPremul)
	***	blend_mode_idx9	@insertpiece( NormalNonPremul)
	***	blend_mode_idx15	@insertpiece( NormalNonPremul)
	***	blend_mode_idx6	@insertpiece( NormalNonPremul)
	***	blend_mode_idx7	@insertpiece( NormalNonPremul)
	***	blend_mode_idx1	@insertpiece( NormalNonPremul)
	***	blend_mode_idx0	@insertpiece( NormalNonPremul)
	***	blend_mode_idx12	@insertpiece( NormalNonPremul)
	***	blend_mode_idx4	@insertpiece( NormalNonPremul)
	***	blend_mode_idx13	@insertpiece( NormalNonPremul)
	DONE DUMPING PIECES
#endif

@insertpiece( SetCrossPlatformSettings )
@insertpiece( Lights )


	@insertpiece( PassDecl )


// START UNIFORM DECLARATION




	@insertpiece( MaterialDecl )
	@insertpiece( InstanceDecl )


@insertpiece( custom_ps_uniformDeclaration )

// END UNIFORM DECLARATION

struct PS_INPUT
{
	@insertpiece( VStoPS_block )

	float4 gl_Position : SV_Position;

	
	

	

	

	

	
};

@property( !hlms_shadowcaster )
	

	

	
	

	

	@property( diffuse )
		@piece( MultiplyDiffuseConst )
			* material.diffuse
		@end
	@end

	@insertpiece( DeclOutputType )

	@insertpiece( output_type )
	main(
		PS_INPUT inPs
		@property( hlms_vpos )
			, float4 gl_FragCoord : SV_Position
		@end
	)
	{
		PS_OUTPUT outPs = (PS_OUTPUT)0;
		@insertpiece( custom_ps_preExecution )
As you can see most of the @-preprocessor directives have not been replaced and I get a shader compile error "unexpected token @". I have managed to make the issue disappear in the past by shuffling around the @property that I have added, but this is not optimal of course.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5436
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1343

Re: [2.1] Shader template parser messing up?

Post by dark_sylinc »

Usually this happens because you forgot to add an @end clause, or you're defining again a piece that's already been defined.

Or you stumbled into a parsing shenanigan.

What's the snippet you added? Is there a diff?
DOS
Gnoblar
Posts: 19
Joined: Tue Oct 27, 2020 5:34 pm

Re: [2.1] Shader template parser messing up?

Post by DOS »

I just figured it out, I wrote a @property ( ... ) instead of @property( ... )
(space between the y and opening bracket)

My mistake, but that's hard to spot when you don't know what to look for.