Gamestudio Links
Zorro Links
Newest Posts
Where's the Wiki?
by Quad. 06/25/19 22:16
Published Gamestudio Games?
by Dooley. 06/25/19 16:59
Updating to A8 [SOLVED]
by Dooley. 06/25/19 16:00
Message from IB of open position
by Zheka. 06/25/19 13:58
FXCM: "Can't connect to price server"
by riinvest. 06/25/19 10:35
New Zorro version 2.12
by jcl. 06/25/19 09:42
Aum120 is ready
by Emre. 06/24/19 17:54
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
5 registered members (JeyKey II, wdlmaster, alibaba, jenGs, kvm), 574 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Theaisback, redye, rhe2564, Qw3rty, Dal
18239 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
soft particle question #474776
11/05/18 12:24
11/05/18 12:24
Joined: May 2009
Posts: 5,106
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,106
Caucasus
Hi!

I've got that soft particle shader from the wiki, but it turned out that it won't work without sky, or with a sky that uses custom shader. I guess it's all related to it's 'depth' thing, but not sure. Can anyone help me out here, or point me in a right direction? Help you in advance.

Some screens:

Quote:
How it looks like with default acknex sky and without fog:

Default acknex sky + fog, what are those while lines on the edges?

Custom sky shader (thanks to txesmi laugh ) and without fog:


Here are the .fx files:

softparticle.fx
Code:
float4x4 matWorld;
float4x4 matWorldViewProj;
float4 vecViewPos;
float4 vecColor;
float vecSkill1;

texture entSkin1;
texture rttDepth_bmap;
sampler SKIN = sampler_state { texture = (entSkin1);};
sampler DEPTH = sampler_state { texture = (rttDepth_bmap);};

float4 VS (	in float4 P : POSITION, in float2 T : TEXCOORD0, out float2 tex : TEXCOORD0, out float3 depth : TEXCOORD1, out float4 pos : TEXCOORD2) : POSITION {

	tex = T;
	pos = mul(P,matWorld);
	depth = mul(P,matWorldViewProj).xyw;
	return mul(P,matWorldViewProj);
	
}

float4 PS (	in float2 tex : TEXCOORD0, in float3 depth : TEXCOORD1, in float4 pos : TEXCOORD2) : COLOR {

	float4 color = tex2D(SKIN,tex) * vecColor;
	float D = tex2D(DEPTH,0.5 * depth.xy / depth.z + 0.5);
	color.a *= saturate((D - distance(pos,vecViewPos)) / vecSkill1.x);

	return color;

}

technique t{
	
	pass p{
		
		VertexShader = compile vs_2_0 VS();
		PixelShader = compile ps_2_0 PS();
		
	}

}


depth.fx
Code:
float4x4 matWorld;
float4x4 matWorldViewProj;
float4 vecViewPos;

float4 VS (	in float4 P : POSITION, out float4 pos : TEXCOORD0) : POSITION {

	pos = mul(P,matWorld);
	return mul(P,matWorldViewProj);
	
}

float4 PS (	in float4 pos : TEXCOORD0) : COLOR {

	return distance(pos,vecViewPos);
	
}

technique t{ 
	pass p{
		
		VertexShader = compile vs_2_0 VS();
		PixelShader = compile ps_2_0 PS();
		
	}
}


custom sky shader
Code:
float4 vecViewPos;
float4 vecFog;
float4 vecFogColor;
float4 vecSkill1;

float4x4 matWorld;
float4x4 matWorldViewProj;

texture mtlSkin1;
samplerCUBE mtlSkin1SamplerCUBE = sampler_state { Texture = <mtlSkin1>; Mipfilter = NONE; Minfilter = NONE; Magfilter = NONE; };

void SkyVS (
in float4 inPos: POSITION,
out float4 outPos: POSITION,
out float4 outWorld: TEXCOORD1 )
{
	outPos = mul( inPos, matWorldViewProj );
	outWorld = mul( inPos, matWorld );
}


