Page 1 of 1

[SOLVED] Shader function "sample2DTextureVec3" not working anymore...

Posted: Sun Mar 29, 2020 7:46 pm
by easyarchitect
Hi, I'm trying to export an Indigo scene from my CAD application.

The shader below does't work anymore (it worked with an older Indigo version)


This is the shader.

I've done some test, the shader works, is the function "sample2DTextureVec3" that seems to always return (0,0,0)

Please help !!

Thank you

Antonio

Code: Select all

<material> <!-- IgsMaterialType : "IgsDiffuse" -->
  <name>Material_12</name>
  <diffuse>
    <texture>
      <!-- TextureMap[0] : "Immagine primaria" -->
      <uv_set>default</uv_set>
      <path>.\MAINA SALA (baco)\MATTONI%20PIETRA%20ECRU_BUMP_IMG1.bmp</path>
      <exponent>2.2</exponent>
      <b>1</b>
      <c>0</c>
    </texture>
    <texture>
      <!-- TextureMap[1] : "Mappa livello bumping" -->
      <uv_set>uv_set1</uv_set>
      <path>.\MAINA SALA (baco)\MATTONI%20PIETRA%20ECRU_BUMP_BUMP.bmp</path>
      <exponent>2.2</exponent>
      <b>0.001000</b>
      <c>0</c>
    </texture>
    <albedo>
      <shader>
        <shader>
          <![CDATA[
            def multiplyColor(vec3 col1, vec3 col2) vec3: vec3(mul(doti(col1),doti(col2)),mul(dotj(col1),dotj(col2)),mul(dotk(col1),dotk(col2)))
            def eval(vec3 pos) vec3 : multiplyColor(sample2DTextureVec3(0,getTexCoords(0)),vec3(0.992157,0.960784,0.901961))
          ]]>
        </shader>
      </shader>
    </albedo>
    <bump>
      <texture>
        <texture_index>1</texture_index>
      </texture>
    </bump>
  </diffuse>
</material>

Re: Shader function "sample2DTextureVec3" not working anymore...

Posted: Sun Mar 29, 2020 8:03 pm
by easyarchitect
To help you, I've created a sample Image.

The vase has this Material below:

Code: Select all

<material> 
  <name>Material_14</name>
  <diffuse>
    <texture>
      <uv_set>default</uv_set>
      <path>CAST_IMG1_V2.bmp</path>
      <exponent>2.2</exponent>
      <b>1</b>
      <c>0</c>
    </texture>
    <albedo>
      <shader>
        <shader>
          <![CDATA[            
            def eval(vec3 pos) vec3 : sample2DTextureVec3(0,getTexCoords(0))
          ]]>
        </shader>
      </shader>
    </albedo>
  </diffuse>
</material>
Everything else has this material below:

Code: Select all

<material>
    <name>Material_17</name>
    <diffuse>
      <texture>
        <uv_set>default</uv_set>
        <path>CAST_IMG1_V2.bmp</path>
        <exponent>2.2</exponent>
        <b>1</b>
        <c>0</c>
      </texture>
      <albedo>
        <texture>
          <texture_index>0</texture_index>
        </texture>
      </albedo>
    </diffuse>
  </material>
This is the result
ShaderBug.png

Re: Shader function "sample2DTextureVec3" not working anymore...

Posted: Sun Mar 29, 2020 9:36 pm
by Zom-B
easyarchitect wrote:
Sun Mar 29, 2020 7:46 pm
The shader below does't work anymore (it worked with an older Indigo version)
Can you tell the Indigo version where this shader worked?

I added this issue to the bugtracker, so thank you for reporting!

Re: Shader function "sample2DTextureVec3" not working anymore...

Posted: Sun Mar 29, 2020 9:59 pm
by easyarchitect
[SOLVED]

Starting from Indigo 3.6.14, the texture used by shader must be declared locally to the shader...

Here is the correct shader:

Code: Select all

<material> 
  <name>Material_14</name>
  <diffuse>
    <texture>
      <uv_set>default</uv_set>
      <path>CAST_IMG1_V2.bmp</path>
      <exponent>2.2</exponent>
      <b>1</b>
      <c>0</c>
    </texture>
    <albedo>
      <shader>
    	<texture>
            <path>CAST_IMG1_V2.bmp</path>
    	</texture>
        <shader>
          <![CDATA[            
            def eval(vec3 pos) vec3 : sample2DTextureVec3(0,getTexCoords(0))
          ]]>
        </shader>
      </shader>
    </albedo>
  </diffuse>
</material>
bye
R