With Theee.js, I'd like to add a directional light in the SkyShader demo scene
I can get the "sun" position, but I have no clues how to get the sun color to match with the light.
Is it possible ?
Thank you.
Is it possible ?
The sky shader computes the colors for a sky box. As you can see in the example these color values vary according to the fragments world position. And even if the shader would compute the expected color value, there is no easy way to extract it from the shader.
Hence, it's probably best if you manually choose an appropriate color for your directional light.
Related
I mean not bounding box and bounding sphere, but exactly pixel perfect, I mean.
Maybe shader or special renderer? Give different colors to different meshes, and by rendered colors detect what objects were selected?
After three days of googling, I haven't found a single answer on the Internet. Help, please.
For example, this Box should not be selected:
How does Blender do it? If I select many objects, he clearly understands what I have selected. Do you have any ideas about their algorithm?
Maybe we can paint objects in the scene in different colors, and render the scene, and then use the pixel colors to understand what colors are visible? And so we exploit the parallel nature of the graphics card? Its like raycasting, but by every selection pixel.
There is now a feature request at GitHub: github.com/mrdoob/three.js/issues/20530
I am working on a sketching tool with the help of threejs. This tool should allow users drawing cubes at any direction. I partially achieved this but still when I scale an object at negative direction the face colors get inverted. I am looking for a solution to avoid color inversion. mean the cube should be the same at both positive and negative scaling.
Please kindly help..!!
Thanks in advance.
Scaling at positive direction.
Scaling at negative direction.
If scaling negatively has unwanted artifacts, why don't you just avoid doing it? Your cubical meshes are symmetrical, so there no desired behaviour as far as I can tell.
In other words, display -50, but scale by the absolute value (50).
scale.set(Math.abs(scale)...)
If you really -do- need geometry flipping, take a look at this answer.
Since you draw cube and scale it lower than, it vertices are being drawn inside. you can set box's material as double sided.
I assume you are using MeshBasicMaterial
var material = new THREE.MeshBasicMaterial({side:THREE.DoubleSide});
var box = new THREE.Mesh(boxGeometryInstance, material);
Example here
I'm using PointLight in scene and ground reflects big light spot. What should I do to remove it? I only need to highlight some area on scene. So, I can decrease distance but it only decreasing size of spot. Not exactly I've expected. Should I use specific material on the ground or something like this?
Answer is very easy: set ground material's roughness to 1. I've updated example to see how roughness changes material.
I would like to upload a mesh with color coded scientific data in three.js. It should result in a nice shape with a realistic shadow, but the object's color itself should not depend on the position relativ to the light (in particular the side facing the light source and its opposite) in order for the color to remain in accordance with the data scale.
Is there an object property that I can set to fulfill this requirement?
If not is there a different workaround?
The simplest way is to use MeshBasicMaterial() http://threejs.org/docs/#Reference/Materials/MeshBasicMaterial which is not affected by the light.
Does anyone have any ideas how to fix the below issue?
The red is just a plane (representing water) with a shader material. I have written a custom shader for the water material, but its very simple (I get it to display red). As you can see from the image below the two particle systems seem to mess up the draw order.
Weirdly - if I use a standard THREE material for the water, like phong or lambert, then the issue doesn't happen. Is there some define / property that I need to change on the shader material to prevent this from happening?
Many
Thanks