float4 SkyPS (
in float4 inWorld: TEXCOORD1 ) : COLOR0
{
	float3 Dir = normalize ( inWorld.xyz - vecViewPos.xyz );
	float4 Color0 = texCUBE ( mtlSkin1SamplerCUBE, Dir );
	Color0.a = 1.0f;
	
	float Fog = 1.0f - pow ( Dir.y, vecSkill1.x );
	Color0.rgb = lerp ( Color0.rgb, vecFogColor.rgb, Fog );
	
	return Color0;
}



technique Sky
{
	pass p0
	{
		CullMode = None;
		
		VertexShader = compile vs_3_0 SkyVS();
		PixelShader  = compile ps_3_0 SkyPS();
	}

}


And the way it's created:
Code:
sky_ent = ent_createlayer(SPHERE_MDL,  SHOW | SKY | CUBE, 1);
vec_fill(&sky_ent->scale_x, (camera->clip_far * 0.99) / 16);
sky_ent->material = mtl_create();
sky_ent->material->skin1 = bmap_create(sky_bbox_tga);
bmap_to_cubemap(sky_ent->material->skin1);
effect_load(sky_ent->material, "mtl_sky.fx");
sky_ent->material->skill1 = floatv(1.6);


Best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: soft particle question [Re: 3run] #474778
11/05/18 14:31
11/05/18 14:31
Joined: Apr 2002
Posts: 1,225
ny
jumpman Offline
Serious User
jumpman  Offline
Serious User

Joined: Apr 2002
Posts: 1,225
ny
hey 3run, try this if it fixes those small lines/offsets:

Code:
float D = tex2D(DEPTH,0.5 * depth.xy / depth.z + 0.5001);



I can confirm Ive had trouble getting correct depth values when I set NOSKY on the soft particle view. Put the sky back on.

In the sky material, try seting the flags ENABLE_RENDER and ENABLE_TREE. Then in the sky material's event do this:

Code:
if(render_view==soft_particle_depth) //if this view is the soft depth view
{
mtl=mtl_depth;  //manually force the sky material to use the depth shader
}



A8 Pro 8.47
Re: soft particle question [Re: jumpman] #474779
11/05/18 15:38
11/05/18 15:38
Joined: May 2009
Posts: 5,106
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,106
Caucasus
Hey! laugh

Added all the changes, but I can't really see any difference frown White lines are still there, and about event and flags for the sky material, this is how I've done it:

Code:
void sky_event(){
	
	//if this view is the soft depth view
	if(render_view == vDepth){
		
		// manually force the sky material to use the depth shader
		mtl = mDepth;
		
	}
	
}

// create sky entity
void pipeline_sky_create(){
	
	sky_ent = ent_createlayer(SPHERE_MDL,  SHOW | SKY | CUBE, 1);
	vec_fill(&sky_ent->scale_x, (camera->clip_far * 0.99) / 16);
	sky_ent->material = mtl_create();
	sky_ent->material->skin1 = bmap_create(sky_bbox_tga);
	sky_ent->material->flags |= ENABLE_RENDER | ENABLE_TREE;
	sky_ent->material->event = sky_event;
	bmap_to_cubemap(sky_ent->material->skin1);
	effect_load(sky_ent->material, "mtl_sky.fx");
	sky_ent->material->skill1 = floatv(1.6);
	
}

But unfortunately this also makes no changes..

Thank you for your time man!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: soft particle question [Re: 3run] #474782
11/05/18 17:56
11/05/18 17:56
Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
Hi,
I downloaded the pack and copied the sky setup from your post just before the main loop and it works fine confused



Code:
#include <acknex.h>
#include "shared.c"

var ParticleSmoothness = 200;

BMAP* rttDepth;					

MATERIAL* mDepth= {	
	effect = "depth.fx";				
	flags = AUTORELOAD | PASS_SOLID;}		

MATERIAL* mSoftParticle = {
	effect = "SoftParticle.fx";
	flags = AUTORELOAD;}

VIEW* vDepth = {					
	material = mDepth;
	aspect = -1;		
	flags = SHOW | NOFLAG1;}

function particle();

