logo
down
shadow

How to change texture in Gera library?


How to change texture in Gera library?

Content Index :

How to change texture in Gera library?
Tag : javascript , By : onurtopcu
Date : November 23 2020, 01:01 AM

I think the issue was by ths following , I have found the way, how to achieve the texture change.
You can do this with using the next code:
window.setTimeout( function() {
    var image = new Image();
    image.src = 'new-file-path.jpg';
    image.onload = function( event ) {
        var handledImage = event.target || event.srcElement;
        cube.texture.image = handledImage;
    };
}, 1000 );

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

FBO texture copy not working on Android - rendered texture filled with whatever is at texture coord 0, 0


Tag : android , By : kdietz
Date : March 29 2020, 07:55 AM
I wish this help you The declaration of your vertex shader output and fragment shader input do not mach for the texture coordinate varying (different precision qualifiers). Ordinarily this would not be an issue, but for reasons I will discuss below using highp in your fragment shader may come back to bite you in the butt.
Vertex shader:
attribute         vec4 position;
attribute mediump vec4 textureCoordinate;

varying   mediump vec2 coordinate;

void main()
{
  gl_Position = position;
  coordinate  = textureCoordinate.xy;
}
varying highp vec2      coordinate;

uniform       sampler2D texture;

void main()
{
  gl_FragColor = texture2D(texture, coordinate);
}
     #define GL_FRAGMENT_PRECISION_HIGH 1

How to set texture to automatically match with a change in window size by using same texture


