noob question related to outline code

Posted By: Reconnoiter

noob question related to outline code - 11/03/17 19:53

Howdy,

Below I have outline shader code that I successfully used previously in a non-ShadeC project, and now I want to use it in a ShadeC evo project. The problem is however that I think I need to add it to an existing pass. When I simply paste it after the current ShadeC pass the whole screen is the outline color (even with extreme thin outline size). And when pasting it as a separate pass it does nothing. So I quessing I need to add it to a current pass but within the linked VertexShader & PixelShader. So I tried that but than I apparently need to change the code/syntax otherwise it gives fx compiling errors ("object literals are not allowed inside functions").
Could someone help me a bit / point me in the right direction with altering the code so I can add it to the existing VertexShader & PixelShader? (if this is feasible that is)

The required variables:
Code:
vector vecSkill41;
const float4x4 matWorldViewProj;



The outline pass:
Code:
pass outline
	{
		CullMode = CCW; // (Commenting these didn't matter) Not really needed, it is the default state
		ZEnable = True; // Not really needed, it is the default state
		ZFunc = Less; // Not really needed, it is the default state
		ZWriteEnable = False;
		//cullMode = cw;
		vertexShaderConstant[0] = <matWorldViewProj>;
		vertexShaderConstant[16] = <vecSkill41>; // outline_thickness
		vertexShader = asm
		{
			vs.1.1
			dcl_position v0
			dcl_normal v3
			dcl_texcoord0 v7
			dcl_texcoord1 v8

			mov r0,v0
			mul r1,c16.x,v3 // scale normal
			add r0.xyz,r0.xyz,r1.xyz // shell offset (vertex position + scaled normal)
			m4x4 oPos,r0,c0 // transform position to clip space
		};
		pixelShader = asm
		{
			ps.1.3
			def c0,255,255,0,1 // color outline rgba
			mov r0,c0
		};
	}



The Shade-C existing technique / pass (sc_deferred_finalize.fx):
Code:
technique t1
{
	pass p0
	{
		//cullmode = ccw;
		//zwriteenable = false;
		alphablendenable = false;
		//VertexShader = compile vs_2_0 mainVS();
		PixelShader = compile ps_3_0 mainPS();
		//FogEnable = False;
		
		SRGBWriteEnable = true;
	}
}

Posted By: Kartoffel

Re: noob question related to outline code - 11/04/17 10:42

The problem is that shade-c (evo) uses deferred rendering and an outline shader like that is usually used in forward rendering. You can still try to use the outline in a second pass but you'd have to output the right data for the gbuffer so your outline is shaded properly in the lighting and shading passes of the deferred pipeline.
Posted By: Reconnoiter

Re: noob question related to outline code - 11/04/17 12:17

Forward rendering is turned on though in the Shade-C init:

Code:
sc_screen_default.settings.forward.enabled = 1; //enable if you need particles or custom materials which can't be rendered in the deferred pipeline


Please note that there is also a "sc_forward.fx" but when I placed the code in that one it didn't do anything and normally it contains only the following:

Code:
technique t1
{
	pass p0
	{
		ColorWriteEnable = 0;
	}
}

© 2024 lite-C Forums