Please use english language
It is currently 26 Feb 2020, 10:30

All times are UTC





Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 11 Sep 2013, 15:45 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 30 Jan 2012, 13:18
Posts: 528
Hey,

I need some function that gives me the coordinates from bright pixels as output. Is that possible? I want to port an anamorphic flare shader to ENB, what it makes so beautiful is that it basically creates a strechted vignette mask around bright pixels. Then the image gets brightened but only where it's not masked ("bright" parts of the vignette) the brightening is visible. It's very fast, very short and I can't port it because the game I take it from gives these values as output. It should work like this when I set a center point for my vignette mask, I call that function which gives as output the coords of the bright pixels which will get used as vignette center. I also need that function in some other shaders.
Thanks in advance.


Top
 Profile  
 
Tomoko
PostPosted: 14 Sep 2013, 20:34 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 30 Jan 2012, 13:18
Posts: 528
Bump


Top
 Profile  
 
PostPosted: 16 Sep 2013, 11:57 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 30 Jan 2012, 13:18
Posts: 528
Bump! I need this, does no one have an idea how to achieve this?


Top
 Profile  
 
PostPosted: 17 Sep 2013, 00:52 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
Okay, as nobody reply, i do. Some guys asked me the same thing several times, so i'm sure they did such code for gta4, first try to find it. For my opinion much better to compute such effects based on entire image, not just detecting sun. But if only for sun, you can't do much if game use ldr colors, because brightness is very similar between each pixels, better forget the idea. In case of hdr data when sun is very intense, you need to write in one line on side of screen horizontal scanned data, then scan that line and produce one pixel only. Position of bright area must be computed as weighted blending of pixels and by ignoring some of pixels, like this:
Code:
float3 color=0;
float weight=0.000000001;
for (int i=0; i<256; i++)
{
float3 tempcolor=tex2D(colorsampler, somecoordoffsetedcomputedfromindex);
float tempgray=dot(tempcolor.xyz, 0.333);
float tempweight=0;
if (tempgray>MINSUNBRIGHTNESS) tempweight=1;
tempcolor*=tempweight;
weight+=tempweight;
}
color/=weight;
return color;

This code only read pixels which are sun or any huge intensity values, but absolutely the same way must be used to get uv instead of color, so somecoordoffsetedcomputedfromindex used.

_________________
i5-4690k, 16Gb RAM, GTX 1060 6Gb, X-Fi Titanium, Win7 x128
I am INFP, not the brutal, godamnit.


Top
 Profile  
 
PostPosted: 17 Sep 2013, 20:05 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 30 Jan 2012, 13:18
Posts: 528
If I write it that way that if a pixel is bright enough, something like that:

float2 newcoords;
{code stuff

newcoords = somecoordoffsetedcomputedfromindex

}

will it get overwritten every time it finds a new pixel which meets the brightness level? shall I use += or what?


Top
 Profile  
 
PostPosted: 18 Sep 2013, 01:04 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
You don't get it. Read again my example and analyze how weight based sampling work.

_________________
i5-4690k, 16Gb RAM, GTX 1060 6Gb, X-Fi Titanium, Win7 x128
I am INFP, not the brutal, godamnit.


Top
 Profile  
 
PostPosted: 18 Sep 2013, 12:44 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 30 Jan 2012, 13:18
Posts: 528
I understand it but I cannot transpose it on coords instead of color. I'm sure I just stand on the hose, I just don't see it, amybe I'm too stupid.


Top
 Profile  
 
PostPosted: 18 Sep 2013, 13:08 
Offline
*blah-blah-blah maniac*
User avatar

Joined: 27 Dec 2011, 08:53
Posts: 14816
Location: Russia
Weighted method finding middle of the most important (bright) pixels, color or anything else, doesn't matter, just replace "color". Damn, i don't like to help writing all code, it's not help actually, but request.
Code:
float3 uv=0.0;
float weight=0.000000001;
for (int i=0; i<256; i++)
{
float2 somecoordoffsetedcomputedfromindex=coord.xy+i/256;
float3 tempcolor=tex2D(colorsampler, somecoordoffsetedcomputedfromindex);
float tempgray=dot(tempcolor.xyz, 0.333);
float tempweight=0;
if (tempgray>MINSUNBRIGHTNESS) tempweight=1;
uv+=somecoordoffsetedcomputedfromindex*tempweight;
weight+=tempweight;
}
uv/=weight;
return uv;

_________________
i5-4690k, 16Gb RAM, GTX 1060 6Gb, X-Fi Titanium, Win7 x128
I am INFP, not the brutal, godamnit.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group