function main() {

	video_set (sys_metrics(0),sys_metrics(1),32,1);
//	video_set (700,700,32,0);fps_max=60;
	level_load (null);

	rttDepth = bmap_createblack(screen_size.x,screen_size.y,14);
	vDepth.bmap = rttDepth;

	you = ent_create ("what_is_it.mdl",nullvector,null);

	camera.x	= -2000;
	camera.z	= 2000;
	camera.tilt	=-45;
	
	ENTITY *sky_ent = ent_createlayer(SPHERE_MDL,  SHOW | SKY | CUBE, 1);
	vec_fill(&sky_ent->scale_x, (camera->clip_far * 0.99) / 16);
	sky_ent->material = mtl_create();
	sky_ent->material->skin1 = bmap_create("skycube+6.tga");
	bmap_to_cubemap(sky_ent->material->skin1);
	effect_load(sky_ent->material, "sky.fx");
	sky_ent->material->skill1 = floatv(1.6);

	while (1) {

	vec_set (vDepth.x,camera.x);
	vec_set (vDepth.pan,camera.pan);

	if (random(10) > 9) ent_create ("particle.tga",nullvector,particle);

	ParticleSmoothness += sign(mickey.z) * 50;
	ParticleSmoothness = clamp(ParticleSmoothness,0,1000);
	mSoftParticle.skill1 = floatv(ParticleSmoothness);

	wait(1);}}

function particle() {

	my.roll		= 1;
	my.alpha	= 100;
	set(my,PASSABLE | TRANSLUCENT | FLAG1 | BRIGHT);
	my.material = mSoftParticle;

	vec_scale (my.scale_x,random(4)+1);

	my.x	=-1024;
	my.y	= random(2048)-1024;
	my.z	= random(512) - 256;

	my.red = random(255);
	my.green = random(255);
	my.blue = random(255);

	while (my.x < 1000) {

	my.alpha = minv(100,1000 - abs(my.x));
	my.x += 5;

	wait(1);}
	ent_remove (me);}

PANEL* pHelp = {

	digits (  0, 0,"WASD:",font,1,0);
	digits (100, 0,"move camera",font,1,0);
	digits (  0,15,"mouse wheel:",font,1,0);
	digits (100,15,"change smoothness (%0.0f)",font,1,ParticleSmoothness);

	flags = SHOW | OUTLINE;}



edited__________________

maybe you needed to align the sky sphere with the camera?

Last edited by txesmi; 11/05/18 17:57.
Re: soft particle question [Re: txesmi] #474783
11/05/18 18:10
11/05/18 18:10
Joined: May 2009
Posts: 5,106
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,106
Caucasus
Hi txesmi!

I copied code you've posted above but no changes for me :<
Here are the results:


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: soft particle question [Re: 3run] #474784
11/05/18 18:34
11/05/18 18:34
Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
Maybe your system has different default values for shading than mine? Strange.

Try to set these states into the pass definition into the shader techniques:

sky.fx
Code:
ZEnable = True;           // Check the projection depth against the Z-buffer
ZWriteEnable = False;     // Do not write into the Z-buffer
AlphaBlendEnable = False; // Draw by substitution



particle.fx
Code:
ZEnable = True;          // Check the projection depth against the Z-buffer
ZWriteEnable = False;    // Do not write into the Z-buffer
AlphaBlendEnable = True; // Mix colors by the alpha value



I believe it has to be something related... let's see

Re: soft particle question [Re: txesmi] #474785
11/05/18 18:46
11/05/18 18:46
Joined: May 2009
Posts: 5,106
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,106
Caucasus
I've just added those into .fx files, but results are the same... :<


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: soft particle question [Re: 3run] #474786
11/05/18 18:50
11/05/18 18:50
Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
mmm

try setting the sky 'ZWriteEnable' state to 'True'...

Re: soft particle question [Re: txesmi] #474787
11/05/18 18:52
11/05/18 18:52
Joined: May 2009
Posts: 5,106
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,106
Caucasus
Still no changes... here are results (it's like I'm posting the same image over and over again):


Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: soft particle question [Re: 3run] #474788
11/05/18 19:00
11/05/18 19:00
Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,229
Hiporope and its pain
crazy I am out of the run. No idea what can be happening.

Did you try unrelated things, like disabling the BRIGHT flags of the particles?

Page 1 of 2 1 2

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1