skarone
Hi Everyone... Im trying to figure out how to create a similar node like TextureToArray... but I only want to specify an uvcoord to get the color at that point via API.
I found two classes that I could use to get this work...

MImage.. with this one you can read but only from a path linking to a texture.

MRenderUtil with this one, that I think its the correct one, I can analyze the shading network to get the color at point, but seems to be very slow.

What I want to know if the TextureToArray node use some of this two, to get the color at point...

Best Regards, Ignacio Urruty

Reply 0 0
pshipkov
You are on the right track.
MImage is the right way to retrieve bitmap data, but you don't need it in this case.
You need MDynamicsUtil for fast lookup of a single texture node and MRenderUtil for (slow) lookup of shading network.

Reply 0 0
skarone
Hi God!!!:
Thanks a lot for the reply. I will make some tests with MDynamicsUtil and tell you the results.

 


Reply 0 0
skarone
Hi Im having troubles to make MDynamicsUtil::hasValidDynamics2dTexture work...
to get the texture node connected to the input color attribute im doing:
        MPlug compPlug( thisMObject(), densColor);
        MPlugArray conns;
        compPlug.connectedTo( conns, true, false, &status );
        MPlug conn = conns[0];
        MObject compNode = conn.node();
        bool hasTextureNode = MDynamicsUtil::hasValidDynamics2dTexture(compNode, densColor);

This is ok?...
or maybe
bool hasTextureNode = MDynamicsUtil::hasValidDynamics2dTexture(compNode, compPlug.attribute());

Please if you can correct me...
Sorry for the bad English =).


Reply 0 0
skarone
MMM I think my mistake was to forget to link OpenMayaFX.lib :eek:
Reply 0 0
skarone
Hiii:
Its working but I steel have an issue...
I could link directly a file texture node or a checker texture node, but if I connect a layered texture node, MDynamicsUtil::hasValidDynamics2dTexture dosen't recognize it, or if I want to use a 3D texture Node....
The only solution for this is to use the MRenderUtil?, that is slow....:confused:
Reply 0 0
pshipkov
Yes that's the point. MdynamicUtil works fast with one 2d texture node only. To sample complex shading networks or 3d texture nodes you need MRenderUtil and that's slow.
Reply 0 0
salvati.marc
I just discovered this post...
And i posted a similar question some minutes ago.

I tried the MRenderUtil::sampleShadingNetwork thing, but I got some crash as soon as i used two nodes in the same scene using this function ("R6025 error Pure virtual function call" ).


I call the function like this:
   
    void sampleOutputColorAttribute (MPlug& sampleColorPlug,
                                    MVectorArray& coords,
                                    MFloatVectorArray &resultcolors){
        MString nodeName = sampleColorPlug.name();
        MFloatMatrix mat;
        mat.setToIdentity ();
        MFloatArray uCoords;
        MFloatArray vCoords;
        MFloatPointArray refPoints;
        MFloatVectorArray resultTransparencies;
        int nbSamples = coords.length();
        uCoords.setLength(nbSamples);
        vCoords.setLength(nbSamples);
        refPoints.setLength(nbSamples);
        //resultcolors.setLength(nbSamples);
        //resultTransparencies.setLength(nbSamples);
        for (int i = 0; i< nbSamples; i++){
            uCoords[i] = coords[i].x;
            vCoords[i] = coords[i].y;
            refPoints[i].x = coords[i].x;
            refPoints[i].y = coords[i].y;
            refPoints[i].z = coords[i].z;
            refPoints[i].w = 1;
        }
        olm::McheckErr(MRenderUtil::sampleShadingNetwork(nodeName, nbSamples, false,false, mat,
                    NULL, &uCoords, &vCoords,NULL, &refPoints, NULL, NULL, NULL, resultcolors, resultTransparencies)
                ,"error during sampling");
    }
Reply 0 0
pshipkov
well, hard to say by that snippet of code, but i think your plugin is failing because of different reason.
That error message indicates that you forgot to implement virtual method.
Reply 0 0
salvati.marc
Thank you for your reply.

I think that I got issues because I called my sampling function from different shaders, and I may have had concurrency issues when rendering and having the sampling functions called for each UV sampled, which should not be the way to use this function I think.

Anyways, I now know that MRenderUtil and MDynamicUtil are the way to go.

Thank you.
Reply 0 0
Reply