RenderKit / ospray

An Open, Scalable, Portable, Ray Tracing Based Rendering Engine for High-Fidelity Visualization
http://ospray.org
Apache License 2.0
1.02k stars 186 forks source link

Cannot wrap texture in mirrored mode #270

Closed celime closed 8 months ago

celime commented 6 years ago

Is it possible to have the OpenGL GL_MIRRORED_REPEAT texture wrap mode ?

before sampling the texture: if (MIRROR_MODE) { if (int(u)&1) u=-u; if (int(v)&1) v=-v; } Thanks

johguenther commented 6 years ago

Actually OSPRay does currently not know about texture wrap modes (REPEAT is always used). The material or the renderer can use different modes by manipulating the texture-coordinates (like you wrote). For example we have an internal utility function clamp2edge.

So, what is your usecase? Would it be sufficient for you to add above code? Or do we really need a new texture property "wrap mode", similar to the texture transformations?

celime commented 6 years ago

I think the mirrored repeat mode have to be an internal property, because it is not possible to emulate it via the user defined textures coordinates.

For instance, with a rectangle, if 'u' go from 0.0 to 3.0, there is 3 texture repeats, but it's not possible to control the mirrored sampling method. (In fact, it is possible with others costly operations: Split the rectangle in 3 parts, or else build a new texture with four time the original size).

I think we really need a new texture property "wrap mode".

Thanks

johguenther commented 6 years ago

What I meant is changing the source code in OSPRay for yourself / for your application (I tried that this morning with the scivis renderer), not changing the model. If that's not so easy we can add that as a new feature to OSPRay.

celime commented 6 years ago

Yes, I will add that property in my own OSPray compiled instance. By the way, thank you very much for the nice work in the OSPray engine !

johguenther commented 3 years ago

FYI, texture wrap modes will be implemented

stukowski commented 3 years ago

FYI, texture wrap modes will be implemented

That's great news. For my application I require support for texture coordinate clamping (like OpenGL's GL_CLAMP_TO_EDGE wrap mode).

Context: I want to implement pseudo-color mapping of a scalar field defined on a rendered surface mesh. The scalar field values are associated with the mesh vertices and passed to OSPRay as UV texture coordinates (in the U component, V remains unused). A 1-d texture map containing a color gradient is used to map scalar field values to RGB colors on a per-pixel basis. Out-of-bounds field values (below 0.0/above 1.0) should be mapped to the border colors of the gradient map. This currently does not work with the wrap-around behavior of textures.