Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by jcl. 04/20/24 08:52
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (7th_zorro, Aku_Aku, henrybane, flink, 1 invisible), 712 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
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
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474778
11/05/18 14:31
11/05/18 14:31
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline
Serious User
jumpman  Offline
Serious User

Joined: Apr 2002
Posts: 1,246
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
}


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

Joined: May 2009
Posts: 5,370
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
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474782
11/05/18 17:56
11/05/18 17:56
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
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,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
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
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474784
11/05/18 18:34
11/05/18 18:34
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
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,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
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
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474786
11/05/18 18:50
11/05/18 18:50
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
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,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
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
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474788
11/05/18 19:00
11/05/18 19:00
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
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?

Re: soft particle question [Re: txesmi] #474789
11/05/18 19:03
11/05/18 19:03
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Yep, just tried.. but no changes frown


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474790
11/05/18 19:11
11/05/18 19:11
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
As test, let's see if it runs compiled
https://app.box.com/s/kj4m6rxwsqcqon1g6fxuge2ddg1x2bc5

Re: soft particle question [Re: txesmi] #474791
11/05/18 19:25
11/05/18 19:25
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Well that's now really weird... Compiled one works fine, but running 'SoftParticle.c' doesn't work? How come?
Edit: compiled 'SoftParticle.c' on my side and it didn't work...


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474792
11/05/18 19:40
11/05/18 19:40
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
No idea, man. I am sorry. That is really weird indeed.

Re: soft particle question [Re: txesmi] #474793
11/05/18 19:42
11/05/18 19:42
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
I'll try older shade-c volumetric particles out then. Didn't want to use them, cause they require too many skins etc, but we'll see how it goes out. Thank you for your time and help guys laugh

My best regards!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: soft particle question [Re: 3run] #474806
11/06/18 10:46
11/06/18 10:46
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Nope.. just tried out those volumetric particles from older shade-c. It's not what I'm looking for. So I guess no soft particles for me grin At least not with acknex,


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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