Welcome, Guest
Username Password: Remember me

TOPIC: Transparency in Videos

Re: Transparency in Videos 1 month ago #204977

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
I'm aware that this feature is flagged experimental.

It appears to me as if the number of textures accessible as PNG resource is limited to five. No message appears, but as soon as 5 are exceeded, all samplers assigned to png textures return unexpected values. Is that known behaviour?
It's better to travel well than to arrive...
Last Edit: 1 month ago by hugly.

Re: Transparency in Videos 1 month ago #204980

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 3430
  • 1 month ago
hugly wrote:
Is that known behaviour?

I do not think so.
Does it occur in all cases with all material?
Resolution of the PNG?
Did you observe the V-Ram utilization?
Mainly automatically translated
--------------------------------------------
Windows 10, 64 Bit
Intel i5-4440 (3,1 GHz) ; Intel HD Graphics 4600

Re: Transparency in Videos 1 month ago #204986

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
That doesn't seem to be a resource or media issue, it feels more like an artificial limit caused by the implementation.

I've attached a simple test effect, including 9 small PNGs, 6 used in the program. The switch TURN_2_BLACK affects only two lines, a texture/sampler declaration (line46/47), unused afterwards.
Attachments:
  • Attachment This attachment is hidden for guests. Please log in or register to see it.
It's better to travel well than to arrive...

Re: Transparency in Videos 1 month ago #204994

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 3430
  • 1 month ago
hugly wrote:
I've attached a simple test effect...

Not yet simple enough to answer this basic question.

I have removed from the effect everything that has nothing directly to do with the PNG import:
This attachment is hidden for guests. Please log in or register to see it.
(Zip file without the PNG files)


Answer: 6 PNG direct imports work.
If it still works, if you add back the two normal inputs that I removed to analyze this question, I did not test it.
Mainly automatically translated
--------------------------------------------
Windows 10, 64 Bit
Intel i5-4440 (3,1 GHz) ; Intel HD Graphics 4600

Re: Transparency in Videos 1 month ago #204995

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
Thanks for testing.

schrauber wrote:
If it still works, if you add back the two normal inputs that I removed to analyze this question, I did not test it.

When adding only Fg it still works, Fg and Bg is too much. Some pixels are flashing far left, the rest is black. Do you see the same?

Since I need it currently for a transition, not to display PNGs, Fg and Bg are mandatory.
Attachments:
  • Attachment This attachment is hidden for guests. Please log in or register to see it.
It's better to travel well than to arrive...

Re: Transparency in Videos 1 month ago #204996

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
Could it be that this issue has something to do with max. available TEXCOORD[0..7]?


This image is hidden for guests. Please log in or register to see it.
It's better to travel well than to arrive...

Re: Transparency in Videos 1 month ago #204999

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 3430
  • 1 month ago
Maybe?
In my effects I had only used max. 5 inputs so far (real inputs).

If you need more image-direct imports, you could combine several small PNGs into one large PNG and zoom in on what you need in each case (`string Resource` uses the original resolution).
Mainly automatically translated
--------------------------------------------
Windows 10, 64 Bit
Intel i5-4440 (3,1 GHz) ; Intel HD Graphics 4600
Last Edit: 1 month ago by schrauber.

Re: Transparency in Videos 1 month ago #205000

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
I'm still on my trip of porting effects, just to see how that works. It's good to know that there is a functional upper limit without any compiler message, when trying to switch textures.

Thanks for testing and the infos.

The effect Displacement.fx doesn't look that nice with most textures loaded from those PNGs anyway, and I won't spend much more time on it. I'll stay with the 5 best looking, for the moment.

By the way, to reduce the effort with search and replace, I started lettings the pre-processor do some work for the effects from gl-transition.com (still enough to do manually):

// Basic GLSL to HLSLS/Cg translation
#define fract(a) frac(a)
#define mix(a,b,c) lerp(a,b,c)
#define mod(a,b) fmod(a,b)
#define texture2D(a,b) tex2D(a,b)
#define vec2 float2
#define vec4 float4

// Basic translation for code from gl-transition.com
#define getFromColor(uv) tex2D(s_Fg,uv)
#define getToColor(uv) tex2D(s_Bg,uv)
#define progress amount
It's better to travel well than to arrive...
Last Edit: 1 month ago by hugly.

