Jump to content

custom shader with dynamic textures


Blax
 Share

Recommended Posts

Folks, hi, again!!!

I trying use BJS.DynamicTexture for draw in and next use in custom shader, but shader ignore geometry with shader material if i try set that texture as samplier2D.  And do not generate any Errors ((
If we switch off DynamicTexture or use simple Texture - all is ok.

Sorry, i can't make this case in PG. Try show situation here:

// var dataTexture       =   new BJS.Texture('/accel/static/i/fx/.../name.jpg',scene,true,false,0,function(){loadedTextures--;}); // its work
var dataTexture         =   new BJS.DynamicTexture("dataTx",{width:2048,height:2048}, scene,false,0);  // its dosent work

// later, when all textures is ready...

var shader = new BABYLON.ShaderMaterial("myShader", scene, "/accel/static/js/...",
{
     attributes: ["position", "normal","uv"],
     uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"]
});                

shader.setTexture     ("dataTx",     dataTexture, scene );
myGeom.material = shader;

in GLSL fragment

uniform     sampler2D   dataTx;

all is ok, if we change DynamicTexture to Texture.

Where i make wrong turn? )) 

Link to comment
Share on other sites

thanks for interest!

yes, is very simple and clear and i dont use this texture. Only use (shader.setTexture) dynamic texture bring problem.

p. s. i found another way for do what i need, but perhaps it is a bug and Babylonjs community has the meaning cath it?

VERTEX
precision highp float;

attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;

// Uniforms
uniform		mat4 		worldViewProjection;
uniform		mat4 		world;
uniform		float 		time;

uniform     sampler2D   hgTx;
uniform     sampler2D   colorTx;
uniform     sampler2D   dataTx;

varying 	vec2		vUV;
varying 	vec3		vPosition;

void main(void) {
 	vUV 		=	uv;
 	vPosition	=	position;
	gl_Position 	= 	worldViewProjection * vec4(vPosition, 1.);
}



FRAGMENT
precision highp float;

// Varying
varying 	vec3 		vPosition;
varying		vec3		vNormal;
varying 	vec2 		vUV;

// Uniforms
uniform     sampler2D   colorsTx;
uniform     sampler2D   hgTx;
uniform     sampler2D   dataTx;
uniform     float       time;

// ====================================================================================
// MAIN 
// ====================================================================================
void main(void) {
    vec3    height3         =   texture2D(hgTx,vUV).rgb;
    float   height          =   (height3.r + height3.g + height3.b) / 3.0;
    vec3    color 	        =	texture2D(colorsTx, vec2(0.999 - height,0.15)).rgb;
    gl_FragColor 			= 	vec4(color, 1.0);
}

 

Link to comment
Share on other sites

texture was empty, i only create DynamicTexture object (i think if it is a problem babylon throw any error). 
But we dont use this only declare it. And i think texture after creation has empty pixels. Not? (oops' sorry if it )))

While i dont know how i can attach shader files in PG.... use shaderStore?

And one more...problem (perhaps it limits Babylon.js propagation not only for me)
Digital Ocean hosting stable block PG for me (i use 2 ISP and it block both) and i forced use slow-slow VPN for see or make samples in PG. Use PG is hard for me.
i'm simple harmless home user on Linux. No spam, viruses, bots and etc. One of my ISP set my IP dynamicly. But...
Some times DOcean blocks API DOC too (((
It may be for many peoples? (

trace.png

Link to comment
Share on other sites

13 hours ago, Deltakosh said:

We are hosted by netlify so this may be their provider :)

please, see on screenshots - Netlify only "face", "proxy", "agent", "frontside" (i can't find right word). Real network space used of DO. Anyway access problem is sad fact. Perhaps it make netlify who's know? 
I try enter from work place (one more another ISP) and get same result (((
 

12 hours ago, NasimiAsl said:

may some plugin or extension append on your browser

nop. clear browsers and i try chrome, firefox and exotic falcon ))
In weekend i'll try make PG sample.


Thank you very much, man's!

Link to comment
Share on other sites

On 12/6/2018 at 1:02 PM, NasimiAsl said:

look this

https://get.webgl.org/ this hosted by  Digital Ocean

))) i'm talk about server blocking, it is not browser's problem ))) 
i think problem get chance on dissolve, when many users say about, i can waiting with use VPN. I need PG some times.


Anyway, i made sample in PG and get same result https://www.babylonjs-playground.com/#8W86ZM#2
Please, take a look.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...