Note that there are some explanatory texts on larger screens.

plurals
  1. POCGFX shader extracting data from alpha channel
    primarykey
    data
    text
    <p>I posted this as well on Nvidia Developer discussion.</p> <p><a href="http://forums.developer.nvidia.com/devforum/discussion/9946/extracting-numbers-cgfx-shader" rel="nofollow">http://forums.developer.nvidia.com/devforum/discussion/9946/extracting-numbers-cgfx-shader</a></p> <p>I am learning to write my first cgfx shader- a terrain shader. So I can only use 1 vertex channel (the alpha channel) and I want it to store 3 masks. I programmed a script no problem in the 3d App Maya where I can store 1 mask in the tenths place, 1 in the hundreths, and 1 in the thousandths place. </p> <p>Each original painted mask is clamped at 0 - .9 (to prevent zeroing out with fmod) so if a vert has:</p> <p>mask 1 =.857</p> <p>mask 2 =.345</p> <p>mask 3 -.948</p> <p>the combined alpha channel for this vert is = .839</p> <p>The problem I am having is I cannot get these masks extracted into seperate masks properly in my shader. </p> <p>If I output the Mask1 I get the correct nicely blended mask. I do this by:</p> <pre><code>float Mask1 = (fmod((Mcolor * 10f ), 10f)) *.111f; </code></pre> <p>If I output the Mask2 I get all these weird artifacts. It looks like the mask1 is pushing itself ontop, even when I am only outputting Mask2. I am positive the math works, I have run the same thing in Maya to store the values to begin with. Can anyone tell me why this is happening? </p> <p>Even:</p> <pre><code>float Mask2 = frac(Mcolor *10); </code></pre> <p>which should just push the mask 2 over into tenths place and erase Mask 1 results in the same artifacts. </p> <pre><code>float Mcolor = In.VertColor.a; float Mask1 = (fmod((Mcolor * 10f ), 10f)) *.111f; float Mask2 = (fmod((Mcolor * 100f ), 10f)) *.111f; </code></pre> <p>I posted some images of the issue on the Nvidia forum, but I can't post here becuase of spam prevention. </p> <p><a href="http://forums.developer.nvidia.com/devforum/discussion/9946/extracting-numbers-cgfx-shader" rel="nofollow">http://forums.developer.nvidia.com/devforum/discussion/9946/extracting-numbers-cgfx-shader</a></p> <p>Help is much appreciated -thanks for reading through! Please explain your response if you can/ have time, I am new to programming so the more descriptive the better!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload