rendering – Adding lighting to custom vertex shader in Unity

What’s the simplest way to add shadow functionality based on the modified vertices, nothing I’ve found online seems to work

 Shader "Unlit/HyperUnlit"
         _MainTex ("Texture", 2D) = "white" {}
         _Color("Color", Color) = (1,1,1,1)
         Tags { "RenderType"="Opaque" }
         LOD 100
             #pragma vertex vert
             #pragma fragment frag
             #include "UnityCG.cginc"
             #include "Complex.cginc"
             struct appdata
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             struct v2f
                 float2 uv : TEXCOORD0;
                 float4 vertex : SV_POSITION;
             sampler2D _MainTex;
             float4 _MainTex_ST;
             fixed4 _Color;
             float Tscale;
             float3 Tpos;
             float klein;
             float Rscale;
             //Mobius Transformation (a,b,c,d)
             float2 a;
             float2 b;
             float2 c;
             float2 d;
             v2f vert (appdata v)
                 v2f o;
                 //Reduce to float3
                 float3 worldPos = mul(unity_ObjectToWorld, float4(, 1)).xyz;
                 //2. Apply linear transformations
                 worldPos *= Tscale;
                 worldPos += Tpos;
                 //3. Apply mobius transformation    
                 worldPos = MobiusXZ(a,b,c,d, worldPos);
                 //4. Klein?
                 if (klein==1)
                     worldPos = PoincareToKlein(worldPos);
                 //5. Scale to disk radius
                 worldPos *= Rscale;
                 //Convert back to ? space
                 o.vertex = mul(UNITY_MATRIX_VP, float4(worldPos, 1));
                 //transform position to clip space
                 //o.vertex = UnityObjectToClipPos(v.vertex);
                 o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                 return o;
             fixed4 frag (v2f i) : SV_Target
                 // sample the texture
                 fixed4 col = tex2D(_MainTex, i.uv) * _Color;
                 return col;
         UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"

javascript – React Map GL not rendering using create-react-app

I would use React Mapbox GL using create react app helper, but I cannot render the map.

I’ve followed This example, using that code it works, but I don’t know how to build the App, so I’d prefer to use CRA.

In the console I don’t have any errors, and yeah, the token is correct.

I’ve read somewhere that i have to use <MapGL /> instead of <MapGL> ... </MapGL>, but as you will see, I do have other components inside the map, and even removing it, it gives me this error: TypeError: null is not an object (evaluating 'context.viewport.zoom')

How can I solve?

Here is my App component:

