x


Shader works in Editor Mode, breaks when running.

I have a shader that combines two textures based upon a projection matrix. This shader works fine in the editor but the uvs don't seem to map properly while the game is running. The texture is vertically compressed and tears at the bottom of the screen.

I rewrote the below shader as a cg shader and the effect was the same, vertically compressed and torn.

So what would cause a shader to behave differently in editor as opposed to in play mode in engine.

Shader "AngleCombine" {

    Properties {        
        _MainTex ("Base (RGB) Gloss(A)", 2D) = "white" {}   
        _Other("Other", 2D) = "white" { }
    }

    Subshader {
        Pass {
            SetTexture[_MainTex] { combine texture }

            SetTexture[_Other] {                
                matrix [_ProjMatrix]
                combine texture * previous DOUBLE
            }
        }
    }

    Subshader {
        Pass {
            SetTexture [_MainTex] { combine texture }
        }
    }

}
more ▼

asked Apr 28 '11 at 03:46 PM

Fraser gravatar image

Fraser
1 1 1 1

Where are you setting _ProjMatrix? Also, you don't ever need to use { combine texture }, if you care.

Apr 28 '11 at 04:08 PM Jessy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

It would look like your _ProjMatrix might be the only possible culprist.

How do you process it? How do you set it?

more ▼

answered Apr 28 '11 at 04:15 PM

taoa gravatar image

taoa
1.6k 8 13 34

The _ProjMatrix is set by a script that calculates it based upon the camera angle. It seems to calculate it properly because it displays properly in the the editor (it would be impossible for it to display like that without the _ProjMatrix).

Apr 28 '11 at 04:35 PM Fraser
(comments are locked)
10|3000 characters needed characters left

The issue was caused by the matrix not properly transforming at non-zero values. I still don't know why it behaved differently in editor than in game (as the object is static and never moves).

more ▼

answered Apr 28 '11 at 05:12 PM

Fraser gravatar image

Fraser
1 1 1 1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1673
x1655
x491

asked: Apr 28 '11 at 03:46 PM

Seen: 794 times

Last Updated: Apr 28 '11 at 03:46 PM