Code Monkey home page Code Monkey logo

Comments (2)

tgjones avatar tgjones commented on May 27, 2024

With DEPTH_RANGE_ZERO_TO_ONE, did you mean that would be a C# #define?

A more discoverable API might be to have it as a property on the [VertexShader] attribute? It could be a DepthRangeTransform enum, defaulting to the current behaviour.

I'm trying to think of other intrinsic functions that could make use of this and coming up blank. That's probably just because it's late :) It does seem like a useful piece of metadata to have.

from shadergen.

mellinoe avatar mellinoe commented on May 27, 2024

With DEPTH_RANGE_ZERO_TO_ONE, did you mean that would be a C# #define?

In my mind, it would be a preprocessor condition that is used but not defined in the shader code, e.g.:

gl_Position = output_.Position;
#if !DEPTH_RANGE_ZERO_TO_ONE
gl_Position.z = gl_Position.z * 2.0 - gl_Position.w;
#endif

By default, nothing would be change, but you could do something like this on the C# side:

string defines = string.Empty;
if (GraphicsDevice.IsDepthRangeZeroToOne)
{
    defines = "DEPTH_RANGE_ZERO_TO_ONE";
}

byte[] shaderBytes = LoadShader("myShader.vert", defines); // Add defines into the text and return bytes

(Prototype of that API in this Veldrid branch)

A more discoverable API might be to have it as a property on the [VertexShader] attribute? It could be a DepthRangeTransform enum, defaulting to the current behaviour.

I'm trying to think of a way that you can write your shader in a "portable" way, such that it will work under both depth range schemes. If we had a more robust "configuration system", perhaps you could just tell ShaderGen to spit out both versions of the shader -- but that's much more complicated.

I'm trying to think of other intrinsic functions that could make use of this and coming up blank.

I think there might need to be some kind of builtin function that does depth comparisons for you, based on whether or not that define is set.

from shadergen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.