Tag : unity3d , By : sayuki288
Date : March 29 2020, 07:55 AM
I wish this helpful for you I made a small 2D game by using unity3D(5.0.2f1). I dragged in some textures to use as the background in a scene. It worked well in the Unity Editor, but not when I built and ran it in a different window size. It didn't look as what I had seen in Unity Editor. , Maybe these will help!
//file ExtensionsHandy.cs
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public static class ExtensionsHandy
{
public static float OrthoScreenWidth(this Camera c)
    {
    return
        c.ViewportToWorldPoint(new Vector3(1,1,10)).x
        - c.ViewportToWorldPoint(new Vector3(0,1,10)).x;
    }

public static float OrthoScreenHeight(this Camera c)
    {
    return
        c.ViewportToWorldPoint(new Vector3(0,1,10)).y
        - c.ViewportToWorldPoint(new Vector3(0,0,10)).y;
    }

}
   void Start()
     {
     float w = Camera.main.OrthoScreenWidth();
     Debug.Log("w is " +w.ToString("f4");
     }
 transform.ScreenRight();
 transform.ScreenTop();
void Update()
  {
  transform.ScreenRight();
  }
public static Vector3 WP( this Camera c, float x, float y, float z)
    {
    return c.ViewportToWorldPoint(new Vector3(x,y,z));
    }

public static void ScreenLeft(this GameObject moveme)
    {
    Vector3 rr = moveme.transform.position;

    Vector3 leftTop = Camera.main.WP(0f,1f,0f);
    float leftX = leftTop.x;

    rr.x = leftX;

    moveme.transform.position = rr;
    }

public static void ScreenRight(this GameObject moveme)
    {
    Vector3 rr = moveme.transform.position;

    Vector3 rightTop = Camera.main.WP(1f,1f,0f);
    float rightX = rightTop.x;

    rr.x = rightX;

    moveme.transform.position = rr;
    }

public static void ScreenBottom(this GameObject moveme)
    {
    Vector3 rr = moveme.transform.position;

    Vector3 bottomLeft = Camera.main.WP(0f,0f,0f);
    float bottomY = bottomLeft.y;

    rr.y = bottomY;

    moveme.transform.position = rr;
    }

public static void ScreenTop(this GameObject moveme)
    {
    Vector3 rr = moveme.transform.position;

    Vector3 topLeft = Camera.main.WP(0f,1f,0f);
    float topY = topLeft.y;

    rr.y = topY;

    moveme.transform.position = rr;
    }

How to change texture of an object to a new texture via a trigger


Tag : javascript , By : JoeKaras
Date : March 29 2020, 07:55 AM
I hope this helps . I Have a trigger in my game and want to change the texture when the player enters a certain area. I have set up the trigger but can't get the image of the waal (object) to change? , Here is the code for changing wall material texture -
var Wall1: GameObject; \\Existing Game Object
var wall1TC: Texture; \\Texture to change Existing Game Object to.

function OnTriggerEnter() {

    Wall1.GetComponent.<Renderer>().material.mainTexture = wall1TC;

}

RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture


Tag : development , By : Julian Ivanov
Date : March 29 2020, 07:55 AM
To fix the issue you can do The issue is you're using COLOR_ATTACHMENT1 and skipping COLOR_ATTACHMENT0.
IIRC you need to start at attachment 0 and work your way up.
const gl = document.createElement("canvas").getContext("webgl2");

testAttachment(gl.COLOR_ATTACHMENT1);
testAttachment(gl.COLOR_ATTACHMENT0);

function testAttachment(attachmentPoint) {

  function createTexture() {
    var texture = gl.createTexture();

    gl.bindTexture(gl.TEXTURE_2D, texture);
    var level = 0;
    var internalFormat = gl.RGBA32UI;
    var border = 0;
    var format = gl.RGBA_INTEGER;
    var type = gl.UNSIGNED_INT;
    var data = null;
    gl.texImage2D(gl.TEXTURE_2D, level, internalFormat,
      1, 1, border, format, type, data);

    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
    return texture;
  }
  
  var texture = createTexture();

  var fb = gl.createFramebuffer();
  gl.bindFramebuffer(gl.FRAMEBUFFER, fb);

  var level = 0;
  gl.framebufferTexture2D(gl.FRAMEBUFFER, attachmentPoint, gl.TEXTURE_2D, texture, level);

  const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);

  console.log(glEnumToString(gl, attachmentPoint), glEnumToString(gl, status));
  
  if (status !== gl.FRAMEBUFFER_COMPLETE) {
    return;
  }
  
  const vs = `#version 300 es
  void main() {
     gl_Position = vec4(0,0,0,1);
     gl_PointSize = 100.0;
  }
  `;
  const fs = `#version 300 es
  uniform highp usampler2D color;
  out uvec4 outColor;
  void main() {
    outColor = texture(color, gl_PointCoord);
  }
  `;
  
  const prg = twgl.createProgram(gl, [vs, fs]);
  gl.useProgram(prg);
  
  // need a different input texture than output texture
  const inTex = createTexture();
  
  // no need to set uniforms since they default to 0
  // so using texture unit 0
  gl.drawArrays(gl.POINTS, 0, 1);

  // check that it rendered without error
  console.log(glEnumToString(gl, gl.getError()));
}

function glEnumToString(gl, value) {
  if (value === 0) { 
    return "NONE";
  }
  for (let key in gl) {
    if (gl[key] === value) {
      return key;
    }
  }
  return "0x" + value.toString(16);
}
<script src="https://twgljs.org/dist/4.x/twgl.min.js"></script>

Change the colors of a texture based on another texture in Unity?


Tag : unity3d , By : SilverRuby
Date : March 29 2020, 07:55 AM
hope this fix your issue GetPixels() returns an array of Color. If you want to get the color of single pixel, use GetPixel() instead. In your code try to change Color pixels2 = source.GetPixels(x, y);to Color pixels2 = source.GetPixel(x, y);
Update 1: Try to test this code. Working perfectly for me.
int width = 150;
int height = 150;
Texture2D secondTexture;
public Texture2D source; //texture for a test, add in inspector
public Renderer rend; //Object for a test, add in inspector

      void Start()

    {
      secondTexture = new Texture2D(width, height);

      var pixels = new Color[width * height];
for (var x = 0; x < width; x++)
{
   for (var y = 0; y < height; y++)
   {
            Color pixels2 = source.GetPixel(x, y);

            if(pixels2 == Color.white)
            {
              //Paint the pixels in secondTexture that match X and Y of sourceTexture with blue per example
              pixels[x + y * width] = Color.blue;
            }
            else
            {
             //Paint the rest of the pixels with black
             pixels[x + y * width] = Color.black;
            }
   }
}
secondTexture.SetPixels(pixels);
secondTexture.wrapMode = TextureWrapMode.Clamp;
secondTexture.Apply();

rend.material.mainTexture = secondTexture;
    }