import MapGL, {
  ScaleControl, GeolocateControl,

} from 'react-map-gl';


 const (viewport, setViewport) = useState({
    latitude: 40,
    longitude: -100,
    zoom: 3.5,
    bearing: 0,
    pitch: 0
  const (popupInfo, setPopupInfo) = useState(null);

return (            
              <Suspense fallback={<div>Loading Events</div>}>
                <Pins onClick={setPopupInfo} />

              {popupInfo && (
                  <EventsInfo info={popupInfo} />

              <GeolocateControl style={geolocateStyle} />
              <FullscreenControl style={fullscreenControlStyle} />
              <NavigationControl style={navStyle} />
              <ScaleControl style={scaleControlStyle} />


Cuda API to render using Physically Based Rendering (PBR) in OpenGL-ES based project

Thanks for contributing an answer to Game Development Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

views – HOOK_views_pre_render() not rendering the updated results arraycorrectly

I have a D8 view with the main page display and created an embed display to get another dataset. I want to merge the result of both displays and make the embed display result sit at the very bottom, but, I don’t want to create an attachment instead of the embed display. So I wrote this piece of code to achieve this task:

function test_views_pre_render(ViewExecutable $view) {
  if($view->id() == 'courses' && $view->current_display == 'page_1') {
    $view2 = views_get_view_result('courses', 'embed_1');
    $view->result = array_merge($view->result, $view2);

When I check the result through xDebug I can see the view output contains the merged data. But, in the preview, I can only see 3 dots, which represent 3 items merged from the embed display onto the main display.

enter image description here

Surely a problem with rendering. Does anyone can see if I’m doing anything wrong here?. Thanks in advance for your help. Please excuse me about the question title.

An ECS rendering system – Game Development Stack Exchange

Thanks for contributing an answer to Game Development Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

Use MathJax to format equations. MathJax reference.

To learn more, see our tips on writing great answers.

rendering – Java AWT drawing tiles laves gap

I am trying to make a tile based game in Java and I have noticed a problem with the drawing. There is about a one pixel gap between some of the tiles and I am not sure what is causing it.

Here is a screenshot of it:

Here is my code so far:

Main class:

package Game.main;

import javax.swing.JFrame;

public class Main {
    public static JFrame window;
    public static void main(String() args) {
        window = new JFrame();
        window.setSize(1280, 720);
        Game game = new Game();

Game class:

package Game.main;

import javax.swing.JPanel;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;

import java.util.ArrayList;

import Game.tile.Tile;

public class Game extends JPanel implements Runnable {

    public Game() {

    boolean running = false;

    int width,height;

    ArrayList<Tile> tiles = new ArrayList<>();

    public void paint(Graphics g1) {
        //cast to graphics2d
        Graphics2D g = (Graphics2D)g1;
        //fill background
        g.fillRect(0, 0, width, height);
        //draw tiles
        for(int i = 0; i < tiles.size(); i++) {
            tiles.get(i).render(g, width, height);

    private void start() {
        Thread gameThread = new Thread(this);
        //create start tiles
        for(int x = 0; x < 1000; x+=10) {
            for(int y = 700; y < 1000; y+=20) {
                Tile tile = new Tile(x, y);

    public void run() {
        running = true;
        while(running) {
            //get window width and height
            width = Main.window.getWidth();
            height = Main.window.getHeight();
            //redraw current frame

Tile class:

package Game.tile;

import java.awt.Graphics2D;
import java.awt.Color;

public class Tile {
    public int x,y;
    public int w,h;
    public Tile(int x, int y) {
        this.x = x;
        this.y = y;
        this.w = 10;
        this.h = this.w*2;
    public void render(Graphics2D g, int width, int height) {
        g.fillRect(this.x*width/1000, this.y*height/1000, this.w*width/1000, this.h*height/1000);


Unity Project Settings: What is the difference between “Graphics -> SRP settings” and “Quality -> Rendering -> URP Asset”

As the title says, I am a bit confused about the aspect that the URP asset is referenced from two different settings:

  • Project Settings -> Graphics -> SRP settings
  • Project Settings -> Quality -> Rendering -> URP Asset

In a blank URP Project, “Project Settings -> Graphics -> SRP settings” references the HighQuality URP asset, and “Project Settings -> Quality -> Rendering -> URP Asset” has three different tiers, all of which reference their respective URP assed (i.e., either LowQuality, MediumQuality, or HighQuality.

Switching from one quality tier to another applies the respective URP asset, i.e., if I switch the quality tier to Low, the LowQuality URP asset is applied, even though the HighQuality is still set in “Project Settings -> Graphics -> SRP settings“.

So now the question: Why do I have to set a URP asset in “Project Settings -> Graphics -> SRP settings” if it seems that it is overridden by the URP asset defined in the quality tab?

How to use conditional rendering in Tsx file (React +Typescript)

I want to use condition in my Task -Status if value is 0 then "Not-Started" elseif value is 50 then in "In-progress" else "Completed"

Now I am using TaskStatus with value like 0,50,100

I am fetching the data through Graph API

enter image description here

Here is my code "item.percentcomplete" is having the value of tasks-status as 0,50,100

<h2>All Planner Tasks </h2>
    <table id="customers">
        <td>Start Date</td>
         <td>End Date</td>

     , key) =>
            <td id = "status">{item.percentComplete}</td>
            <td><a href =' '>{item.title}</a></td>
            <td>{moment(item.startDateTime).format('MM/DD/YYYY ')}</td>
          </tr> )


javascript – Images not rendering correctly on render component from Slick

I have an issue whenever I click on a product that rendering a product view component, images keeps showing previous product images until I refresh the page!


   v-if="product.similar_products && product.similar_products.length > 0"
   class="tab-pane active"


    <section class="similar-products" :class="'section-'+listing">
        <div class="container">
            <div class="text-center">
                <div class="similar-products-wrapper">
                            v-for="(item, index) in data"
                            <div class="panel panel-default product">
                                <div class="panel-body">
                                    <ProductCard v-bind:product="item"

    import Slick from 'Slick/Slick.vue';
    import {slick_mixins} from 'appUtl';
    import similar_products_mixins from '../mixins/similar_products';
    import ProductCard from './ProductCard.vue';

    export default {
        props: ('data', 'listing'),
        mixins:(slick_mixins, similar_products_mixins),
        components: {
        data() {
            return {
                show: true,
                slickOptions: {
                    dots: false,
                    infinite: false,
                    adaptiveHeight: true,
                    autoplay: false,
                    slidesToShow: 4,
                    slidesToScroll: 4,
                    responsive: (
                            breakpoint: 992,
                            settings: {
                                slidesToShow: 3,
                                slidesToScroll: 3
                            breakpoint: 768,
                            settings: {
                                slidesToShow: 2,
                                slidesToScroll: 2
                minLazyLoadIndex: (window.matchMedia("(max-width: 480px)").matches) ? 1 : 3


export default {
    methods: {
        next() {
        prev() {
        reInit() {
            this.$nextTick(() => {
        getItems:function () {
                return ();
   = false
            this.$nextTick(() => {
       = true
                this.$nextTick(() => {
        lazyLoadCard:function (index) {
            return (index > this.minLazyLoadIndex &&;
        handleBeforeChange(event, slick, currentSlide, nextSlide){
            if(nextSlide <= this.minLazyLoadIndex || !

            let slidId = '.product-item-card-'+this.listing+'-'+nextSlide+' .lazy-unveil-img';
            if($(slidId).attr('data-src') && $(slidId).attr('data-src').trim().length > 0) {
                $(slidId).attr('src', $(slidId).attr('data-src'));
                $(slidId).attr('data-src', null);
    updated() {
        if(this.$store.getters.isEditingMode) {
            if ( {
       = false;
            } else {
    mounted() {
        if(!this.$store.getters.isEditingMode) {
            setTimeout(() => {
            }, 600);

I was having same issue in another component, and solved by commenting this.$; + using v-once to render the SimilarProducts component as it was having multiple rendering. However, I tried to fix the similar issue here but nothing worked.

javascript – Rendering delay in Three.js

We are trying to build a web application for hand tracking and then rendering the results in three.js.

Hand tracking part is returning a frame almost every 40 ms (30 fps). We are using these results to change positions of created cubes in three.js.

The issue is that we are having a delay between the changing of the position and rendering the new position on the screen. Are we missing something here? or is it the normal expected performance from three.js

below are some description snapshots for the issue:

full js code:

import React from "react";
import * as THREE from "three";

interface ContainerProps {
  results: Object() | any;

class ThreeJSCanvas extends React.Component<ContainerProps> {
  state = {
    results: Object(),
    prevResults: Object(),

  scene: THREE.Scene;
  camera: THREE.Camera;
  raycaster: THREE.Raycaster | undefined;
  mouse: THREE.Vector2 | undefined;
  renderer: THREE.WebGLRenderer | undefined;
  handObjects: Array<number>;
  canvasWidth: number = 1280;
  canvasHeight: number = 720;

  private constructor(props: any) {
    this.scene = new THREE.Scene(); = new THREE.PerspectiveCamera(75, 1280 / 720, 0.1, 1000);
    this.handObjects = new Array<number>();

  componentDidMount() {

  componentDidUpdate() {
    if (this.props.results !== this.state.results) {
        prevResults: this.state.results,
        results: this.props.results,
  initialize() {
    this.scene = new THREE.Scene();
    this.raycaster = new THREE.Raycaster(); = new THREE.OrthographicCamera(
      this.canvasWidth / -2,
      this.canvasWidth / 2,
      this.canvasHeight / 2,
      this.canvasHeight / -2,
    let canvas = document.getElementById("threeJS-canvas") as HTMLCanvasElement;

    this.renderer = new THREE.WebGLRenderer({ canvas, alpha: true });
    this.renderer.setSize(1280, 720);
    document.body.appendChild(this.renderer.domElement); = 10;

  animate() {

  createCubes() {
    for (let i = 0; i < 21; i++) {
      let cube = this.addObject(1, 0, 0);

  updateCubesPosition() {
    for (let i = 0; i < this.state.results?.length; i++) {
      let obj = this.scene.getObjectById(this.handObjects(i));
      let pos = this.state.results(i);
      let x = pos.x * this.canvasWidth - this.canvasWidth / 2.0;
      let y = this.canvasHeight / 2.0 - pos.y * this.canvasHeight;
      obj?.position.set(x, y, 1);

  addObject(x: number, y: number, z: number): number {
    let box = new THREE.BoxGeometry(5, 5, 5);
    let mat = new THREE.MeshBasicMaterial({ color: this.randomColor() });
    let newCube = new THREE.Mesh(box, mat);
    newCube.position.x = x;
    newCube.position.y = y;
    newCube.position.z = z;

  rand(min: any, max: any) {
    if (max === undefined) {
      max = min;
      min = 0;
    return min + (max - min) * Math.random();
  randomColor() {
    return `hsl(${this.rand(0, 360) | 0}, ${this.rand(50, 100) | 0}%, 50%)`;

  render() {
    return (
        <canvas className="bottom" id="threeJS-canvas"></canvas>
export default ThreeJSCanvas;