Re: Transparency in Videos 1 month ago #205012

  • jwrl
  • Moderator
    Pro User
  • OFFLINE
  • Moderator
  • Posts: 11407
  • 1 month ago
jwrl wrote:
all() and any() still contain a bug as reported by Nvidia ...
schrauber wrote:
Thank you, interesting.
Do you have a link?

It's somewhere in the original user effects thread started by khaver, from memory.

jwrl wrote:
   a = b > 0.5 || c > 0.50 ? 1.0 : 0.0;         // BAD!!!!
hugly wrote:
Are you sure?

Try it. I'm relying on an increasingly rusty memory, and I'm quite happy to be proven wrong.
Last Edit: 1 month ago by jwrl.

Re: Transparency in Videos 1 month ago #205025

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
Reverse engineering of operator precedence is hard work, since there are many operators and much more possible combinations. I prefer relying on some documentation. I found this sentence in Microsoft's HLSL operator description:

Operator Precedence
When an expression contains more than one operator, operator precedence determines the order of evaluation. Operator precedence for HLSL follows the same precedence as C.

This is from Cg Language Speccification Appendix A, page 189 (this appendix starts with page 165):
Operator Precedence
Cg uses the same operator precedence as C for operators that are common
between the two languages.
The swizzle and write-mask operators (.) have the same precedence as the
structure member operator (.) and the array index operator ([]).


This page on cppreference.com describes C Operator Precedence.


Finally, this chart is from the NVidia Cg Tutorial (the operators in question marked):
This image is hidden for guests. Please log in or register to see it.

Summarizing all this, I think "BAD" can be safely replaced with "Also good", in this case.
It's better to travel well than to arrive...
Last Edit: 1 month ago by hugly.

Re: Transparency in Videos 1 month ago #205046

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
schrauber wrote:
Maybe?
In my effects I had only used max. 5 inputs so far (real inputs).

Using your effect, which is very helpful for testing, I found that compiling with shader profile ps_3_0, more than 8 texel coordinates variables are supported. However, the results with the PNG's are the same, max. 7 textures in total. Beyond that limit, somethings goes wrong. It's sufficient to define additional textures without using them to see it.
Attachments:
  • Attachment This attachment is hidden for guests. Please log in or register to see it.
It's better to travel well than to arrive...

Re: Transparency in Videos 1 month ago #205098

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 3430
  • 1 month ago
hugly wrote:
... profile ps_3_0 ...

I noticed that when I was testing it. But I don't know if the specifications of ps_3_0 should allow more, or just the compiler error message is missing.
Mainly automatically translated
--------------------------------------------
Windows 10, 64 Bit
Intel i5-4440 (3,1 GHz) ; Intel HD Graphics 4600

Re: Transparency in Videos 1 month ago #205100

  • schrauber
  • OFFLINE
  • Platinum Boarder
  • Posts: 3430
  • 1 month ago
jwrl wrote:
.. However in general if an expression will evaluate to a boolean it can be used wherever a boolean is required. For example, the following is valid and will execute reliably.

   a = b > 0.5 ? 1.0 : 0.0;


Do I understand correctly that `b > 0.5` view returns a boolean value even without using `if` or `?`

Would this code also be correct if only boolean values were needed? :

 bool a = b > 0.5;
Mainly automatically translated
--------------------------------------------
Windows 10, 64 Bit
Intel i5-4440 (3,1 GHz) ; Intel HD Graphics 4600
Last Edit: 1 month ago by schrauber.

Re: Transparency in Videos 1 month ago #205101

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
The Cg manual says about ps_3_0:

Sixteen texture units are supported


developer.download.nvidia.com/cg/ps_3_0.html
It's better to travel well than to arrive...

Re: Transparency in Videos 1 month ago #205102

  • hugly
  • OFFLINE
  • Platinum Boarder
  • Posts: 20864
  • 1 month ago
schrauber wrote:
Do I understand correctly that `b > 0.5` view returns a boolean value even without using `if` or `?`

Would this code also be correct if only boolean values were needed? :
 bool a = b > 0.5;


Yes to both, unless Cg isn't compliant with the C standards.

Edit: Assuming that a and b are scalar values.
It's better to travel well than to arrive...
Last Edit: 1 month ago by hugly.
Time to create page: 0.34 seconds
Scroll To Top