Incorrect texture display on vertical plane in OpenGL2019 Community Moderator ElectionHow do I center text horizontally and vertically in a TextView?Textured points in OpenGL ES 2.0?glTexGen in OpenGL ES 2.0OpenGL texture not following geometryClipping-planes in OpenGL ES 2.0Android OpenGL ES 2.0 black texturesOpenGL ES 2.0 Failing to correctly assign the color attributeMoving texture OpenGL ES 2.0OpenGL ES Texture Not Renderingtype mismatch in arithmetic operation between vec4 and vec3 OpenGL ES

PTIJ: Mordechai mourning

Difference between 'stomach' and 'uterus'

Can a space-faring robot still function over a billion years?

PTIJ: What dummy is the Gemara referring to?

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

I've given my players a lot of magic items. Is it reasonable for me to give them harder encounters?

Levi-Civita symbol: 3D matrix

GDAL GetGeoTransform Documentation -- Is there an oversight, or what am I misunderstanding?

Can we carry rice to Japan?

The need of reserving one's ability in job interviews

Should we avoid writing fiction about historical events without extensive research?

Convergence to a fixed point

Is there a way to find out the age of climbing ropes?

Is there any relevance to Thor getting his hair cut other than comedic value?

Was it really inappropriate to write a pull request for the company I interviewed with?

Has Wakanda ever accepted refugees?

How to kill a localhost:8080

How can neutral atoms have exactly zero electric field when there is a difference in the positions of the charges?

Create chunks from an array

A bug in Excel? Conditional formatting for marking duplicates also highlights unique value

When was drinking water recognized as crucial in marathon running?

GPL code private and stolen

How do you say “my friend is throwing a party, do you wanna come?” in german

Can I solder 12/2 Romex to extend wire 5 ft?



Incorrect texture display on vertical plane in OpenGL



2019 Community Moderator ElectionHow do I center text horizontally and vertically in a TextView?Textured points in OpenGL ES 2.0?glTexGen in OpenGL ES 2.0OpenGL texture not following geometryClipping-planes in OpenGL ES 2.0Android OpenGL ES 2.0 black texturesOpenGL ES 2.0 Failing to correctly assign the color attributeMoving texture OpenGL ES 2.0OpenGL ES Texture Not Renderingtype mismatch in arithmetic operation between vec4 and vec3 OpenGL ES










0















Working on AR app and trying to replace plane texture.



I'm trying to render texture on vertical and horizontal planes. It's working fine for horizontal planes, but doesn't work well on vertical.



enter image description here



i found that something wrong with texture_coord calculations, but can't figure it out (new to OpenGL).



Here is my vertex shader



void main()

vec4 local_pos = vec4(a_position, 1.0);
vec4 world_pos = u_model * local_pos;

texture_coord = world_pos.sp * u_scale;

gl_Position = u_mvp * local_pos;



fragment shader



out vec4 outColor;



void main()

vec4 control = texture(u_texture, diffuse_coord);

float dotScale = 1.0;

float lineFade = 0.5;

vec3 newColor = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb : control.g > u_gridControl.y ? u_lineColor.rgb * lineFade: u_lineColor.rgb * 0.25 * lineFade;

outColor = vec4(newColor, 1.0);










