Home Technical Talk

Can't sample textures in ShaderFX custom code

polycounter lvl 8
Offline / Send Message
brurpo polycounter lvl 8
Hi There!

Been porting my shader for Opengl for compatibility reasons. But it seems I cant sample any texture in custom code. Not even Autodesk example works, even though it works in the shaderfx swatch.

It works with OpenGL legacy, seems to be a problem with OGSFX

Did anyone have this kind of problem before or know whats up? Maybe @shaderfx or @kodde?

Thanks!!


Replies

  • brurpo
    Options
    Offline / Send Message
    brurpo polycounter lvl 8
    Got it.

    For some reason this is missing from docs. Docs include code for GLSL_4 that only works in swatches.

    The code for GLSL_4 uses the texture node:

    float3 t = texture( SFX_TEXTURE0, float2(UV.x, 1-UV.y) ).xyz;

    While OGSFX uses the sampler node.

    float3 t = texture( SFX_SAMPLER0, float2(UV.x, 1-UV.y) ).xyz;


    Problem solved.


  • kodde
    Options
    Offline / Send Message
    kodde polycounter lvl 19
    Well that was quick.
    I was going to say I haven't dabbled with sampling textures with custom code.

    Good to hear you solved it.
  • brurpo
    Options
    Offline / Send Message
    brurpo polycounter lvl 8
    Thanks kodde! Not so quick was banging my head against the wall for about 4 hours before coming here haha!

    I mainly use it to get dimensions so I dont need a toggle to enable texture maps.

    But there is a problem, swatches dont use OGSFX, so you lose the ability to check for compile errors, because every OGSFX code turns out as an error in the compiler (even though they work in the viewport).

    The solution is to use compile time if else to add both codes, swatches and viewport. more than doubling the code in many cases =(
  • shaderfx
    Options
    Offline / Send Message
    shaderfx polycounter lvl 9
    There is a env variable you can enable so that Maya prints out any compile errors to the shell.
    Maybe that is helpful?
    (ShaderFX tells you what that env variable is when you first open the UI)

    But if you want to support all the different viewport modes that Maya has, then you have little choice but to add code for each different mode unfortunately.
  • brurpo
    Options
    Offline / Send Message
    brurpo polycounter lvl 8
    Thanks Kees! Thats very helpful!

    Since you are here, haha, let me seize the oportunity! Is there any hope that we get area light corners? Maya viewport has access to it, and preview it correctly, its exposed in the API. And maybe one day access to the framebuffer? It would be awesome to prototype full screen effects in shaderfx!


  • brurpo
    Options
    Offline / Send Message
    brurpo polycounter lvl 8
    BTW, this is What I am doing right now.

    A script to automatically connect substance painter textures to an arnold shader, then create a shaderfx preview materials with attributes linked to the arnold shader, so when you change one the other changes too, aiming to get as close as possible to the arnold render.

    Left is the viewport right is arnold render.
     
Sign In or Register to comment.