Comments (4)
so I added compareMode
and compareFunc
(v5.5.1) as they were easy to add, but just FYI, twgl's goal is not to replace all of native WebGL. It's just to help in a few verbose situations. For example there is no twgl code for gl.enable
, gl.clearColor
, gl.depthFunc
and 100s of other WebGL functions.
In any case, this should work now
const tex = twgl.createTexture(gl, {
width: gl.canvas.width,
height: gl.canvas.height,
internalFormat: gl.DEPTH_COMPONENT32F,
compareMode: gl.COMPARE_REF_TO_TEXTURE,
});
const fbi = twgl.createFramebufferInfo(gl, [
{ internalFormat: gl.RGBA8 },
{ attachment: tex, attachmentPoint: gl.DEPTH_ATTACHMENT },
]);
https://jsgist.org/?src=50a8c4f0432c15da48f3ccec3cec4b13
or this
const fbi = twgl.createFramebufferInfo(gl, [
{ internalFormat: gl.RGBA8 },
{ internalFormat: gl.DEPTH_COMPONENT32F, compareMode: gl.COMPARE_REF_TO_TEXTURE },
]);
const tex = fbi.attachments[1];
https://jsgist.org/?src=72183c6e6e3f2ad18a5827e45b82bc45
from twgl.js.
Can't you just do this?
const tex = twgl.createTexture(gl, {
width: gl.canvas.width,
height: gl.canvas.height,
internalFormat: gl.DEPTH_COMPONENT32F,
});
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
eg: https://jsgist.org/?src=8e9958a6741267edbe0c1fdab4bf352e
from twgl.js.
Thanks!
So your first tip pointed me towards doing this
const shadowMapTex = createTexture(gl, {
width: 1024,
height: 1024,
format: gl.DEPTH_COMPONENT,
internalFormat: gl.DEPTH_COMPONENT32F,
wrap: gl.CLAMP_TO_EDGE,
})
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR)
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE)
Which is working really well, I never thought about combining texParameteri()
calls with twgl for some reason
Great you're making this part of the library, but also if you feel making this part of twgl is pushing too far into a 1:1 rewrite of the WebGL API I can understand that too.
from twgl.js.
So fyi, even before this change you could do this
const shadowMapTex = createTexture(gl, {
width: 1024,
height: 1024,
format: gl.DEPTH_COMPONENT,
internalFormat: gl.DEPTH_COMPONENT32F,
wrap: gl.CLAMP_TO_EDGE,
minMag: gl.LINEAR,
})
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE)
If you want to set both TEXTURE_MIN_FILTER
and TEXTURE_MAG_FILTER
to the same thing. and min
and mag
are there if you want to set them to separate things.
from twgl.js.
Related Issues (20)
- Dynamically changing attribute values, does it require to create bufferinfo everytime
- Last framebuffer's attached texture is empty? HOT 3
- Incorrect sentence structure.
- GPGPU particles example performance HOT 5
- resizeCanvasToDisplaySize in a web worker sets the width and height to 0 HOT 2
- Should not update the number of elements too HOT 1
- Question about simple triangle rendering HOT 1
- Inconsistent `type` type in `createAttribsFromArrays` HOT 8
- Defer checking shader compile status HOT 8
- Unsetting a texture in webgl2 HOT 3
- gl.useProgram(program); HOT 1
- bindTransformFeedbackInfo with offset HOT 3
- Get the jsdoc into the tsd HOT 2
- Incorrect TypeScript types of `createAugmentedTypedArray` HOT 2
- twgl-base package.json refers to non-existent `module` file HOT 2
- Cubemap uses only first texture HOT 3
- Rendering objects using drawObjectList causes skybox to not be rendered HOT 6
- `opt_locations` of createProgramInfo is missing from typescript bindings HOT 2
- webgpu support ? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twgl.js.