share|improve this question




























    0















    Working on AR app and trying to replace plane texture.



    I'm trying to render texture on vertical and horizontal planes. It's working fine for horizontal planes, but doesn't work well on vertical.



    enter image description here



    i found that something wrong with texture_coord calculations, but can't figure it out (new to OpenGL).



    Here is my vertex shader



    void main()

    vec4 local_pos = vec4(a_position, 1.0);
    vec4 world_pos = u_model * local_pos;

    texture_coord = world_pos.sp * u_scale;

    gl_Position = u_mvp * local_pos;



    fragment shader



    out vec4 outColor;



    void main()

    vec4 control = texture(u_texture, diffuse_coord);

    float dotScale = 1.0;

    float lineFade = 0.5;

    vec3 newColor = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb : control.g > u_gridControl.y ? u_lineColor.rgb * lineFade: u_lineColor.rgb * 0.25 * lineFade;

    outColor = vec4(newColor, 1.0);










    share|improve this question


























      0












      0








      0








      Working on AR app and trying to replace plane texture.



      I'm trying to render texture on vertical and horizontal planes. It's working fine for horizontal planes, but doesn't work well on vertical.



      enter image description here



      i found that something wrong with texture_coord calculations, but can't figure it out (new to OpenGL).



      Here is my vertex shader



      void main()

      vec4 local_pos = vec4(a_position, 1.0);
      vec4 world_pos = u_model * local_pos;

      texture_coord = world_pos.sp * u_scale;

      gl_Position = u_mvp * local_pos;



      fragment shader



      out vec4 outColor;



      void main()

      vec4 control = texture(u_texture, diffuse_coord);

      float dotScale = 1.0;

      float lineFade = 0.5;

      vec3 newColor = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb : control.g > u_gridControl.y ? u_lineColor.rgb * lineFade: u_lineColor.rgb * 0.25 * lineFade;

      outColor = vec4(newColor, 1.0);










      share|improve this question
















      Working on AR app and trying to replace plane texture.



      I'm trying to render texture on vertical and horizontal planes. It's working fine for horizontal planes, but doesn't work well on vertical.



      enter image description here



      i found that something wrong with texture_coord calculations, but can't figure it out (new to OpenGL).



      Here is my vertex shader



      void main()

      vec4 local_pos = vec4(a_position, 1.0);
      vec4 world_pos = u_model * local_pos;

      texture_coord = world_pos.sp * u_scale;

      gl_Position = u_mvp * local_pos;



      fragment shader



      out vec4 outColor;



      void main()

      vec4 control = texture(u_texture, diffuse_coord);

      float dotScale = 1.0;

      float lineFade = 0.5;

      vec3 newColor = (control.r * dotScale > u_gridControl.x) ? u_dotColor.rgb : control.g > u_gridControl.y ? u_lineColor.rgb * lineFade: u_lineColor.rgb * 0.25 * lineFade;

      outColor = vec4(newColor, 1.0);







      android opengl-es arcore






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 15 hours ago









      Nicol Bolas

      289k33481653




      289k33481653










      asked 19 hours ago









      Андрей ГузюкАндрей Гузюк

      4822830




      4822830






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The important bit is texture_coord = world_pos.sp in your vertex shader.



          There are 3 ways to refer to the components of a vector in GLSL. xyzw (the most common), rgba (more natural for colours), stpq (more natural for texture coordinates).



          The line texture_coord = world_pos.sp would be clearer if it were written as texture_coord = world_pos.xz.



          Once you realize that you're generating texture coordinates by ignoring the y-component it's obvious why vertical planes are not textured how you would like.



          Unfortunately there's no simple one line fix. Perhaps tri-planar texturing might be an appropriate solution for you - this seems to be a good explanation of the technique.






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021187%2fincorrect-texture-display-on-vertical-plane-in-opengl%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The important bit is texture_coord = world_pos.sp in your vertex shader.



            There are 3 ways to refer to the components of a vector in GLSL. xyzw (the most common), rgba (more natural for colours), stpq (more natural for texture coordinates).



            The line texture_coord = world_pos.sp would be clearer if it were written as texture_coord = world_pos.xz.



            Once you realize that you're generating texture coordinates by ignoring the y-component it's obvious why vertical planes are not textured how you would like.



            Unfortunately there's no simple one line fix. Perhaps tri-planar texturing might be an appropriate solution for you - this seems to be a good explanation of the technique.






            share|improve this answer



























              0














              The important bit is texture_coord = world_pos.sp in your vertex shader.



              There are 3 ways to refer to the components of a vector in GLSL. xyzw (the most common), rgba (more natural for colours), stpq (more natural for texture coordinates).



              The line texture_coord = world_pos.sp would be clearer if it were written as texture_coord = world_pos.xz.



              Once you realize that you're generating texture coordinates by ignoring the y-component it's obvious why vertical planes are not textured how you would like.



              Unfortunately there's no simple one line fix. Perhaps tri-planar texturing might be an appropriate solution for you - this seems to be a good explanation of the technique.






              share|improve this answer

























                0












                0








                0







                The important bit is texture_coord = world_pos.sp in your vertex shader.



                There are 3 ways to refer to the components of a vector in GLSL. xyzw (the most common), rgba (more natural for colours), stpq (more natural for texture coordinates).



                The line texture_coord = world_pos.sp would be clearer if it were written as texture_coord = world_pos.xz.



                Once you realize that you're generating texture coordinates by ignoring the y-component it's obvious why vertical planes are not textured how you would like.



                Unfortunately there's no simple one line fix. Perhaps tri-planar texturing might be an appropriate solution for you - this seems to be a good explanation of the technique.






                share|improve this answer













                The important bit is texture_coord = world_pos.sp in your vertex shader.



                There are 3 ways to refer to the components of a vector in GLSL. xyzw (the most common), rgba (more natural for colours), stpq (more natural for texture coordinates).



                The line texture_coord = world_pos.sp would be clearer if it were written as texture_coord = world_pos.xz.



                Once you realize that you're generating texture coordinates by ignoring the y-component it's obvious why vertical planes are not textured how you would like.



                Unfortunately there's no simple one line fix. Perhaps tri-planar texturing might be an appropriate solution for you - this seems to be a good explanation of the technique.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 6 hours ago









                ColumboColumbo

                3,7622817




                3,7622817





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55021187%2fincorrect-texture-display-on-vertical-plane-in-opengl%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко