Crash upon using TexGenAttrib with autoshader

Bug #424637 reported by FenrirWolf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Panda3D
Fix Released
Medium
rdb

Bug Description

Panda 1.6.2 from website, Windows 2003 (32), Python 2.5.2.

Use this code to test:

-----------------------------
from pandac.PandaModules import *
import direct.directbase.DirectStart

render.setShaderAuto()

smiley = loader.loadModel ('models/smiley.egg')
smiley.reparentTo (render)

tex = loader.loadTexture ('maps/envir-ground.jpg')
ts = TextureStage ('ts')

smiley.setTexture (ts, tex)
smiley.setTexGen(ts, TexGenAttrib.MWorldPosition)

run()
-----------------------------

The problem is that in ShaderGenerator::synthesize_shader, it enumerates all incoming texture coordinates to the shader. But it doesn't handle out-of-order texture stages with TexGenAttribs. It works fine if the first texture stage has a TexGen, but if it doesn't, there is a gap in the texcoord_vreg/texcoord_freg list, which causes a crash here:

for (int i=0; i<_num_textures; i++) {
    if (!tex_gen->has_stage(texture->get_on_stage(i))) {
      texcoord_vreg.push_back(alloc_vreg());
      texcoord_freg.push_back(alloc_freg());
      text << "\t in float4 vtx_texcoord" << i << " : " << texcoord_vreg[i] << ",\n"; // <-- Oops, crashes because second stage has TexGen, first does not, so #2 referenced in a singular-entry list.
      text << "\t out float4 l_texcoord" << i << " : " << texcoord_freg[i] << ",\n";
    }
  }

Original forum topic: http://www.panda3d.org/phpbb2/viewtopic.php?t=7021

rdb (rdb)
Changed in panda3d:
assignee: nobody → pro-rsoft (niertie1)
importance: Undecided → Medium
milestone: none → 1.7.0
status: New → Fix Committed
rdb (rdb)
Changed in panda3d:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.