Fill Spectre v3.1

Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Alright, I've had a big long go at it and improved some things. Still seems a long way to go though :|

The improvements:
Overall smoother and clearer presentation.
There's some primitive sprite angle changing occuring- I think it needs to be based on relative position though, not angle?
The foreground (including the player sprite) no longer gets reflected in the lensing effect (always did).
The new lensing technique can now allow the Spectre to go behind other objects.
It is compatible with all texture filtering and upscaling options but not multisampling.

The Faults:
The purple sprite should only be enabled for the closest Spectre but is visible for those not being counteracted by the shader.
The lensing only works on the most recently seen Spectre.
No movement interpolation.
The frames don't animate for some reason apart from rotations. -Just figured out why apart from the death sequence.
The death sequence (now animates) but gets squashed by the bounding box.
The perspective is only being approximated by the shader by scaling to it's maximum area.
You do not have the required permissions to view the files attached to this post.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

Now thats a great step to....step forward :P

I see that all vertices are sent to shader, but it processes only first one. Why?
Found out
Uniforms are so named because they do not change from one execution of a shader program to the next within a particular rendering call.
Shader dont support "for( true or false ) {do while true}" state at all, or it just cant cloak all spectres in sight due how it receive coordinate?
I can force code to store all vectors/coordonate of points into array, but shader cant iterate through array by itself, right!?

If no, maybe it makes sense to create several(dozens) of same shader copy, in every of which script must send coordinate of spectre? Like, shader "spectre1", shader "spectre2", shader "spectre"...
Because this can solve first two "The sins of demon before father-of-all".


After quick view, diagonally, into opengl wiki, I see that shader CAN have array and CAN iterate through it, but looks like zscript cant fill such array with data.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

I swear I have sent an array to a shader once before (pre-release RetroSpectre) but can't for the life of me remember how I did it. It was way too slow due to it's size is all I can remember but should be okay for this. If we could do that it would remove any limits to the maximum number of Spectres too, right? Then a Do/While loop in the shader should do the rest of the work...
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

Yes.
But "for(){}" more suitable
for(number = 1, because in opengl arrays begins from 1, not 0; number smaller than size of vertex_array; number +=4)
{apply shader to screen rectangle with coordinate vertex_array[number]/[number+1]/[number+2]/[number+3];}

And what you means by "slow"? FPS drop or what?
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Ah fair enough, I'm not experienced with a lot of coding principles. I mostly use a lot of trial and error.
And what you means by "slow"? FPS drop or what?
Yeah, FPS. I sent the random number array from the 'software' fuzz out of ZScript and into RetroSpectre thinking it would make it faster than running it from inside the shader and got the same drastic slowdown that the actual fuzz gives me. For that reason I drew the array (actually two) into a texture and read from that instead.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

For reference, you can type in console "stat gpu" which can show how much time gpu take to cope with shader.
Also, you can just type "stat" and see list of most commonly used stats. And there is fps stat.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Oh yeah I use 'stat gpu' heaps :lol:

I've only used the vid_fps version for fps though. I'll try the 'stat' one now! :o
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

It can't go above eight and doesn't disable the shaders when you switch maps. I did learn how to use string concatenation for it though :mrgreen:
You do not have the required permissions to view the files attached to this post.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

For some reason this version didnt work in my gzdoom copy. It only show purple spectre and show that shader initialized, with "stat gpu", but thats all.

Also

Code: Select all

string shadnam = string.Format("FillSpec%i", i);
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Bizarre, it did that to me at one point too. I thought I'd fixed it though :?

Code: Select all

string shadnam = string.Format("FillSpec%i", i);
Ah cool, thanks :)

I'm just about finished a sprite shader that will make any sprite compatible by declaring it in GLDefs. Should make the stealth monsters easy.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

This one has the new shader to make any sprite work, though I recommend making them greyscale for best results.
I'm hoping that by using String.Format() it fixes the previous bug because I no longer get it :?
You do not have the required permissions to view the files attached to this post.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Just to take a quote from the other thread:
Pixel Eater wrote:
So, you know what time it is now? Its feature suggestion time!
I have a feature suggestion... suggestion. There may be a better way to make the shader seamless and that is to have the engine send only flagged monsters to a sample texture. The back and foregrounds would need to be pitch black for it to work and the sprite would need to be invisible in the main view. It would put an end to the chroma keying altogether and all it's flaws. I suspect it would be much more complicated for anyone willing to implement the code though...
If that technique were ever to happen then I could do this with the sprites:
Encoded.png
And that would work as my own warped version of a normal map :geek:
You do not have the required permissions to view the files attached to this post.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

No, still dont work as previous version.
I even comment every zscript string with console.printf(1/2/3/4/...); to check, maybe there are something wrong with it. But no, all numbers prints to console.

Check on shitty intel hd 3000 and geforce gt 540/950/1080.
User avatar
Pixel Eater
 
 
Posts: 667
Joined: Wed Aug 02, 2017 12:31 am
Location: In between the Moon and you, between the buried and me.

Re: Fill Spectre v3.1

Post by Pixel Eater »

Aw shoot. What happens when you add 'Enabled' into each shader definition in GLDefs?

For copying and pasting:

Code: Select all

HardwareShader PostProcess beforebloom
{
	Name "FillSpec0"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec1"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec2"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec3"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec4"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec5"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec6"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}

HardwareShader PostProcess beforebloom
{
	Name "FillSpec7"
	Shader "fillspectre.fp" 330
	Uniform float tolerance
	Uniform float tolerance2
	Uniform float tolerance3
	Uniform float depth
	Uniform float alpha
	Uniform vec2 vertex1
	Uniform vec2 vertex2
	Uniform vec2 vertex3
	Uniform vec2 vertex4
	Enabled
}
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Fill Spectre v3.1

Post by Apeirogon »

It still dont work.

Even more, if I change render mode to any non-opengl I see gray spectre.
If select opengl render mode I see purple spectre.

Return to “Shaders”