View Single Post
Old 08 December 2020, 12:01   #22
kokoko3k
Registered User

 
Join Date: Nov 2020
Location: italy
Posts: 12
Hi,
I'm a n00b in shader development, but i'm still trying hard to make one, so please, excuse my inexact terminology!

What puzzles me now, is that i need to make a multipass shader which should able to draw perfect pixels at fixed window coordinates.
Actually, i'm able to write a single pixel on my monitor using gl_FragColor only in the last pass.

In the following test example:
* the first pass does nothing
* the second pass draws 3 RGB vertical lines starting at row 100
* the third and last pass draws 3 white/black/white vertical lines starting at row 400

If you resize the FS-UAE window, you'll see that
1) the RGB vertical lines mantain a fixed position relative to the amiga screen and are scaled.
2) the white/black/white vertical lines mantain a fixed position relative to the FS-UAE window, and are not scaled, so pixel perfect.

I'd like to have the RGB lines rendered by the second pass to act like the ones rendered by the second one.

Is that possible?
I'm struggling with this problem and even got the xml v1.1 shader docs from the wayback machine, but i'm unable to go on and i'm starting to think that the spec and/or the implementation basically won't allow that.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<shader language="GLSL">

<fragment ><![CDATA[
	uniform sampler2D rubyTexture;
	void main(void) {
		vec3 pixel = texture2D(rubyTexture, gl_TexCoord[0].xy).rgb; 
		gl_FragColor = vec4(pixel,1.0);
	}
]]></fragment>
    

<fragment ><![CDATA[
	uniform sampler2D rubyTexture;
    void main(void) {
        vec3 pixel = texture2D(rubyTexture, gl_TexCoord[0].xy).rgb; 
		float start=100.0;
		float col = float(int(gl_FragCoord.x));
		if ( col  == (start+1.0) ) {
			pixel = vec3(1.0,0.0,0.0);
		}
		if ( col  == (start+2.0) ) {
			pixel = vec3(0.0,1.0,0.0);
		}
		if ( col  == (start+3.0) ) {
			pixel = vec3(0.0,0.0,1.0);
		}
			gl_FragColor = vec4(pixel,1.0);
    }
]]></fragment>


<fragment ><![CDATA[
	uniform sampler2D rubyTexture;
    void main(void) {
        vec3 pixel = texture2D(rubyTexture, gl_TexCoord[0].xy).rgb; 
		float start=400.0;
		float col = float(int(gl_FragCoord.x));
		if ( col  == (start+1.0) ) {
			pixel = vec3(1.0,1.0,1.0);
		}
		if ( col  == (start+2.0) ) {
			pixel = vec3(0.0,0.0,0.0);
		}
		if ( col  == (start+3.0) ) {
			pixel = vec3(1.0,1.0,1.0);
		}
			gl_FragColor = vec4(pixel,1.0);
    }
]]></fragment>
Any hint?


Thanks!


-EDIT-
...Took me a lot to get it; it was the outscale* shader parameter

Last edited by kokoko3k; 10 January 2021 at 10:52.
kokoko3k is offline  
 
Page generated in 0.04258 seconds with 11 queries