Related Posts Related QUESTIONS :
  • How can I iterate over an Array object by using For IN or FOR OF
  • Launch local executable from web browser
  • How to prepare array of json objects to d3 hierarchical tree structure
  • VueJS - event emitted - show HTML before other calculations
  • Export SASS/SCSS variables to Javascript without exporting them to CSS
  • How to attach an event handler only once continuously
  • How to make button open a link in new tab in JavaScript?
  • Find range from the javascript object
  • How can I use my jQuery code as JavaScript?
  • How to show 5 images in a 2 row slider with bxslider
  • How to convert stream into variables in typescript
  • Three.js custom shader error on Chrome GL_INVALID_OPERATION: Active draw buffers with missing fragment shader outputs
  • My JavaScript doesn't work. How can I solve this problem?
  • Why is this async function is running synchronously?
  • Get updated variable from within react hook before return
  • I want to show all image preview but whenever I upload a new one the old one is gone
  • Would I be able to give access to specific electron APIs safely?
  • Why several clicks fire for each instance of a Class?
  • cant grab value from div using attr()
  • Make web service not accessible by browser?
  • Select DOM elements within template
  • How to customize angular ui-grid row background color?
  • Binding data in two respective $scope in AngularJS, how?
  • react put some props after import class
  • Variable is distributed among same components
  • switch class in jQuery/JavaScript for active/inactive state
  • How To Track Outbound Clicks Using Javascript
  • How to get total seconds elapsed since the beginning of the month?
  • Protractor: Stale element reference at "browser.wait(EC.visibilityOf(confDial), FIFTY_SECONDS);"
  • Access to an array inside an object
  • Reseting an JavaScript Interval with different value?
  • Learning Angular for the first time - version 2 or 4?
  • Rendering RSS feed (XML) in React with jquery, why do object values parsed from the feed seem empty?
  • Node.js xml2js http.request tag matching
  • applying texture to custom plane geometry in Threejs
  • How do I pass an Event as a function parameter in HTML written inside JavaScript variable?
  • Interface of object parameter with default value and default property
  • Does using try / catch rather than `.catch` observable operator with XHR requests reduce performance?
  • In IE11 background colors not working on printing
  • TypeScript interface signature "(): string"
  • Is synchronous XMLHttpRequest supported in Internet Explorer 10 and 11?
  • Axios function not returning any values with js
  • How to use firestore TIMESTAMP to create time-stamp in JavaScript
  • Instantiate subclass without constructing
  • Outputing a created object in javascript to a server side JSON file
  • Transition the numeric labels in a bar chart
  • createBottomTabNavigator: hide just one tab from the tabBar
  • iife vs simple statement behavior with document.title
  • showDialogPopup Refresh Page after Click
  • Child component does not set the initial value passed from the parent: ReactJS
  • Nodejs javascript added to button not responding
  • Trying to define a promise.all
  • Python GEE to extract featurecollection timeseries from Landsat imageries
  • How to write negative binary number?
  • Unable to set property of individual object
  • Why Named Function Expression itself cannot assign Name to another Value?
  • How to reset scroll position on single page pagination
  • How to scroll to bottom of page, when a new message is sent - Socket.io
  • How to reconstruct audio blob from a base64 encoded String?
  • How to calculate numbers within an array of objects
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com